/* ============================================================
   EduTime – Style Sheet
   ============================================================ */

:root {
  --primary:       #3b82f6;
  --primary-dark:  #2563eb;
  --primary-light: #dbeafe;
  --secondary:     #8b5cf6;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --sidebar-bg:    #1e293b;
  --sidebar-text:  #94a3b8;
  --bg:            #f1f5f9;
  --card-bg:       #ffffff;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 25px -3px rgba(0,0,0,.15);
  --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  width: 230px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0; top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo { display: flex; align-items: center; gap: .6rem; }
.logo-icon { font-size: 1.4rem; }
.logo-text { font-size: 1.15rem; font-weight: 700; color: #fff; letter-spacing: -.3px; }

.sidebar-nav {
  padding: .75rem .6rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .9rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: .95rem; width: 1.3rem; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-version { font-size: .75rem; color: rgba(255,255,255,.3); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main-content {
  margin-left: 230px;
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-muted);
  margin-top: .25rem;
  font-size: .85rem;
}

/* ============================================================
   CARD
   ============================================================ */

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: .95rem; font-weight: 600; }

/* ============================================================
   STATS
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-muted); font-size: .8rem; margin-top: .2rem; }

/* ============================================================
   DASHBOARD
   ============================================================ */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
  transition: all .15s;
  text-align: left;
}
.quick-action-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.list-item:last-child { border-bottom: none; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font);
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-link { background: none; border: none; color: var(--primary); font-size: .8rem; cursor: pointer; padding: 0; font-family: var(--font); }

.icon-btn {
  width: 30px; height: 30px;
  border: none;
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  transition: background .15s;
}
.icon-btn:hover { background: var(--border); }
.icon-btn.danger:hover { background: #fef2f2; }

/* ============================================================
   ITEMS GRID (classes / teachers)
   ============================================================ */

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}

.item-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  transition: box-shadow .15s, transform .15s;
}
.item-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.item-card-header {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: .4rem;
}
.item-title { font-weight: 600; font-size: .95rem; flex: 1; min-width: 0; }
.item-actions { display: flex; gap: .2rem; margin-left: auto; flex-shrink: 0; }
.item-desc { font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }

.item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .75rem;
  padding-top: .65rem;
  border-top: 1px solid var(--border);
}

/* Teacher card */
.teacher-card { cursor: pointer; }

.teacher-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: .95rem;
  flex-shrink: 0;
}

.teacher-avatar-lg {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* ============================================================
   BADGE
   ============================================================ */

.badge {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 99px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .72rem;
  font-weight: 600;
}

.class-badge {
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
}

/* ============================================================
   SETTINGS
   ============================================================ */

.days-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1rem;
}

.day-toggle {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s;
  user-select: none;
}
.day-toggle input { display: none; }
.day-toggle:hover { border-color: var(--primary); color: var(--primary); }
.day-toggle.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

.settings-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* ============================================================
   FORMS
   ============================================================ */

.form-group { margin-bottom: .85rem; }

.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .55rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-group input:disabled,
.form-group select:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}
.form-group textarea { resize: vertical; min-height: 72px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   TIMETABLE
   ============================================================ */

.timetable-card { padding: 0; overflow: hidden; }

.class-selector-wrapper select {
  padding: .5rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font);
}
.class-selector-wrapper select:focus {
  outline: none;
  border-color: var(--primary);
}

.timetable-scroll { overflow-x: auto; }

.timetable {
  width: 100%;
  border-collapse: collapse;
  min-width: 550px;
}

.timetable thead th {
  background: var(--sidebar-bg);
  color: #fff;
  padding: .7rem .5rem;
  text-align: center;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
}

.time-col { width: 80px; }

.timetable td {
  border: 1px solid var(--border);
  vertical-align: middle;
  height: 52px;
}

.time-label {
  text-align: center;
  font-size: .72rem;
  color: var(--text-muted);
  padding: .3rem .4rem;
  background: #f8fafc;
  border-right: 2px solid var(--border);
  white-space: nowrap;
  line-height: 1.4;
}

