/**
 * EDUFORMIUM TIMETABLE GENERATOR
 * Design System — matched to Eduformium SMS color palette
 */

:root {
  /* ── Brand ── */
  --color-primary:        #1a3a6b;   /* navy  */
  --color-primary-dark:   #142e58;
  --color-primary-light:  #2d5a9e;
  --color-primary-faint:  rgba(26,58,107,.07);

  --color-teal:           #0d9488;   /* teal accent */
  --color-teal-dark:      #0a7a70;
  --color-teal-faint:     rgba(13,148,136,.07);

  /* ── Backgrounds ── */
  --color-bg:             #ffffff;
  --color-white:          #ffffff;
  --color-surface:        #ffffff;
  --color-surface-2:      #edf1f7;
  --color-surface-light:  #f1f5f9;

  /* ── Borders ── */
  --color-border:         #e2e8f0;
  --color-border-light:   #f1f5f9;
  --color-divider:        #cbd5e1;

  /* ── Text ── */
  --color-text:           #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted:     #94a3b8;
  --color-text-inverse:   #ffffff;

  /* ── Status ── */
  --color-success:        #16a34a;
  --color-success-light:  #dcfce7;
  --color-warning:        #d97706;
  --color-warning-light:  #fef3c7;
  --color-error:          #dc2626;
  --color-error-light:    #fee2e2;
  --color-info:           #1a3a6b;
  --color-info-light:     rgba(26,58,107,.08);

  /* ── Typography ── */
  --font-family:   Inter, system-ui, -apple-system, sans-serif;
  --text-xs:       11px;
  --text-sm:       12px;
  --text-base:     14px;
  --text-lg:       15px;
  --text-xl:       17px;
  --text-2xl:      20px;
  --text-3xl:      24px;
  --text-4xl:      30px;
  --font-normal:   400;
  --font-medium:   500;
  --font-semibold: 600;
  --font-bold:     700;
  --line-height-tight:  1.25;
  --line-height-base:   1.5;

  /* ── Spacing ── */
  --space-1:  4px;  --space-2:  8px;  --space-3: 12px;
  --space-4: 16px;  --space-5: 20px;  --space-6: 24px;
  --space-8: 32px;  --space-10:40px;  --space-12:48px;
  --space-16:64px;  --space-20:80px;

  /* ── Radius ── */
  --radius-sm:  7px;
  --radius-md:  10px;
  --radius-lg:  12px;
  --radius-xl:  14px;
  --radius-2xl: 18px;
  --radius-full:9999px;

  /* ── Shadows — soft only ── */
  --shadow-none: none;
  --shadow-xs:   0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(26,58,107,.03);
  --shadow-sm:   0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(26,58,107,.04);
  --shadow-base: 0 4px 14px rgba(0,0,0,.06), 0 2px 6px rgba(26,58,107,.04);
  --shadow-md:   0 4px 14px rgba(0,0,0,.08), 0 2px 6px rgba(26,58,107,.06);
  --shadow-lg:   0 8px 24px rgba(0,0,0,.08), 0 4px 12px rgba(26,58,107,.06);

  /* ── Transitions ── */
  --transition-fast: 150ms ease;
  --transition-base: 220ms ease;
  --transition-slow: 380ms ease;

  /* ── Z-index ── */
  --z-dropdown:     100;
  --z-sticky:       200;
  --z-fixed:        300;
  --z-modal-overlay:400;
  --z-modal:        500;
  --z-notification: 700;
}

/* ══ RESET ══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-bg);
}

h1,h2,h3,h4,h5,h6 { font-weight: var(--font-semibold); line-height: var(--line-height-tight); color: var(--color-text); }
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl);  }

a { color: var(--color-teal); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-teal-dark); text-decoration: underline; }

/* ── Inputs ── */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
textarea, select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  font-family: var(--font-family);
  font-size: var(--text-base);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,.1);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

