/* ── CSS Variables ── */
:root {
  --primary:        #1a56db;
  --primary-dark:   #1245b5;
  --primary-light:  #e8f0fe;
  --secondary:      #6c757d;
  --success:        #0e9f6e;
  --danger:         #f05252;
  --warning:        #ff9800;
  --info:           #0ea5e9;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --surface-3:      #f1f5f9;
  --border:         #e2e8f0;
  --border-dark:    #cbd5e1;
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:      0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.12);
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-xl:      24px;
  --sidebar-w:      260px;
  --navbar-h:       64px;
  --transition:     all .2s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-3); }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--secondary); }

/* ── Vazirmatn Font Faces ── */
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn/Vazirmatn-Thin.woff2') format('woff2'); font-weight: 100; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn/Vazirmatn-ExtraLight.woff2') format('woff2'); font-weight: 200; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn/Vazirmatn-Light.woff2') format('woff2'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn/Vazirmatn-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn/Vazirmatn-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn/Vazirmatn-ExtraBold.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn/Vazirmatn-Black.woff2') format('woff2'); font-weight: 900; font-display: swap; }

.bi { vertical-align: -.125em; }

/* ── Dashboard Navbar ── */
.icon-container { display: flex; align-items: center; gap: 0.5rem; }
.user-avatar { width: 40px; height: 40px; background: var(--primary-light); color: var(--primary); border-radius: 50%; line-height: 1; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }

.main-navbar { height: var(--navbar-h); background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); position: fixed; top: 0; right: 0; left: 0; z-index: 1040; display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem; }
.navbar-brand { font-size: 1.25rem; font-weight: 800; color: var(--primary) !important; text-decoration: none; display: flex; align-items: center; gap: .5rem; letter-spacing: -.5px; }
.navbar-brand .brand-icon { width: 36px; height: 36px; background: var(--primary); border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 1.1rem; }
.navbar-brand .brand-icon .bi { line-height: 0; vertical-align: baseline; }
.navbar-toggler-custom { background: none; border: none; font-size: 1.4rem; color: var(--text-secondary); cursor: pointer; padding: .25rem .5rem; border-radius: var(--radius-sm); transition: var(--transition); }
.navbar-toggler-custom:hover { background: var(--surface-3); color: var(--primary); }
.navbar-user { margin-right: auto; display: flex; align-items: center; gap: .75rem; }