.empty-slot {
  text-align: center;
  color: #d1d5db;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.empty-slot:hover {
  background: var(--primary-light) !important;
  color: var(--primary);
  font-size: 1.4rem;
}

.assignment-slot {
  cursor: pointer;
  transition: opacity .15s;
  padding: 4px 6px;
  vertical-align: top;
}
.assignment-slot:hover { opacity: .82; }

.slot-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.slot-content strong { font-size: .78rem; line-height: 1.2; }
.slot-content span   { font-size: .72rem; color: var(--text-muted); }

.time-badge { font-size: .68rem; color: var(--text-muted); }

/* Teacher schedule modal */
.teacher-schedule-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.teacher-schedule-header h2 { font-size: 1.1rem; font-weight: 700; }

.assignment-cell {
  padding: 4px 6px;
  vertical-align: top;
}
.assignment-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.assignment-content strong { font-size: .78rem; line-height: 1.2; }
.assignment-content span   { font-size: .72rem; color: var(--text-muted); }

/* ============================================================
   LEGEND
   ============================================================ */

.legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding: .65rem 1rem;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: .78rem;
}
.legend-title { font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.legend-item  { display: flex; align-items: center; gap: .3rem; }
.legend-dot   { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty-icon  { font-size: 2.8rem; margin-bottom: .75rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1rem; }
.empty-text  { color: var(--text-muted); font-size: .85rem; text-align: center; padding: 1rem; }

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
.modal-large { max-width: 860px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal-header h3 { font-size: .95rem; font-weight: 700; }

.modal-close {
  width: 30px; height: 30px;
  border: none;
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all .15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body { padding: 1.4rem; }

/* ============================================================
   CONFLICT WARNING / ALERT
   ============================================================ */

.conflict-warning {
  padding: .65rem .9rem;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  color: #92400e;
  font-size: .82rem;
  margin-bottom: .85rem;
}
.conflict-warning.hidden { display: none; }

.info-box {
  padding: .65rem .9rem;
  background: var(--primary-light);
  border: 1px solid #93c5fd;
  border-radius: var(--radius-sm);
  color: #1e40af;
  font-size: .82rem;
  margin-bottom: .85rem;
}

/* ============================================================
   ASSIGNMENT DETAIL
   ============================================================ */

.assignment-detail { display: flex; flex-direction: column; gap: .4rem; }
.detail-row {
  font-size: .875rem;
  padding: .45rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: .5rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row strong { color: var(--text-muted); min-width: 90px; flex-shrink: 0; }

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  padding: .75rem 1.25rem;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 2000;
  transform: translateY(80px);
  opacity: 0;
  transition: all .28s cubic-bezier(.34,1.56,.64,1);
  max-width: 320px;
}
.toast-visible { transform: translateY(0); opacity: 1; }
.toast-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.toast-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.toast-info    { background: var(--primary-light); color: #1e40af; border: 1px solid #93c5fd; }

/* ============================================================
   UTILITIES
   ============================================================ */

.text-muted { color: var(--text-muted); }
.hidden     { display: none !important; }
.mt-1       { margin-top: .5rem; }
.mt-2       { margin-top: 1rem; }

/* ============================================================
   RESPONSIVE (basic)
   ============================================================ */

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-row { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   EXPORT DROPDOWN
   ============================================================ */

.export-dropdown { position: relative; }

.export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 210px;
  z-index: 200;
  overflow: hidden;
  animation: menuIn .15s ease;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.export-menu button {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .6rem 1rem;
  border: none;
  background: none;
  text-align: left;
  font-size: .85rem;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
  transition: background .12s;
}
.export-menu button:hover { background: var(--bg); }
.export-menu button + button { border-top: 1px solid var(--border); }

/* ============================================================
   PRINT
   ============================================================ */

@media print {
  .sidebar, .page-header .btn, .export-dropdown, .legend { display: none !important; }
  .main-content { margin-left: 0; padding: .5rem; }
  .card { box-shadow: none; border: 1px solid #e2e8f0; }
  .timetable thead th { background: #1e293b !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 640px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-item span:last-child, .sidebar-footer { display: none; }
  .main-content { margin-left: 60px; padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .settings-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
