/* ==========================================================================
   سند برو (Sanad Pro) - نظام إدارة مراكز التخاطب والتأهيل
   Executive Healthcare SaaS Design System
   ========================================================================== */

:root {
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-light: #e0f2fe;
  --accent: #10b981;
  --accent-dark: #059669;
  --bg-app: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-family: "Segoe UI", "Cairo", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* App Layout Grid */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  width: 290px;
  background: #0f172a;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #1e293b;
}

.brand-logo {
  font-size: 32px;
  line-height: 1;
}

.brand-info h2 {
  font-size: 20px;
  font-weight: 900;
  color: #38bdf8;
  letter-spacing: -0.5px;
}

.brand-info span {
  font-size: 13px;
  color: #94a3b8;
  display: block;
  font-weight: 600;
}

.sidebar-menu {
  flex: 1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #cbd5e1;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: right;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item:hover {
  background: #1e293b;
  color: #ffffff;
}

.nav-item.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.nav-icon {
  font-size: 20px;
}

.nav-badge {
  margin-right: auto;
  background: #334155;
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.nav-badge.alert {
  background: #ef4444;
  color: #fff;
}

.menu-divider {
  height: 1px;
  background: #1e293b;
  margin: 10px 0;
}

.nav-item.highlight-aac {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  margin-top: 10px;
  border: 1px solid #34d399;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.nav-item.highlight-aac:hover {
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
  transform: translateY(-2px);
}

.nav-double-text {
  display: flex;
  flex-direction: column;
}

.nav-double-text small {
  font-size: 11px;
  color: #d1fae5;
  font-weight: 600;
}

.external-tag {
  margin-right: auto;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
}

.sidebar-footer {
  padding: 16px 20px;
  background: #090d16;
  border-top: 1px solid #1e293b;
}

.center-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.center-name {
  font-size: 13px;
  font-weight: 800;
  color: #e2e8f0;
}

.system-ver {
  font-size: 11px;
  color: #64748b;
}

/* ==========================================================================
   MAIN CONTENT & TOPBAR
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow-sm);
}

.header-search {
  position: relative;
  width: auto;
  flex: 1 1 200px;
  max-width: 340px;
}

.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.header-search input {
  width: 100%;
  padding: 10px 42px 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}

.header-search input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* License Pill */
.license-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.license-pill.trial {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.license-pill.active-license {
  background: #d1fae5;
  border-color: #a7f3d0;
  color: #065f46;
}

.license-pill.expired {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.license-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.btn-license-act {
  background: #0284c7;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.btn-license-act:hover {
  background: #0369a1;
}

/* License Modal Card */
.license-info-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lic-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.lic-row span {
  color: var(--text-muted);
  font-weight: 700;
}

.hwid-row {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

.hwid-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hwid-box code {
  background: #1e293b;
  color: #38bdf8;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
}

.live-clock {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--accent);
  color: #ffffff;
}

.btn-success:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  background: #475569;
  color: #ffffff;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text-main);
}

.btn-whatsapp {
  background: #25d366;
  color: #ffffff;
  border: none;
}

.btn-whatsapp:hover {
  background: #20ba5a;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.btn-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   CONTENT BODY & PANELS
   ========================================================================== */
.content-body {
  padding: 28px;
  flex: 1;
}

.view-panel {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
}

.panel-title {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-main);
}

.panel-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

.date-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
}

/* ==========================================================================
   KPI CARDS
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.kpi-card.blue .kpi-icon { background: #e0f2fe; }
.kpi-card.green .kpi-icon { background: #d1fae5; }
.kpi-card.purple .kpi-icon { background: #f3e8ff; }
.kpi-card.amber .kpi-icon { background: #fef3c7; }

.kpi-details {
  display: flex;
  flex-direction: column;
}

.kpi-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 900;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 2px;
}

/* ==========================================================================
   CARDS & TABLES
   ========================================================================== */
.dashboard-split {
  display: flex;
  gap: 20px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.card-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.box-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.box-title h3 {
  font-size: 18px;
  font-weight: 900;
}

.dot-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
}

.dot-indicator.pulse {
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}

.data-table tr:hover td {
  background: rgba(2, 132, 199, 0.02);
}

/* Status Badges */
.badge-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge-status.completed {
  background: #d1fae5;
  color: #065f46;
}

.badge-status.scheduled {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-status.ongoing {
  background: #fee2e2;
  color: #991b1b;
  animation: pulseDot 1.2s infinite;
}

.badge-status.cancelled {
  background: #f1f5f9;
  color: #64748b;
}

.badge-diag {
  background: rgba(2, 132, 199, 0.1);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  display: inline-block;
}

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  background: #e2e8f0;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-bar-fill {
  height: 100%;
  background: #10b981;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Filter Bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.filter-item select, .filter-item input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
}

.filter-item.search-grow {
  flex: 1;
  min-width: 200px;
}

.filter-item.search-grow input {
  width: 100%;
}

/* ==========================================================================
   DIAGNOSTICS & QUICK CALLOUT
   ========================================================================== */
.diagnostics-chart-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.diag-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.diag-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
}

.quick-callout {
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
}

.quick-callout h4 {
  font-size: 14px;
  font-weight: 800;
  color: #1d4ed8;
  margin-bottom: 6px;
}

.quick-callout p {
  font-size: 13px;
  color: #1e3a8a;
  line-height: 1.5;
}

/* ==========================================================================
   THERAPISTS GRID
   ========================================================================== */
.therapists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
}

.therapist-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.therapist-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.therapist-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #e0f2fe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.therapist-info h3 {
  font-size: 17px;
  font-weight: 900;
}

.therapist-info span {
  font-size: 13px;
  color: var(--text-muted);
}

.therapist-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  background: var(--surface-alt);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.th-stat {
  display: flex;
  flex-direction: column;
}

.th-stat span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.th-stat strong {
  font-size: 18px;
  color: var(--text-main);
}

/* ==========================================================================
   FINANCIALS & INVOICES
   ========================================================================== */
.financial-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.fin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 6px solid #10b981;
}

.fin-card.alert {
  border-right-color: #ef4444;
}

.fin-card.info {
  border-right-color: #0284c7;
}

.fin-card span {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 700;
}

.fin-card strong {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-main);
}

/* ==========================================================================
   IEP REPORTS SECTION
   ========================================================================== */
.iep-selector-row {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.form-select {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-main);
  min-width: 280px;
  outline: none;
}

.iep-display-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  padding: 30px;
}

.iep-goal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.iep-goal-item:last-child {
  border-bottom: none;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: modalScale 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 19px;
  font-weight: 900;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

.form-group input, .form-group select, .form-group textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.session-note-header-info {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  font-size: 13px;
}

/* ==========================================================================
   PRINT STYLES FOR A4 OFFICIAL INVOICES AND IEP REPORTS
   ========================================================================== */
.print-only {
  display: none;
}

@media print {
  body * {
    visibility: hidden;
  }
  .print-only, .print-only * {
    visibility: visible;
  }
  .print-only {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 30px;
    background: #fff;
    color: #000;
  }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 992px) {
  .dashboard-split { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { width: 80px; }
  .sidebar-brand .brand-info, .sidebar .nav-text, .sidebar-footer, .nav-badge { display: none; }
  .nav-item { justify-content: center; padding: 14px; }
  .top-bar { padding: 12px 18px; }
  .header-search { width: auto; flex: 1; }
}

@media (max-width: 640px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar-menu { flex-direction: row; overflow-x: auto; padding: 10px; }
  .content-body { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .header-actions { flex-wrap: wrap; }
}
