:root {
    --gold: #b8860b;
    --gold-light: #daa520;
    --gold-dark: #8b6508;
    --gold-soft: #fff8e1;
    --sidebar-bg: #1a1a2e;
    --sidebar-bg-2: #16213e;
    --sidebar-bg-active: #0f3460;
    --sidebar-text: #ccd6f6;
    --sidebar-text-active: #fff;
    --sidebar-width: 260px;
    --body-bg: #f4f6f9;
    --border-color: #dee2e6;
}

body {
    font-family: 'Vazirmatn', 'Segoe UI', sans-serif;
    background: var(--body-bg);
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    z-index: 1060;
    overflow: hidden;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar-inner::-webkit-scrollbar { width: 5px; }
.sidebar-inner::-webkit-scrollbar-track { background: transparent; }
.sidebar-inner::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.sidebar .brand {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar .brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar .brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.15);
    background: #fff;
}

.sidebar .brand-text h4 {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.sidebar .brand-text small {
    color: #8892b0;
    font-size: 0.68rem;
}

.sidebar-section-label {
    padding: 0.7rem 1.1rem 0.3rem;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6676a0;
}

.sidebar .nav {
    padding: 0 0.6rem;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
    border-radius: 7px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1px;
    transition: all 0.2s;
    position: relative;
}

.sidebar .nav-link i.bi {
    font-size: 1.10rem;
    width: 22px;
    text-align: center;
    color: #8892b0;
    transition: all 0.2s;
}

.sidebar .nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.sidebar .nav-link:hover i.bi { color: var(--gold-light); }

.sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(184,134,11,0.35);
}

