/* ========================================================
   Academy CRM - Modern Stripe/Linear Clean Light Design
   100% Offline / Local Assets & RTL First
   ======================================================== */

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: block;
}

:root {
    color-scheme: light;

    /* Brand Colors - Electric Indigo */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-glow: rgba(79, 70, 229, 0.15);

    /* Accents */
    --secondary: #0ea5e9;
    --secondary-light: #f0f9ff;
    --success: #10b981;
    --success-hover: #059669;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: #fef2f2;

    /* Light Theme Palette (Default) */
    --dark: #0f172a;
    --dark-muted: #334155;
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --card-header-bg: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --table-th-bg: #f8fafc;
    --table-hover-bg: #f8fafc;
    --input-bg: #ffffff;
    --modal-bg: #ffffff;
    --modal-header-bg: #ffffff;
    --modal-footer-bg: #f8fafc;
    --drawer-bg: #ffffff;
    --drawer-footer-bg: #f8fafc;

    /* Layout Dimensions */
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 74px;
    --header-h: 68px;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;

    /* Soft Multi-Layer Shadows (Linear / Stripe style) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    --shadow-drawer: -12px 0 35px -5px rgba(15, 23, 42, 0.18);

    /* Animation Easing */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================================
   Dark Theme Tokens (Linear Dark / Deep Space Style)
   ======================================================== */
html.dark-mode,
html.dark-mode body,
body.dark-mode {
    color-scheme: dark;
    --dark: #f8fafc;
    --dark-muted: #cbd5e1;
    --body-bg: #090d16;
    --card-bg: #111827;
    --card-header-bg: #161f32;
    --sidebar-bg: #070a12;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --border-color: #1e293b;
    --border-subtle: #162032;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --table-th-bg: #0d1322;
    --table-hover-bg: rgba(255, 255, 255, 0.03);
    --input-bg: #0d1322;
    --modal-bg: #111827;
    --modal-header-bg: #161f32;
    --modal-footer-bg: #0d1322;
    --drawer-bg: #111827;
    --drawer-footer-bg: #0d1322;

    --primary-light: rgba(99, 102, 241, 0.18);
    --secondary-light: rgba(14, 165, 233, 0.18);
    --success-light: rgba(16, 185, 129, 0.18);
    --warning-light: rgba(245, 158, 11, 0.18);
    --danger-light: rgba(239, 68, 68, 0.18);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-drawer: -12px 0 35px -5px rgba(0, 0, 0, 0.6);
}

html {
    background-color: var(--body-bg);
}

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

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

/* Theme transitioning helper: only animate colors when user explicitly clicks theme toggle */
body.theme-transitioning,
body.theme-transitioning *,
body.theme-transitioning *::before,
body.theme-transitioning *::after {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease !important;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

/* ------------------- Layout Structure ------------------- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ------------------- Modern Collapsible Sidebar ------------------- */
.sidebar {
    width: var(--sidebar-w);
    background: #0f172a;
    color: #94a3b8;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.06);
    transition: width 0.28s var(--ease-out);
    overflow: hidden;
}

.sidebar-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-header .logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.sidebar-header .logo-text {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    padding: 12px 14px 4px 14px;
    font-weight: 700;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    color: #94a3b8;
    font-weight: 500;
    font-size: 13.5px;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
    transition: transform 0.2s;
}

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

.nav-link:hover svg {
    transform: scale(1.08);
}

.nav-link.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.9) 0%, rgba(99, 102, 241, 0.8) 100%);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.5);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.sidebar-user-info .user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.sidebar-user-info .user-role {
    font-size: 11px;
    color: #64748b;
}

/* Collapsed Sidebar State */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-w);
}

body.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .logo-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .sidebar-user-info {
    opacity: 0;
    display: none;
}

body.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 12px 0;
}

body.sidebar-collapsed .sidebar-footer {
    justify-content: center;
    padding: 14px 0;
}

body.sidebar-collapsed .sidebar-footer a {
    display: none;
}

