:root {
    --bg: #1a1a1a;
    --card: #222;
    --border: #444;
    --text: #e0e0e0;
    --accent: #f0d000;
    --accent-hover: #ffea00;
    --success: #2ecc71;
    --danger: #e74c3c;
    --muted: #888;
}

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

body {
    font-family: 'Vazir', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

button, input, select, textarea, a, span, p,
h1, h2, h3, h4, h5, h6, td, th, label {
    font-family: 'Vazir', Tahoma, sans-serif;
}



@font-face {
    font-family: 'Vazir';
    src: url('/static/fonts/vazir/Vazir-Light-FD-WOL.eot');
    src: url('/static/fonts/vazir/Vazir-Light-FD-WOL.eot?#iefix') format('embedded-opentype'),
         url('/static/fonts/vazir/Vazir-Light-FD-WOL.woff') format('woff'),
         url('/static/fonts/vazir/Vazir-Light-FD-WOL.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazir';
    src: url('/static/fonts/vazir/Vazir-Bold-FD.woff') format('woff');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
}

/* Header */
.top-bar {
    background: #111;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent);
    text-decoration: none;
}
nav {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}
nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
}
nav a:hover { color: var(--accent); }
.user-name { color: var(--muted); font-size: 0.9rem; }
.badge {
    background: var(--accent);
    color: #111;
    border-radius: 50%;
    padding: 2px 7px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-right: 4px;
}

/* Buttons */
.btn-primary, .btn-outline, .btn-danger, .btn-success {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--accent);
    color: #111;
    font-weight: bold;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }

/* Cards & forms */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.form-control {
    width: 100%;
    padding: 10px 12px;
    background: #111;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 1rem;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
}
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Messages */
.messages { margin: 12px auto; }
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 8px;
}
.alert-success { background: #1a3a2a; border: 1px solid var(--success); }
.alert-error, .alert-danger { background: #3a1a1a; border: 1px solid var(--danger); }
.alert-warning { background: #3a3a1a; border: 1px solid var(--accent); }
.alert-info { background: #1a2a3a; border: 1px solid #3498db; }

/* Categories */
.categories-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    overflow-x: auto;
}
.categories-bar .label {
    color: var(--accent);
    font-weight: bold;
    white-space: nowrap;
    margin-left: 8px;
}
.cat-btn {
    background: #111;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.cat-btn:hover,
.cat-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: #2a2a1a;
}
.nav-arrow {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 6px;
}

/* Search */
.search-fold {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}
.search-fold select,
.search-fold input { flex: 1; }

/* ========== PRODUCT ROW (GRID) ========== */
.product-row {
    display: grid;
    direction: rtl;
    grid-template-columns: 56px minmax(0, 1fr) auto auto auto;
    grid-template-areas: "img title price qty btn";
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
}

.product-row .img-box     { grid-area: img; }
.product-row .title       { grid-area: title; min-width: 0; text-align: right; }
.product-row .price       { grid-area: price; color: var(--accent); font-weight: bold; white-space: nowrap; font-size: 1.05rem; }
.product-row .qty-control { grid-area: qty; }
.product-row .add-btn     { grid-area: btn; }

.product-row .img-box {
    width: 56px;
    height: 56px;
    background: #111;
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.product-row .img-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.product-row .title strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-row .stock {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 2px;
}

.product-row .qty-control {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
}
.product-row .qty-control button {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 1.1rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
}
.product-row .qty-control input {
    width: 50px;
    text-align: center;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1rem;
}
.product-row .unit {
    color: var(--muted);
    font-size: 0.85rem;
}

/* تبلت: عنوان زیر ردیف */
@media (max-width: 900px) {
    .product-row {
        direction: ltr; /* چپ/راست فیزیکی ثابت */
        grid-template-columns: auto auto 1fr 56px;
        grid-template-areas:
            "btn qty price img"
            "title title title title";
        align-items: center;
    }

    .product-row .add-btn {
        grid-area: btn;
    }
    .product-row .qty-control {
        grid-area: qty;
        width: auto;
        max-width: max-content;
        justify-content: center;
        align-self: center;
    }
    .product-row .price {
        grid-area: price;
        justify-self: end;
    }
    .product-row .img-box {
        grid-area: img;
    }
    .product-row .title {
        grid-area: title;
        text-align: right;
        width: 100%;
    }
    .product-row .title strong {
        white-space: normal;
    }
}

/* موبایل: تصویر کنار عنوان (جای HERE) */
@media (max-width: 600px) {
    .product-row {
        direction: rtl;
        display: grid;
        grid-template-columns: 1fr 72px;
        grid-template-areas:
            "title img"
            "price img"
            "qty   qty"
            "btn   btn";
        gap: 10px 12px;
        align-items: start;
    }

    .product-row .img-box {
        grid-area: img;
        width: 72px;
        height: 72px;
        min-width: 72px;
        min-height: 72px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        background: #111;
        border: 1px solid var(--border);
        border-radius: 6px;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .product-row .img-box img {
        display: block !important;
        width: 100%;
        height: 100%;
        object-fit: cover;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .product-row .title {
        grid-area: title;
        text-align: right;
        min-width: 0;
    }

    .product-row .title strong {
        white-space: normal;
    }

    .product-row .price {
        grid-area: price;
        text-align: right;
    }

    .product-row .qty-control {
        grid-area: qty;
        width: 100%;
        justify-content: center;
    }

    .product-row .add-btn {
        grid-area: btn;
        width: 100%;
        padding: 12px 16px;
    }
}











/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}
th {
    color: var(--muted);
    font-weight: normal;
    font-size: 0.9rem;
}
.total-row {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}
.status-pending { background: #3a3a1a; color: var(--accent); }
.status-confirmed { background: #1a3a2a; color: var(--success); }
.status-preparing { background: #1a2a3a; color: #3498db; }
.status-shipped { background: #2a1a3a; color: #9b59b6; }
.status-completed { background: #1a3a2a; color: var(--success); }
.status-cancelled { background: #3a1a1a; color: var(--danger); }
.status-draft { background: #333; color: #aaa; }

.footer {
    margin-top: 100px;
    padding: 20px 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

.auth-box {
    max-width: 420px;
    margin: 40px auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 28px;
}
.auth-box h1 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--accent);
    font-size: 1.5rem;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--muted);
}


select.form-control,
.search-fold select,
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #111;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23f0d000' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center; /* فاصله فلش از لبه چپ */
    padding: 10px 12px 10px 36px; /* چپ بیشتر = جا برای فلش */
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    direction: rtl;
}

.search-fold select {
    padding-left: 36px;
    background-position: left 14px center;
}



/* ===== Responsive Tables ===== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* اسکرول نرم روی iOS */
  margin-bottom: 8px;
}

/* جدول داخل wrapper */
.table-wrap table {
  width: 100%;
  min-width: 520px; /* حداقل عرض تا ستون‌ها له نشن */
  border-collapse: collapse;
}

/* کمی فشرده‌تر کردن روی موبایل */
@media (max-width: 640px) {
  .table-wrap table {
    font-size: 0.85rem;
  }
  .table-wrap th,
  .table-wrap td {
    padding: 8px 10px;
    white-space: nowrap; /* جلوگیری از شکستن متن داخل سلول */
  }
  /* ستون محصول اجازه داره کمی جمع بشه */
  .table-wrap td:first-child,
  .table-wrap th:first-child {
    white-space: normal;
    min-width: 120px;
  }
}
