/* ── Buttons ── */
button, .btn {
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1.4;
}
.btn-primary  { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-teal     { background: var(--color-teal); color: #fff; }
.btn-teal:hover { background: var(--color-teal-dark); }
.btn-secondary{ background: var(--color-white); color: var(--color-primary); border: 1.5px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-surface-2); border-color: var(--color-primary); }
.btn-ghost    { background: transparent; color: var(--color-text-secondary); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-primary); }
.btn-danger   { background: var(--color-error); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-success  { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-sm   { padding: 6px 12px; font-size: var(--text-sm); }
.btn-lg   { padding: 12px 22px; font-size: var(--text-lg); }
.btn-block{ width: 100%; }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── Cards ── */
.card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; transition: border-color var(--transition-fast); }
.card:hover { border-color: rgba(13,148,136,.35); }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.card-title  { font-size: var(--text-base); font-weight: var(--font-semibold); margin: 0; }
.card-body   { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--color-border); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); white-space: nowrap; }
.badge-success { background: var(--color-success-light); color: #14532d; }
.badge-warning { background: var(--color-warning-light); color: #92400e; }
.badge-error   { background: var(--color-error-light);   color: #991b1b; }
.badge-info    { background: var(--color-info-light);    color: var(--color-primary); }
.badge-primary { background: var(--color-primary-faint); color: var(--color-primary); }
.badge-teal    { background: var(--color-teal-faint);    color: var(--color-teal-dark); }

/* ── Stat Cards ── */
.stat-card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; align-items: center; gap: 14px; }
.stat-icon  { width: 42px; height: 42px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.stat-blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon.stat-green  { background: #f0fdf4; color: #16a34a; }
.stat-icon.stat-amber  { background: #fffbeb; color: #d97706; }
.stat-icon.stat-purple { background: #fdf4ff; color: #a855f7; }
.stat-icon.stat-teal   { background: rgba(13,148,136,.08); color: #0d9488; }
.stat-icon.stat-navy   { background: rgba(26,58,107,.08); color: #1a3a6b; }
.stat-info  { display: flex; flex-direction: column; }
.stat-value { font-size: var(--text-3xl); font-weight: var(--font-bold); color: var(--color-text); line-height: 1; }
.stat-label { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 4px; }

/* ── Page Header ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-title   { font-size: var(--text-3xl); font-weight: var(--font-bold); margin: 0; color: var(--color-text); }
.page-subtitle{ font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 4px; }

/* ── Forms ── */
.form-group  { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-label  { font-size: var(--text-xs); font-weight: var(--font-bold); color: var(--color-text-secondary); text-transform: uppercase; letter-spacing: .05em; }
.form-helper { font-size: var(--text-xs); color: var(--color-text-muted); }
.form-error  { font-size: var(--text-xs); color: var(--color-error); }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(7,24,48,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--z-modal-overlay); padding: 16px;
  animation: fadeIn .15s ease-out;
}
.modal {
  background: var(--color-white);
  border-radius: var(--radius-2xl);
  max-width: 520px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  border: 1px solid var(--color-border);
  animation: slideUp .2s ease-out;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--color-border); }
.modal-title  { font-size: var(--text-xl); font-weight: var(--font-bold); margin: 0; }
.modal-close  { width: 28px; height: 28px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: transparent; border: none; cursor: pointer; color: var(--color-text-muted); font-size: 15px; transition: all var(--transition-fast); }
.modal-close:hover { background: var(--color-error-light); color: var(--color-error); }
.modal-body   { padding: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--color-border); }

/* ── Notifications ── */
.notification { padding: 12px 16px; border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-white); font-size: var(--text-sm); font-weight: var(--font-medium); pointer-events: auto; animation: slideInRight .25s ease-out; min-width: 240px; max-width: 340px; }
.notification-success { background:#f0fdf4; border-color:#86efac; color:#14532d; }
.notification-error   { background:#fef2f2; border-color:#fecaca; color:#991b1b; }
.notification-warning { background:#fffbeb; border-color:#fcd34d; color:#92400e; }
.notification-info    { background:#eff6ff; border-color:#bfdbfe; color:#1e40af; }

/* ── Empty State ── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 32px; text-align: center; gap: 14px; }
.empty-state svg { color: var(--color-text-muted); width: 40px; height: 40px; }
.empty-state h3  { font-size: var(--text-xl); font-weight: var(--font-semibold); color: var(--color-text); }
.empty-state p   { font-size: var(--text-base); color: var(--color-text-muted); max-width: 340px; }

/* ── Timetable ── */
.timetable { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.timetable thead   { background: var(--color-surface-2); position: sticky; top: 0; z-index: 10; }
.timetable th      { padding: 10px 14px; text-align: center; font-weight: var(--font-semibold); border-right: 1px solid var(--color-border); min-width: 130px; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-secondary); }
.timetable th:first-child { position: sticky; left: 0; background: var(--color-surface-2); z-index: 11; text-align: left; }
.timetable td      { padding: 8px 10px; border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); min-width: 130px; text-align: center; vertical-align: top; }
.timetable td:first-child { position: sticky; left: 0; background: var(--color-white); font-weight: var(--font-semibold); font-size: var(--text-xs); white-space: nowrap; border-right: 2px solid var(--color-border); text-align: left; color: var(--color-text-secondary); }
.timetable tbody tr:hover { background: var(--color-primary-faint); }

/* ── Stats Grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }

/* ── Sidebar section labels ── */
.app-sidebar-section-label { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--color-text-muted); padding: 16px 12px 5px; pointer-events: none; user-select: none; }

/* ── Dropdown ── */
.dropdown-menu { position: absolute; top: 100%; left: 0; min-width: 200px; background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius-lg); z-index: var(--z-dropdown); margin-top: 4px; }
.dropdown-item { display: block; padding: 9px 14px; font-size: var(--text-sm); color: var(--color-text); cursor: pointer; transition: background var(--transition-fast); }
.dropdown-item:hover { background: var(--color-teal-faint); color: var(--color-teal); }

/* ── Animations ── */
@keyframes fadeIn       { from{opacity:0}                           to{opacity:1} }
@keyframes slideUp      { from{transform:translateY(12px);opacity:0} to{transform:none;opacity:1} }
@keyframes slideInRight { from{transform:translateX(20px);opacity:0} to{transform:none;opacity:1} }
@keyframes spin         { to{transform:rotate(360deg)} }

/* ── Skeleton ── */
.skeleton { background:linear-gradient(90deg,var(--color-surface-2) 25%,#e8edf4 50%,var(--color-surface-2) 75%); background-size:200% 100%; animation:shimmer 1.4s infinite; border-radius:var(--radius-sm); }
@keyframes shimmer { to{background-position:-200% 0} }

/* ── Scrollbar ── */
::-webkit-scrollbar       { width:5px; height:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--color-border); border-radius:99px; }
::-webkit-scrollbar-thumb:hover { background:var(--color-teal); }
::selection { background: var(--color-teal); color:#fff; }

/* ══ DARK MODE ═══════════════════════════════════════════ */
[data-theme="dark"] {
  --color-bg:            #0f172a;
  --color-white:         #1e293b;
  --color-surface:       #1e293b;
  --color-surface-2:     #162032;
  --color-surface-light: #263548;
  --color-border:        #2d3f55;
  --color-border-light:  #1e293b;
  --color-text:          #f1f5f9;
  --color-text-secondary:#94a3b8;
  --color-text-muted:    #64748b;
  --color-primary-faint: rgba(26,58,107,.2);
  --color-teal-faint:    rgba(13,148,136,.12);
}
[data-theme="dark"] input[type="text"], [data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"], [data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea, [data-theme="dark"] select {
  background:#263548; color:#f1f5f9; border-color:#2d3f55;
}

/* ══ PRINT ═══════════════════════════════════════════════ */
@media print {
  body{background:#fff;font-size:11px}
  .app-header,.app-sidebar,.btn,nav{display:none!important}
  .app-main{margin:0!important;padding:8px!important}
  td,th{border:1px solid #ccc!important}
}

/* ══ RESPONSIVE ═══════════════════════════════════════════ */
@media(max-width:768px){
  .app-sidebar{display:none}
  .app-main{margin-left:0!important}
  .form-row{grid-template-columns:1fr}
  .stats-grid{grid-template-columns:1fr 1fr}
  .page-header{flex-direction:column;align-items:flex-start}
}
@media(max-width:480px){
  .stats-grid{grid-template-columns:1fr}
  .modal{width:95%}
}