:root {
    --primary: #007aff;
    --bg: #f9fafb;
    --surface: #fff;
    --border: #e5e7eb;
    --text: #111827;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


html,
body {
    height: 100%;
    font-family: 'Vazir', sans-serif;
    direction: rtl;
    background: var(--bg);
    color: var(--text);
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    width: 70px;
    /* عرض لوگو */
    height: 20px;
    /* ارتفاع لوگو */
    flex-shrink: 0;
    /* جلوگیری از کوچک شدن لوگو */
}

.logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* مقیاس‌دهی مناسب بدون برش */
}



.search-bar input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.categories button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #6b7280;
    color: #fff;
}


#drop-area {
    flex: 1;
    position: relative;
    background: var(--surface);
}

#canvas {

    background: transparent;
}

.toolbar {
    padding: 10px;
    background: var(--bg);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}



.main {
    display: flex;
    flex: 1;
    overflow: visible;
    /* ✅ اصلاح شد */
    z-index: 15;
}

.sidebar {
    width: 300px;
    background-color: #fff;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 15;
}

.search-bar input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.categories button {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    background: #6b7280;
    color: white;
}

.models {


    display: grid;
    grid-template-columns: repeat(2, 110px);
    /* دو ستون با عرض ثابت */

    justify-content: center;
    /* وسط‌چین */


}


.model {
    width: auto;
    /* اندازه پیش‌نمایش دلخواه */
    height: 74px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* اگه عکس بزرگ باشه، داخل باکس جمع میشه */

    box-sizing: border-box;
    padding: 8px;
}


.model img,
.model .model-thumb {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    /* تناسب تصویر حفظ میشه */
    display: block;
}


#drop-area {
    width: 100%;
    height: 100%;
    flex: 1;
    position: relative;
    background-color: white;
    overflow: visible;

    background-image:

        /* سطح 3: 17.5px */
        linear-gradient(to right, rgba(170, 170, 170, 0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(170, 170, 170, 0.1) 1px, transparent 1px),

        /* سطح 3: 17.5px */
        linear-gradient(to right, rgba(170, 170, 170, 0.2) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(170, 170, 170, 0.2) 1px, transparent 1px),

        /* سطح 2: 35px */
        linear-gradient(to right, rgba(170, 170, 170, 0.4) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(170, 170, 170, 0.4) 1px, transparent 1px);


    background-size:
        12.5px 12.5px,
        12.5px 12.5px,
        25px 25px,
        25px 25px,
        50px 50px,
        50px 50px;

}

.placed-wrapper {
    position: absolute;
    transform-origin: center center;
    transition: transform 0.1s ease-in-out;
}

.placed-wrapper img.placed {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
}

.placed-wrapper.selected {
    outline: 2px dashed #007aff;
    z-index: 20;
}


.rotate-handle {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
}

.rotate-handle:hover {
    opacity: 1;
}

.rotate-handle img {
    width: 60px;
    height: 60px;
    pointer-events: none;
}




.product-card {
    font-family: 'Dana', sans-serif;
    direction: rtl;
    justify-content: center;
    align-items: center;
    display: none;
    position: absolute;
    width: 310px;
    background-color: #f9f9f9;
    border: 1px solid #666;
    z-index: 1000;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);

}



.title {
    font-size: 18px;
    font-weight: bold;
    text-align: right;
    margin-bottom: 12px;
    border-bottom: 2px solid #444;
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#closeBtn {
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: #000;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    font-size: 14px;
}



.info-row select,
.cushion-controls select {
    padding: 6px 12px 6px 12px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-family: inherit;
    font-size: 14px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg fill='%23666' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 8px center;
    background-size: 16px;
    background-color: #fff;
    min-width: 120px;
    direction: rtl;
}


.info-row-color select,
.cushion-controls select {
    padding: 6px 12px 6px 12px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-family: inherit;
    font-size: 13px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg fill='%23666' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 8px center;
    background-size: 12px;
    background-color: #fff;
    min-width: 100px;
    direction: rtl;
}

.desc {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #444;
}

.divider {
    margin: 20px 0;
    border-top: 1px solid #ccc;
}

.bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.quantity-control {
    display: flex;
    align-items: center;
    background: #f1f1f1;
    border-radius: 6px;
    padding: 4px 10px;
    gap: 6px;
}

.quantity-control button {
    border: none;
    background: transparent;
    font-size: 16px;
    cursor: pointer;
}

.price {
    font-weight: bold;
    color: #111;
}

.add-button {
    margin-top: 20px;
    width: 100%;
    background: #3e464a;
    color: white;
    padding: 10px;
    font-size: 16px;
    font-family: 'Dana', sans-serif;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.add-button::before {
    content: "+";
    font-size: 20px;
}

/* کوسن&zwnj;ها */
.cushion-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-top: 4px;
    width: 100%;
}

.add-cushion-btn {
    background-color: #444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family: 'Dana', sans-serif;
}

.cushion-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
}