/* ── Sidebar ── */
.sidebar { position: fixed; top: var(--navbar-h); right: 0; width: var(--sidebar-w); height: calc(100vh - var(--navbar-h)); background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; overflow-x: hidden; z-index: 1030; transition: transform .3s cubic-bezier(.4,0,.2,1); padding: 1.5rem 0 2rem; display: flex; flex-direction: column; }
.sidebar-hidden { transform: translateX(100%); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1025; backdrop-filter: blur(2px); }
.sidebar-overlay.show { display: block; }
.sidebar-section { padding: 0 1rem; margin-bottom: 1.5rem; }
.sidebar-section-title { font-size: .7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; padding: 0 .75rem; margin-bottom: .5rem; }
.sidebar-link { display: flex; align-items: center; gap: .75rem; padding: .625rem .75rem; border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; font-size: .9rem; font-weight: 500; transition: var(--transition); margin-bottom: 2px; position: relative; }
.sidebar-link i { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-link:hover { background: var(--surface-3); color: var(--primary); }
.sidebar-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-link.active::before { content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 70%; background: var(--primary); border-radius: 2px 0 0 2px; }
.sidebar-badge { margin-right: auto; font-size: .7rem; padding: .15rem .5rem; border-radius: 20px; }

/* ── Main Content ── */
.main-content { margin-top: var(--navbar-h); margin-right: var(--sidebar-w); min-height: calc(100vh - var(--navbar-h)); padding: 2rem; transition: margin-right .3s cubic-bezier(.4,0,.2,1); }

/* ── Page Header ── */
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.page-header p { color: var(--text-secondary); margin: .25rem 0 0; font-size: .9rem; }
.page-breadcrumb { font-size: .82rem; color: var(--text-muted); margin-bottom: .5rem; }
.page-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.page-breadcrumb a:hover { color: var(--primary); }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); transition: var(--transition); }
.card-header { background: none; border-bottom: 1px solid var(--border); padding: 1.25rem 1.5rem; font-weight: 600; font-size: 1rem; }
.card-body { padding: 1.5rem; }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* ── Stat Cards ── */
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; display: flex; align-items: center; gap: 1rem; transition: var(--transition); }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon { width: 52px; height: 52px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon .bi { line-height: 0; vertical-align: baseline; }
.stat-icon.blue   { background: #eff6ff; color: #2563eb; }
.stat-icon.green  { background: #f0fdf4; color: #16a34a; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-icon.red    { background: #fef2f2; color: #dc2626; }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; color: var(--text-primary); }
.stat-label { font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Buttons ── */
.btn { font-family: 'Vazirmatn', 'DejaVu Sans', sans-serif; font-weight: 600; border-radius: var(--radius-sm); transition: var(--transition); display: inline-flex; align-items: center; gap: .4rem; }
.btn .bi { line-height: 0; vertical-align: baseline; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,86,219,.3); }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger  { background: var(--danger);  border-color: var(--danger);  }
.btn-ghost { background: transparent; border: none; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-3); color: var(--primary); }

/* ── Forms ── */
.form-control, .form-select { font-family: 'Vazirmatn', 'DejaVu Sans', sans-serif; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: .625rem 1rem; color: var(--text-primary); background: var(--surface); transition: var(--transition); font-size: .9rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); outline: none; }
.form-label { font-weight: 600; font-size: .85rem; color: var(--text-secondary); margin-bottom: .4rem; }
.form-text { font-size: .78rem; color: var(--text-muted); }
.form-check-input { border-color: var(--border-dark); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

/* ── Form Sections ── */
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 1.5rem; overflow: hidden; }
.form-section-header { background: var(--surface-3); border-bottom: 1px solid var(--border); padding: 1rem 1.5rem; display: flex; align-items: center; gap: .75rem; cursor: pointer; user-select: none; }
.form-section-header h5 { margin: 0; font-size: .95rem; font-weight: 700; color: var(--text-primary); }
.form-section-header .section-icon { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.form-section-body { padding: 1.5rem; }
.form-section-toggle { margin-right: auto; transition: transform .3s; }
.form-section-header.collapsed .form-section-toggle { transform: rotate(180deg); }

/* ── Checkbox Grid ── */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.checkbox-item { display: flex; align-items: flex-start; gap: .5rem; padding: .5rem .75rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); background: var(--surface); }
.checkbox-item:hover { border-color: var(--primary); background: var(--primary-light); }
.checkbox-item input[type="checkbox"] { margin-top: .2rem; flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; }
.checkbox-item input[type="checkbox"]:checked ~ .checkbox-label { color: var(--primary); font-weight: 600; }
.checkbox-item:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.checkbox-label { font-size: .83rem; line-height: 1.4; color: var(--text-secondary); }

/* ── Tables ── */
.table-wrapper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.table { margin: 0; font-size: .875rem; }
.table th { background: var(--surface-3); border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; padding: 1rem 1.25rem; white-space: nowrap; }
.table td { padding: .875rem 1.25rem; vertical-align: middle; border-bottom: 1px solid var(--border); color: var(--text-primary); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

/* ── Badges ── */
.badge { font-family: 'Vazirmatn', 'DejaVu Sans', sans-serif; font-weight: 600; font-size: .72rem; border-radius: 20px; padding: .3rem .7rem; }
.badge-pending  { background: #fff7ed; color: #ea580c; }
.badge-verified { background: #f0fdf4; color: #16a34a; }
.badge-rejected { background: #fef2f2; color: #dc2626; }
.badge-draft    { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }
.badge-submitted { background: #eff6ff; color: #2563eb; }

/* ── Alerts ── */
.alert { border: none; border-radius: var(--radius-md); font-size: .875rem; padding: 1rem 1.25rem; }
.alert-primary { background: var(--primary-light); color: var(--primary-dark); }
.alert-success  { background: #f0fdf4; color: #14532d; }
.alert-danger   { background: #fef2f2; color: #7f1d1d; }
.alert-warning  { background: #fffbeb; color: #78350f; }
.alert-info     { background: #f0f9ff; color: #075985; }

/* ── Messages Container ── */
.messages-container { position: fixed; top: calc(var(--navbar-h) + 1rem); left: 1.5rem; right: 1.5rem; z-index: 1050; pointer-events: none; }
@media (min-width: 576px) { .messages-container { left: auto; right: 1.5rem; width: 380px; } }
.messages-container .alert { pointer-events: all; box-shadow: var(--shadow-md); animation: slideIn .3s ease; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to   { transform: translateX(0);   opacity: 1; } }

/* ── Auth Pages ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #f0f4ff 0%, #f8fafc 50%, #e8f5e9 100%); padding: 1.5rem; }
.auth-card { background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 2.5rem; width: 100%; max-width: 440px; }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo .logo-icon { width: 64px; height: 64px; background: var(--primary); border-radius: var(--radius-md); display: inline-flex; align-items: center; justify-content: center; font-size: 1.8rem; color: #fff; margin-bottom: 1rem; box-shadow: 0 8px 24px rgba(26,86,219,.3); }
.auth-logo h2 { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); margin: 0; }
.auth-logo p { font-size: .85rem; color: var(--text-muted); margin: .25rem 0 0; }
.otp-input { font-size: 2rem !important; font-weight: 700 !important; letter-spacing: .5rem; text-align: center; border-radius: var(--radius-md) !important; border-width: 2px !important; padding: 1rem !important; }
.otp-timer { font-size: .85rem; color: var(--text-muted); text-align: center; }
.otp-timer .timer-count { font-weight: 700; color: var(--primary); }

/* ── Patient Header ── */
.patient-header { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; border-radius: var(--radius-lg); padding: 2rem; margin-bottom: 1.5rem; position: relative; overflow: hidden; }
.patient-header::before { content: ''; position: absolute; top: -40%; right: -10%; width: 250px; height: 250px; background: rgba(255,255,255,.06); border-radius: 50%; }
.patient-header::after { content: ''; position: absolute; bottom: -30%; left: 5%; width: 180px; height: 180px; background: rgba(255,255,255,.04); border-radius: 50%; }
.patient-avatar-large { width: 72px; height: 72px; background: rgba(255,255,255,.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 700; flex-shrink: 0; border: 3px solid rgba(255,255,255,.3); }
.patient-info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; margin-top: 1.25rem; }
.patient-info-item { background: rgba(255,255,255,.12); border-radius: var(--radius-sm); padding: .6rem 1rem; }
.patient-info-item label { font-size: .72rem; opacity: .75; display: block; margin-bottom: .1rem; }
.patient-info-item span { font-weight: 600; font-size: .9rem; }

/* ── Session Rows ── */
.session-row { display: flex; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); gap: 1rem; transition: var(--transition); }
.session-row:last-child { border-bottom: none; }
.session-row:hover { background: var(--surface-2); }
.session-num { width: 36px; height: 36px; background: var(--primary-light); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.session-type-badge { font-size: .72rem; padding: .2rem .6rem; border-radius: 20px; font-weight: 600; }
.session-type-long  { background: #faf5ff; color: #7c3aed; }
.session-type-short { background: #fff7ed; color: #ea580c; }

/* ── Wizard Steps ── */
.wizard-steps { display: flex; align-items: center; gap: 0; margin-bottom: 2rem; overflow-x: auto; padding-bottom: .5rem; }
.wizard-step { display: flex; align-items: center; flex-shrink: 0; }
.step-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; border: 2px solid var(--border); background: var(--surface); color: var(--text-muted); }
.step-dot.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.step-dot.done { background: var(--success); border-color: var(--success); color: #fff; }
.step-label { font-size: .78rem; margin-top: .25rem; color: var(--text-muted); text-align: center; }
.step-label.active { color: var(--primary); font-weight: 600; }
.step-label.done   { color: var(--success); }
.step-line { height: 2px; width: 40px; background: var(--border); flex-shrink: 0; }
.step-line.done { background: var(--success); }

/* ── Image Grid ── */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.image-item { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; border: 2px solid var(--border); }
.image-item img { width: 100%; height: 100%; object-fit: cover; }
.image-item .delete-btn { position: absolute; top: .25rem; left: .25rem; width: 24px; height: 24px; background: rgba(220,38,38,.9); color: #fff; border: none; border-radius: 50%; font-size: .75rem; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .2s; }
.image-item:hover .delete-btn { opacity: 1; }
.image-upload-zone { border: 2px dashed var(--border-dark); border-radius: var(--radius-md); padding: 2rem; text-align: center; cursor: pointer; transition: var(--transition); background: var(--surface-2); }
.image-upload-zone:hover, .image-upload-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }

/* ── Tag Input ── */
.tag-container { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); min-height: 44px; cursor: text; background: var(--surface); transition: var(--transition); }
.tag-container:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
.tag-item { background: var(--primary-light); color: var(--primary); border-radius: 20px; padding: .2rem .75rem; font-size: .8rem; font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.tag-item .remove-tag { cursor: pointer; font-size: .7rem; opacity: .7; }
.tag-item .remove-tag:hover { opacity: 1; }
.tag-input { border: none; outline: none; flex: 1; min-width: 120px; font-family: 'Vazirmatn', 'DejaVu Sans', sans-serif; font-size: .875rem; background: transparent; color: var(--text-primary); }
.autocomplete-dropdown { position: absolute; top: 100%; right: 0; left: 0; background: var(--surface); border: 1.5px solid var(--border); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); box-shadow: var(--shadow-md); z-index: 100; max-height: 200px; overflow-y: auto; }
.autocomplete-item { padding: .6rem 1rem; cursor: pointer; font-size: .875rem; transition: background .15s; }
.autocomplete-item:hover { background: var(--primary-light); color: var(--primary); }
.nc-check-feedback { font-size: .8rem; margin-top: .35rem; display: none; }

/* ── Responsive ── */
@media (max-width: 991.98px) {
  .main-content { margin-right: 0; padding: 1.25rem; }
  .sidebar { transform: translateX(100%); }
  .sidebar.show { transform: translateX(0); }
}
@media (max-width: 575.98px) {
  .auth-card { padding: 1.75rem 1.25rem; }
  .patient-header { padding: 1.25rem; }
  .main-content { padding: 1rem; }
  .card-body { padding: 1rem; }
  .form-section-body { padding: 1rem; }
  .checkbox-grid { grid-template-columns: 1fr; }
  .image-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}

/* ── Utility Classes ── */
.text-primary-custom { color: var(--primary) !important; }
.bg-surface-2 { background: var(--surface-2); }
.border-dashed { border-style: dashed !important; }
.rounded-custom { border-radius: var(--radius-md) !important; }
.shadow-custom { box-shadow: var(--shadow-md) !important; }
.gap-icon { gap: .4rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.fs-small { font-size: .85rem; }
.ltr { direction: ltr; }
.no-select { user-select: none; }
.opacity-50 { opacity: .5; }