/* ------------------- Main Wrapper & Header ------------------- */
.main-wrapper {
    flex: 1;
    margin-right: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-right 0.28s var(--ease-out);
}

body.sidebar-collapsed .main-wrapper {
    margin-right: var(--sidebar-collapsed-w);
}

.top-header {
    height: var(--header-h);
    background-color: var(--card-bg);
    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;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.03);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-toggle-btn, .theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.sidebar-toggle-btn:hover, .theme-toggle-btn:hover {
    background: var(--border-subtle);
    color: var(--text-main);
    border-color: #94a3b8;
}

.sidebar-toggle-btn svg, .theme-toggle-btn svg {
    width: 18px;
    height: 18px;
}

/* Theme toggle sun & moon icons */
.theme-toggle-btn .sun-icon {
    display: none;
}
.theme-toggle-btn .moon-icon {
    display: block;
}
body.dark-mode .theme-toggle-btn .sun-icon {
    display: block;
    color: #facc15;
}
body.dark-mode .theme-toggle-btn .moon-icon {
    display: none;
}

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

.date-badge {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.main-content {
    flex: 1;
    padding: 28px 32px;
}

/* ------------------- Typography & Page Header ------------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ------------------- Modern Cards ------------------- */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, background-color 0.25s ease, border-color 0.25s ease;
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--card-header-bg);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

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

.card-body {
    padding: 24px;
}

/* ------------------- KPI Stat Cards Grid ------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), background-color 0.25s ease, border-color 0.25s ease;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.2s;
}

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

.stat-card:hover::after {
    background: var(--primary);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
}

.stat-icon.primary   { background: var(--primary-light); color: var(--primary); }
.stat-icon.success   { background: var(--success-light); color: var(--success); }
.stat-icon.warning   { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger    { background: var(--danger-light); color: var(--danger); }
.stat-icon.secondary { background: var(--secondary-light); color: var(--secondary); }

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

.stat-data .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 4px;
    letter-spacing: -0.5px;
}

.stat-data .stat-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 3px;
}

/* ------------------- Buttons ------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
    line-height: 1.4;
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-success {
    background-color: var(--success);
    color: white;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}
.btn-success:hover {
    background-color: var(--success-hover);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover {
    background-color: var(--danger-hover);
    color: white;
}

.btn-secondary {
    background-color: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    background-color: var(--border-subtle);
    color: var(--text-main);
    border-color: #94a3b8;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ------------------- Tables ------------------- */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
    font-size: 13px;
}

.table th {
    background-color: var(--table-th-bg);
    color: var(--text-muted);
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    letter-spacing: -0.2px;
}

body.dark-mode .table th {
    color: #cbd5e1;
}

.table td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.table a {
    color: var(--text-main);
    font-weight: 600;
}
.table a:hover {
    color: var(--primary);
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background-color: var(--table-hover-bg);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-start;
}

/* ------------------- Compact Action Icon Buttons ------------------- */
.action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-muted);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    padding: 0;
    flex-shrink: 0;
    line-height: 1;
}

.action-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.action-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background-color: var(--primary-light);
    transform: translateY(-1px);
}

.action-btn.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
    background-color: var(--danger-light);
    transform: translateY(-1px);
}

.action-btn.success:hover {
    color: var(--success);
    border-color: var(--success);
    background-color: var(--success-light);
    transform: translateY(-1px);
}

/* Card Table Header with Integrated Filters */
.card-table-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    background-color: var(--card-header-bg);
}

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

.table-filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0;
}

.table-filter-form .form-control,
.table-filter-form .form-select {
    padding: 6px 12px;
    height: 36px;
    font-size: 12.5px;
}

/* ------------------- Badges ------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success   { background: var(--success-light); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-danger    { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-warning   { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-info      { background: var(--secondary-light); color: var(--secondary); border: 1px solid rgba(14, 165, 233, 0.3); }
.badge-secondary { background: var(--border-subtle); color: var(--text-muted); border: 1px solid var(--border-color); }

/* ------------------- Forms & Filter Bar ------------------- */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-main);
}