.cushion-item {
    background: #f1f1f1;
    padding: 6px 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cushion-qty {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cushion-qty button,
.cushion-remove {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
}

.cushion-remove {
    color: red;
    font-weight: bold;
}

.cushion-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cushion-row label {
    white-space: nowrap;
    min-width: 70px;
}

.cushion-row .add-cushion-btn {
    flex-shrink: 0;
    padding: 6px 12px;
}

.cushion-row select {
    flex-grow: 1;
}

.btnback {
    padding: 4px;
    width: 100px;
}

.main-container {
    display: flex;
    height: calc(100vh - 60px);
}

.sidebar-top-tabs {
    display: flex;
    justify-content: space-around;
    border-bottom: 1px solid #e0e0e0;
}

.tab {
    flex-grow: 1;
    text-align: center;
    padding: 10px 5px;
    cursor: pointer;
    font-size: 0.7em;
    color: #000;
    transition: 0.2s;
}

.tab:hover {
    background-color: #eee;
    color: #000;
}

.tab.active-tab-color {
    background-color: #eee;
    color: #000;
}

.sidebar-content-area {
    flex-grow: 1;
    display: flex;
    overflow-y: auto;
    scrollbar-width: none;
}

.sidebar-content-area::-webkit-scrollbar {
    display: none;
}

.main-sidebar-content {
    width: 150;
    flex-grow: 1;
    padding: 15px;
}

.content-section {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #e0e0e0;
}

.content-section:last-child {
    border-bottom: none;
}

.content-section h6 {
    margin-bottom: 15px;
    font-size: 0.8em;
    color: #444;
}






.grid-item:hover {
    border-color: #aaa;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}





.vertical-toolbar {
    width: 70px;
    background-color: #f8f8f8;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    /* در صورت نیاز به تراز در بالا */
    z-index: 10;
    /* از اسکرول شدن زیر سایر المان‌ها جلوگیری می‌کند */
}

.toolbar-icon {
    width: 20px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-family: 'Rajdhani';
    font-size: 13px;

}


.toolbar-icon.active-category {
    background-color: #eee;
    width: 70px;
    height: 40px;
}

.btnsabt {
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 0 20p;


}



.backtool1 {


    padding: 6px 10px;
    height: 40px;
    background: #eee;
    /* خاکستری خیلی روشن */
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);


}


.tool-panel {
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 0 20p;
    margin-right: 100px;
}

/* تول&zwnj;بار پس&zwnj;زمینه */
.backtool {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: fit-content;
    padding: 6px 10px;
    height: 40px;
    background: #eee;
    /* خاکستری خیلی روشن */
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin: 20px auto;
    /* وسط&zwnj;چین کردن */
}

/* استایل دکمه&zwnj;ها */
.tool-panel button {
    background: #eee;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

/* آیکون داخل دکمه */
.tool-panel button img {
    width: 15px;
    height: 15px;
    pointer-events: none;
}

/* هاور */
.tool-panel button:hover {
    background-color: white;
    /* خاکستری روشن */
}

/* دکمه فعال */
.tool-panel button.active {
    background-color: white;

}


.btn-dropdown-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    /* فاصله بین دکمه ثبت و منو */
    justify-content: flex-start;
    /* همه به سمت چپ */
}

.btnsabt button {
    font-family: 'Vazir', sans-serif;
    width: 60px;
    height: 30px;
    background: #666;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
}

.dropdown {
    position: relative;
    /* برای نمایش درست منو */
}

.dropdown-menu {
    top: 35px;
    /* پایین دکمه */
    left: 0;
    /* کنار دکمه ثبت */
}


.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
}

.dropdown-toggle .arrow-down {
    font-size: 8px;
    margin-top: 2px;
}

.dropdown-toggle img {
    width: 20px;
    height: 20px;
}

.dropdown-menu {
    direction: ltr;
    display: none;
    position: absolute;
    top: 30px;
    left: 0;
    background-color: white;
    border: 1px solid #ddd;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 999;
    min-width: 160px;
    padding: 6px 0;
    border-radius: 6px;
}

.dropdown-menu div {
    padding: 8px 16px;
    cursor: pointer;
}

.dropdown-menu div:hover {
    background-color: #f0f0f0;
}

.dropdown.open .dropdown-menu {
    display: block;
}

table {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}

th,
td {
    border: 1px solid #000;
    padding: 6px;
    font-size: 14px;
    vertical-align: middle;
    text-align: center;
    word-wrap: break-word;
}



.table-wrapper {
    position: relative;
    max-width: 100%;
}

.small {
    font-size: 12px;
}

/* حالت عادی: مخفی */
#print-footer {
    display: none;
}

/* حالت چاپ: نمایش بده */
@media print {
    #print-footer {
        display: block !important;
        /* فقط هنگام چاپ نمایش داده می‌شود */
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        text-align: center;
        background-color: white;
        padding: 10px 0;
    }

    /* سایر تنظیمات چاپ شما */
    body * {
        visibility: hidden !important;
    }

    #drop-area,
    #drop-area * {
        visibility: visible !important;
    }

    #drop-area {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100vw !important;
        /* پر کنه عرض کل صفحه */
        height: 100vh !important;
        /* پر کنه ارتفاع کل صفحه */
        transform: none !important;
        background-color: white !important;
        /* بک‌گراند شطرنجی */
        background-image: linear-gradient(to right, rgba(170, 170, 170, 0.1) 1px, transparent 1px), linear-gradient(to bottom, rgba(170, 170, 170, 0.1) 1px, transparent 1px), linear-gradient(to right, rgba(170, 170, 170, 0.2) 1px, transparent 1px), linear-gradient(to bottom, rgba(170, 170, 170, 0.2) 1px, transparent 1px), linear-gradient(to right, rgba(170, 170, 170, 0.4) 1px, transparent 1px), linear-gradient(to bottom, rgba(170, 170, 170, 0.4) 1px, transparent 1px);
        background-size: 12.5px 12.5px, 12.5px 12.5px, 25px 25px, 25px 25px, 50px 50px, 50px 50px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    canvas {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        /* تناسب حفظ بشه */
    }

    #print-footer,
    #print-footer * {

        visibility: visible !important;
    }
}

@page {
    size: A4 landscape;
    /* یا A3 , A1 ... */
    margin: 0;
}