/* فونت فارسی وزیر (لوکال و آفلاین) */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazir.woff2') format('woff2'),
        url('../fonts/Vazir.woff') format('woff'),
        url('../fonts/Vazir.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazir';
    src: url('../fonts/Vazir.woff2') format('woff2'),
        url('../fonts/Vazir.woff') format('woff'),
        url('../fonts/Vazir.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* اصلاح نگاشت آیکون‌های کنتور و گیج برای هماهنگی با وب‌فونت‌های پروژه */
.fa-gauge-high:before,
.fa-gauge:before,
.fa-tachometer-alt:before,
.fa-tachometer:before,
.fa-dashboard:before {
    content: "\f3fd" !important;
}

:root {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #2563eb;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-on-dark: #f8fafc;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;

    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --info: #0284c7;
    --info-light: #f0f9ff;

    --border-color: #e2e8f0;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --sidebar-width: 270px;
}

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

body {
    font-family: 'Vazirmatn', 'Vazir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    font-size: 14px;
}

button,
input,
select,
textarea,
optgroup {
    font-family: 'Vazirmatn', 'Vazir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

code,
kbd,
samp {
    font-family: 'Vazirmatn', 'Vazir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}


/* ساختار کلی صفحه داشبورد */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* منوی جانبی راست (Sidebar) */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--text-on-dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 100;
    transition: all 0.3s ease;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 24px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
}

.menu-category {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 12px 8px 12px;
}

.menu-item {
    margin-bottom: 4px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
}

.menu-link:hover {
    background-color: var(--bg-sidebar-hover);
    color: #ffffff;
}

.menu-link.active {
    background-color: var(--bg-sidebar-active);
    color: #ffffff;
    font-weight: 600;
}

.menu-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* محتوای اصلی (Main Content Area) */
.main-content {
    margin-right: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* نوار بالای صفحه (Top Header) */
.top-header {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--primary-light);
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid #dbeafe;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background-color: var(--primary);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-info-text {
    font-size: 13px;
}

.user-name {
    font-weight: 700;
    color: var(--text-primary);
}

.user-role {
    color: var(--text-secondary);
    font-size: 11px;
}

/* بدنه اصلی محتوا (Page Body) */
.page-body {
    padding: 28px;
    flex: 1;
}

/* کارت‌ها و گریدها */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background-color: var(--bg-surface);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.primary {
    background-color: var(--primary-light);
    color: var(--primary);
}

.stat-icon.success {
    background-color: var(--success-light);
    color: var(--success);
}

.stat-icon.warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

.stat-icon.danger {
    background-color: var(--danger-light);
    color: var(--danger);
}

/* کارت محتوای اصلی (Content Box) */
.card-box {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
    min-width: 0;
    max-width: 100%;
}

.card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* جدول داده‌ها (Data Tables) */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.data-table th {
    background-color: #f1f5f9;
    color: var(--text-secondary);
    font-weight: 700;
    padding: 14px 16px;
    font-size: 13px;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 13.5px;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

/* نشان‌ها و بج‌ها (Badges) */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background-color: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

.badge-danger {
    background-color: var(--danger-light);
    color: var(--danger);
}

.badge-info {
    background-color: var(--info-light);
    color: var(--info);
}

.badge-secondary {
    background-color: #f1f5f9;
    color: var(--text-secondary);
}

/* دکمه‌ها (Buttons) */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-success {
    background-color: var(--success);
    color: #ffffff;
}

.btn-success:hover {
    background-color: #15803d;
}

.btn-warning {
    background-color: #d97706;
    color: #ffffff;
}

.btn-warning:hover {
    background-color: #b45309;
}

.btn-info {
    background-color: var(--info);
    color: #ffffff;
}

.btn-info:hover {
    background-color: #0369a1;
}

.btn-secondary {
    background-color: #e2e8f0;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-sm {
    padding: 9px 9px;
    font-size: 12px;
}

/* فرم‌ها و اینپوت‌ها */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-control {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text-primary);
    background-color: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

/* اعتبارسنجی فرم‌ها (Form Validation Styles) */
.form-control.is-invalid {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

.invalid-feedback {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #dc2626;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* هشدارها و فلش مسج‌ها */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background-color: var(--success-light);
    border: 1px solid #bbf7d0;
    color: #166534;
}

.alert-error {
    background-color: var(--danger-light);
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-warning {
    background-color: var(--warning-light);
    border: 1px solid #fde68a;
    color: #92400e;
}

/* استایل سفارشی پنجره‌های SweetAlert2 */
.swal2-popup {
    font-family: 'Vazirmatn', 'Vazir', -apple-system, BlinkMacSystemFont, sans-serif !important;
    direction: rtl !important;
    text-align: right !important;
    border-radius: var(--radius-md) !important;
    padding: 24px !important;
}

.swal2-title {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: var(--text-primary) !important;
}

.swal2-html-container {
    font-size: 14px !important;
    color: var(--text-secondary) !important;
    line-height: 1.7 !important;
}

.swal2-actions {
    gap: 10px !important;
}

.swal2-confirm,
.swal2-cancel {
    font-family: inherit !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    border-radius: var(--radius-sm) !important;
    padding: 10px 22px !important;
}


/* کامپوننت پلاک خودرو ایران (National Iran License Plate) */
.iran-plate-badge {
    display: inline-flex;
    align-items: center;
    direction: ltr;
    background: #ffffff;
    border: 2px solid #1e293b;
    border-radius: 6px;
    height: 34px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    font-family: inherit;
    font-weight: 800;
    user-select: none;
    vertical-align: middle;
}

.iran-plate-flag {
    background: #1e3a8a;
    color: #ffffff;
    width: 22px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    padding: 2px;
    border-right: 1px solid #1e293b;
}

.iran-plate-part1,
.iran-plate-part2 {
    padding: 0 6px;
    font-size: 15px;
    color: #0f172a;
    letter-spacing: 1px;
}

.iran-plate-letter {
    padding: 0 4px;
    font-size: 14px;
    color: #0f172a;
    font-weight: 900;
}

.iran-plate-code {
    border-left: 2px solid #1e293b;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    background: #f8fafc;
}

.iran-plate-code span {
    font-size: 8px;
    color: #64748b;
    line-height: 1;
}

.iran-plate-code strong {
    font-size: 13px;
    color: #0f172a;
    line-height: 1.1;
}

/* فوتر */
.app-footer {
    padding: 20px 28px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 12.5px;
    color: var(--text-secondary);
}

/* ===================================================================
   طراحی واکنش‌گرا و سامانه موبایلی (Mobile Responsive Framework)
   =================================================================== */

/* وضعیت پیش‌فرض دسکتاپ برای المان‌های موبایل (پنهان در دسکتاپ) */
.mobile-hamburger-btn {
    display: none !important;
}

.sidebar-close-btn {
    display: none !important;
}

.sidebar-mobile-indicator {
    display: none !important;
}

.sidebar-backdrop {
    display: none !important;
}

.mobile-bottom-nav {
    display: none !important;
}

.header-right-side {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.header-left-side {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

/* قوانین استایل‌دهی تبلت و موبایل (عرض صفحه کمتر از 992px) */
@media (max-width: 991px) {

    /* ۱. بدنه و محتوای اصلی */
    .app-container {
        display: block;
        width: 100%;
        overflow-x: hidden;
    }

    .main-content {
        margin-right: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    body {
        padding-bottom: 60px;
    }

    body.sidebar-open {
        overflow: hidden !important;
    }

    /* ۲. نوار بالایی و هدر در موبایل */
    .top-header {
        height: 60px;
        padding: 0 14px;
        position: sticky;
        top: 0;
        z-index: 900;
        background-color: #ffffff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .header-right-side {
        gap: 10px;
        flex: 1;
    }

    .header-left-side {
        gap: 8px;
    }

    /* دکمه منوی همبرگری با تم و رنگ سایدبار */
    .mobile-hamburger-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        background-color: var(--bg-sidebar) !important;
        color: #ffffff !important;
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: var(--radius-sm);
        font-size: 17px;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(15, 23, 42, 0.18);
        transition: transform 0.15s ease, background-color 0.2s ease;
        flex-shrink: 0;
    }

    .mobile-hamburger-btn:active {
        transform: scale(0.92);
        background-color: #1e293b !important;
    }

    .page-header-title {
        font-size: 14px !important;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 140px;
    }

    /* مشخصات کاربر لاگین شده در هدر موبایل */
    .user-profile-badge {
        padding: 4px 10px !important;
        gap: 8px !important;
        background: rgba(37, 99, 235, 0.08) !important;
        border-radius: 20px !important;
        border: 1px solid #dbeafe !important;
    }

    .user-avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 12px !important;
    }

    .user-name {
        font-size: 11.5px !important;
        font-weight: 700 !important;
        max-width: 90px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .user-role {
        display: none !important;
        /* پنهان کردن نقش در موبایل برای تمیزی هدر */
    }

    .header-logout-btn {
        padding: 6px 9px !important;
        font-size: 12px !important;
    }

    .header-logout-btn span {
        display: none !important;
        /* فقط نمایش آیکون خروج */
    }

    /* ۳. سایدبار کشویی در موبایل (Drawer Menu) */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        width: 290px !important;
        max-width: 86vw !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 1050 !important;
        box-shadow: -4px 0 25px rgba(0, 0, 0, 0.35) !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .sidebar.is-open,
    body.sidebar-open .sidebar {
        transform: translateX(0) !important;
    }

    .sidebar-close-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 6px;
        color: #f8fafc;
        font-size: 15px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .sidebar-close-btn:active {
        background: rgba(239, 68, 68, 0.25);
        color: #f87171;
    }

    .sidebar-mobile-indicator {
        display: flex !important;
        align-items: center;
        gap: 8px;
        padding: 8px 16px;
        background: rgba(37, 99, 235, 0.15);
        color: #93c5fd;
        font-size: 11px;
        font-weight: 600;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    /* پس‌زمینه تیره نیمه‌شفاف هنگام باز بودن منو */
    .sidebar-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.65);
        backdrop-filter: blur(2px);
        z-index: 1040;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-backdrop.is-open,
    body.sidebar-open .sidebar-backdrop {
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* فیلتر منوها در موبایل: فقط نمایش منوهایی که دسترسی سامانه موبایلی دارند */
    .sidebar .menu-item:not(.mobile-allowed),
    .sidebar .menu-category:not(.mobile-allowed) {
        display: none !important;
    }

    /* ۴. فوتر پایین صفحه در موبایل (Mobile Bottom Navigation Bar) */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        height: 58px;
        z-index: 1000;
        background-color: #ffffff;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.07);
        align-items: center;
        justify-content: space-around;
        padding: 0 4px;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #64748b;
        text-decoration: none;
        font-size: 10.5px;
        font-weight: 600;
        flex: 1;
        height: 100%;
        border: none;
        background: none;
        cursor: pointer;
        transition: color 0.15s ease;
    }

    .mobile-nav-item i {
        font-size: 17px;
    }

    .mobile-nav-item.active,
    .mobile-nav-item:active {
        color: var(--primary);
    }

    /* دکمه وسط منوی کشویی */
    .mobile-nav-icon-circle {
        width: 44px;
        height: 44px;
        background-color: var(--bg-sidebar);
        color: #ffffff;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        margin-top: -16px;
        border: 3px solid #ffffff;
        box-shadow: 0 3px 8px rgba(15, 23, 42, 0.25);
        transition: transform 0.15s ease;
    }

    .mobile-nav-menu-btn:active .mobile-nav-icon-circle {
        transform: scale(0.92);
    }

    /* فاصله فوتر از پایین صفحه */
    .page-body {
        padding: 16px 12px 75px 12px !important;
    }

    .app-footer {
        padding: 16px 14px 20px 14px;
        font-size: 11px;
        margin-bottom: 56px;
    }

    /* بهینه‌سازی کارت‌ها، فرم‌ها و جداول در موبایل */
    .card-box {
        padding: 16px 14px !important;
        margin-bottom: 14px !important;
        border-radius: var(--radius-md) !important;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 14px;
    }

    .card-header-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
}