.form-label.required::after {
    content: " *";
    color: var(--danger);
}

.form-control, .form-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    font-family: inherit;
    font-size: 13px;
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.25s ease;
    outline: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

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

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.filter-bar .search-input {
    flex: 1;
    min-width: 220px;
}

/* ------------------- Alerts ------------------- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-sm);
}

.alert-success { background-color: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background-color: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background-color: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background-color: var(--secondary-light); color: #075985; border: 1px solid #bae6fd; }

/* ========================================================
   Centered Floating Modals (مودال‌های متمرکز، شناور و شیک)
   ======================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    position: relative;
    width: 100%;
    max-width: 660px;
    max-height: 92vh;
    background: var(--modal-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96) translateY(-10px);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease, background-color 0.25s ease;
}

.modal-container.modal-lg {
    max-width: 780px;
}

.modal-overlay.active .modal-container {
    transform: scale(1) translateY(0);
}

.modal-container form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin: 0;
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background-color: var(--modal-header-bg);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--border-subtle);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    line-height: 1;
}

.modal-close:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

.modal-body {
    padding: 20px 24px 24px 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    background: var(--modal-bg);
}

.modal-body .form-group {
    margin-bottom: 14px;
}

.modal-body .form-control,
.modal-body .form-select {
    padding: 8px 12px;
    font-size: 13px;
}

.modal-body .form-label {
    margin-bottom: 5px;
    font-size: 12.5px;
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: var(--border-subtle);
}
.modal-body::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background-color: var(--modal-footer-bg);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* ------------------- Progress Bar ------------------- */
.progress-bar-wrapper {
    background-color: var(--border-color);
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.progress-bar-fill.safe   { background: linear-gradient(90deg, #10b981, #34d399); }
.progress-bar-fill.medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-bar-fill.danger { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ------------------- Datepicker Dark Mode Compatibility ------------------- */
body.dark-mode .pwt-datepicker-container {
    background-color: #111827 !important;
    border: 1px solid #1f293d !important;
    color: #f1f5f9 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
}
body.dark-mode .pwt-datepicker-container .pwt-datepicker-header {
    background-color: #0b0f19 !important;
    border-bottom: 1px solid #1f293d !important;
}
body.dark-mode .pwt-datepicker-container .pwt-datepicker-header-view,
body.dark-mode .pwt-datepicker-container .pwt-btn {
    color: #f1f5f9 !important;
}
body.dark-mode .pwt-datepicker-container .pwt-day {
    color: #cbd5e1 !important;
}
body.dark-mode .pwt-datepicker-container .pwt-day:hover {
    background-color: #1f293d !important;
    color: #ffffff !important;
}
body.dark-mode .pwt-datepicker-container .pwt-day.selected {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

/* ------------------- Print Styles ------------------- */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    .sidebar, .top-header, .btn, .filter-bar, .modal-overlay, .no-print {
        display: none !important;
    }
    .main-wrapper {
        margin-right: 0 !important;
    }
    .main-content {
        padding: 0 !important;
    }
    .card {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }
    .table th, .table td {
        border-color: #000 !important;
        color: #000 !important;
    }
}

/* ------------------- Responsive ------------------- */
@media (max-width: 992px) {
    .sidebar {
        right: -260px;
    }
    .sidebar.open {
        right: 0;
    }
    .main-wrapper {
        margin-right: 0 !important;
    }
    .sidebar-toggle-btn {
        display: flex !important;
    }
    .modal-container {
        max-width: 100% !important;
        border-radius: 0;
    }
}

/* ------------------- Top Navigation Progress Bar ------------------- */
#crmProgressBar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #38bdf8, #818cf8);
    z-index: 99999;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.2s ease, opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
}
#crmProgressBar.active {
    opacity: 1;
    transform: scaleX(0.7);
}
#crmProgressBar.done {
    transform: scaleX(1);
    opacity: 0;
}