.sidebar .nav-link.active i.bi { color: #fff; }

.sidebar .nav-indicator { font-size: 0.75rem; }

.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-clock {
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.clock-time {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gold-light);
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

.clock-date {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    margin-top: 4px;
}

.sidebar-currency {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #8892b0;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

.sidebar-currency i.bi { font-size: 1.1rem; color: var(--gold-light); }

/* Sidebar responsive (custom toggle) */
.sidebar-backdrop {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* Default state: sidebar hidden on mobile, visible on desktop */
@media (max-width: 991.98px) {
    [dir="ltr"] .sidebar { transform: translateX(-100%); }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 0 0 30px rgba(0,0,0,0.3);
    }
    [dir="ltr"] .sidebar.open, [dir="rtl"] .sidebar.open { transform: translateX(0) !important; }
}

/* Desktop: collapsed sidebar (toggle button collapses/expands) */
@media (min-width: 992px) {
    [dir="ltr"] .sidebar.collapsed { transform: translateX(-100%); }
    [dir="rtl"] .sidebar.collapsed { transform: translateX(100%); }
    .sidebar.collapsed ~ .main-wrapper { margin-left: 0 !important; }
    [dir="rtl"] .sidebar.collapsed ~ .main-wrapper { margin-right: 0 !important; margin-left: 0 !important; }
}

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin 0.3s ease;
    display: flex;
    flex-direction: column;
}

[dir="rtl"] .main-wrapper {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

@media (max-width: 991.98px) {
    .main-wrapper, [dir="rtl"] .main-wrapper { margin: 0 !important; }
}

/* ===== TOPBAR ===== */
.topbar {
    background: #fff;
    padding: 0.7rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1030;
    gap: 15px;
    flex-wrap: wrap;
}

.topbar-title {
    margin: 0;
    font-weight: 700;
    color: #2d3436;
    font-size: 1.15rem;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #2d3436;
    padding: 0 6px;
    border-radius: 6px;
}

.sidebar-toggle:hover { background: var(--gold-soft); color: var(--gold); }

.topbar-datetime {
    border-inline-end: 1px solid var(--border-color);
    padding-inline-end: 15px;
}

.datetime-item {
    font-size: 0.8rem;
    color: #495057;
    white-space: nowrap;
}

.datetime-item i.bi { margin-inline-end: 4px; }

.clock-digital {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: var(--gold-dark);
    background: var(--gold-soft);
    padding: 2px 10px;
    border-radius: 6px;
    border: 1px solid rgba(184,134,11,0.2);
}

/* FA vs EN visibility */
.fa-only { display: none; }
html[dir="rtl"] .fa-only { display: inline-flex; }
html[dir="rtl"] .en-only { display: none; }
html[dir="ltr"] .fa-only { display: none !important; }
html[dir="ltr"] .en-only { display: inline-flex; }

.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ===== STAT CARDS ===== */
.stat-card {
    background: #fff;
    border-radius: 0.75rem;
    padding: 1.25rem;
    border-inline-start: 4px solid var(--gold);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card.border-primary { border-inline-start-color: #0d6efd; }
.stat-card.border-success { border-inline-start-color: #198754; }
.stat-card.border-warning { border-inline-start-color: #ffc107; }
.stat-card.border-danger  { border-inline-start-color: #dc3545; }
.stat-card.border-info    { border-inline-start-color: #0dcaf0; }
.stat-card.border-purple  { border-inline-start-color: #6f42c1; }

.stat-icon { font-size: 2rem; opacity: 0.85; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #2d3436; }
.stat-label { font-size: 0.78rem; color: #636e72; }

/* ===== CARDS ===== */
.card {
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-radius: 0.75rem;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #eef0f2;
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* ===== TABLES - Full bordered ===== */
.table {
    --bs-table-bg: transparent;
    --bs-table-border-color: #dee2e6;
    margin: 0;
    border: 1px solid var(--border-color);
    width: 100%;
}

.table-bordered > :not(caption) > *,
.table-bordered > :not(caption) > * > * {
    border-color: #dee2e6;
}

.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #495057;
    border-bottom-width: 2px;
    white-space: nowrap;
}

.table td { vertical-align: middle; font-size: 0.86rem; }
.table-hover tbody tr:hover { background-color: var(--gold-soft); }
.table-row-striped:nth-child(even) { background: #fafbfc; }

/* Wrap all data tables with full border */
.card .table {
    border-inline-start: 1px solid var(--border-color);
    border-inline-end: 1px solid var(--border-color);
}

.order-number {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: var(--gold-dark);
}

.gold-text { color: var(--gold); }

/* ===== MODALS (RTL friendly) ===== */
/* Keep modals above the fixed sidebar (z-index 1060) */
.modal-backdrop { z-index: 1500 !important; }
.modal { z-index: 1505 !important; }

.modal-content {
    border: none;
    border-radius: 0.85rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.modal-header {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #fff;
    border-radius: 0.85rem 0.85rem 0 0;
    border-bottom: none;
    padding: 0.9rem 1.25rem;
}

.modal-header .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
}

.modal-header .modal-title i.bi { margin-inline-end: 6px; }

/* Force title icons to white on the gold gradient (override .gold-text) */
.modal-header .modal-title .gold-text,
.modal-header .modal-title i.bi { color: #fff; }

.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    margin-inline-start: auto;
}

/* RTL-safe modal header layout */
[dir="rtl"] .modal-header {
    flex-direction: row;
    justify-content: flex-start;
    text-align: right;
}

[dir="rtl"] .modal-header .btn-close {
    margin-right: auto;
    margin-left: 0;
}

.modal-body { padding: 1.5rem; }
.modal-footer {
    border-top: 1px solid #eef0f2;
    padding: 1rem 1.5rem;
}

/* Fix RTL in modal: select2 dropdown & text alignment */
[dir="rtl"] .modal .form-label { text-align: right; }
[dir="rtl"] .modal .form-control, [dir="rtl"] .modal .form-select { text-align: right; }
[dir="rtl"] .modal-body .row > [class*="col-"] { text-align: right; }
[dir="rtl"] .modal .modal-footer { justify-content: flex-start; }
[dir="rtl"] .modal .input-group > .form-control:not(:last-child) { border-radius: 0 0.375rem 0.375rem 0; }

/* ===== Table action button groups (RTL-safe, supports nested <form>) ===== */
.table .btn-group.btn-group-sm {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex-wrap: nowrap;
}

.table .btn-group.btn-group-sm .btn,
.table .btn-group.btn-group-sm form {
    margin: 0;
}

.table .btn-group.btn-group-sm .btn {
    border-radius: 0.375rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.table .btn-group.btn-group-sm form { display: inline-flex; }

[dir="rtl"] .table .btn-group.btn-group-sm .btn { margin-inline-end: 0; }
[dir="rtl"] .table .btn-group.btn-group-sm > * + * { margin-inline-start: 3px; }

.input-group { flex-wrap: nowrap; }

/* ===== SELECT2 RTL & modal fix ===== */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--border-color) !important;
    min-height: 38px;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 38px;
    padding-inline-start: 0.75rem;
    font-size: 0.88rem;
}

[dir="rtl"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow { left: 3px; right: auto; }
[dir="rtl"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { text-align: right; }
.select2-dropdown { border-color: var(--border-color) !important; }
.select2-results__option { font-size: 0.85rem; }

/* ===== BUTTONS ===== */
.btn-gold {
    background: var(--gold);
    border-color: var(--gold);
    color: #fff;
    font-weight: 500;
}

.btn-gold:hover {
    background: var(--gold-dark);
    border-color: var(--gold-dark);
    color: #fff;
}

.btn-outline-gold {
    color: var(--gold);
    border-color: var(--gold);
}

.btn-outline-gold:hover {
    background: var(--gold);
    color: #fff;
}

/* Badges */
.badge-status { font-size: 0.72rem; font-weight: 500; padding: 0.35em 0.65em; }
.summary-table td { padding: 6px 12px; }
.summary-table .total-row td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--gold); color: var(--gold-dark); }

/* ===== DataTables RTL + full border ===== */
.dataTables_wrapper {
    padding: 0.25rem;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    min-width: 180px;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.3rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--gold) !important;
    border-color: var(--gold) !important;
    color: #fff !important;
    border-radius: 6px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--gold-light) !important;
    border-color: var(--gold-light) !important;
    color: #fff !important;
    border-radius: 6px;
}

/* RTL pagination - reverse order */
[dir="rtl"] .dataTables_wrapper .dataTables_paginate .paginate_button { float: right; }
[dir="rtl"] .dataTables_wrapper .dataTables_paginate { text-align: left; }
[dir="rtl"] .dataTables_wrapper .dataTables_info { text-align: right; }
[dir="rtl"] .dataTables_wrapper .dataTables_length { text-align: right; }
[dir="rtl"] .dataTables_wrapper .dt-header .dataTables_filter { text-align: left; }
[dir="rtl"] .dt-header > div,
[dir="rtl"] .dt-footer > div { flex: 0 0 auto; }

/* DataTables row layout fixes for RTL */
.dataTables_wrapper .dt-header, .dataTables_wrapper .dt-footer {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
}

/* ===== Alerts ===== */
.alert { border-radius: 0.75rem; }

/* ===== Print ===== */
@media print {
    .sidebar, .topbar, .sidebar-backdrop, .no-print { display: none !important; }
    .main-wrapper { margin: 0 !important; }
    .content-area { padding: 0; }
}
