:root {
  /* Color Palette - Dark Theme */
  --bg-body: #0f172a;       /* Deep Slate */
  --bg-sidebar: #1e293b;    /* Slate 800 */
  --bg-card: #1e293b;       /* Slate 800 */
  --bg-input: #020617;      /* Slate 950 */
  
  /* Text Colors */
  --text-primary: #f8fafc;  /* Slate 50 */
  --text-secondary: #94a3b8;/* Slate 400 */
  --text-muted: #64748b;    /* Slate 500 */

  /* Brand Colors */
  --brand-primary: #6366f1; /* Indigo 500 */
  --brand-hover: #4f46e5;   /* Indigo 600 */
  --brand-secondary: #06b6d4; /* Cyan 500 */
  
  /* Borders */
  --border-color: #334155;  /* Slate 700 */
  
  /* Status Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  /* Spacing & Layout */
  --sidebar-width: 200px;
  --header-height: 64px;
  --sidebar-collapsed-width: 64px;
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg-body);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

.brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--brand-primary);
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
}

.brand i {
  font-size: 24px;
}

.nav-menu {
  padding: 20px 16px;
  flex: 1;
}

.nav-group {
  margin-bottom: 24px;
}

.nav-group-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 12px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  margin-bottom: 4px;
  font-size: 14px;
}

.nav-item:hover,
.nav-item.active {
  background-color: rgba(99, 102, 241, 0.1);
  color: var(--brand-primary);
}

.nav-item.active {
  font-weight: 600;
  background-color: rgba(99, 102, 241, 0.15);
}

.nav-item i {
  font-size: 18px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.top-header {
  height: var(--header-height);
  background-color: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--bg-card);
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.content-wrapper {
  padding: 32px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Panels / Cards */
.panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  overflow-x: auto;
}

.panel-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Forms */
.form {
  display: grid;
  gap: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  align-items: center;
}

label {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="file"],
select {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius);
  width: 100%;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Checkbox Group */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}

.checkbox-item:hover {
  border-color: var(--text-muted);
}

.checkbox-item input {
  margin: 0;
  accent-color: var(--brand-primary);
}

/* Buttons */
.btn {
  background-color: var(--brand-primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn:hover {
  background-color: var(--brand-hover);
}

/* Tables */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.table th {
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Utilities */
.alert {
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--success);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}

.text-red { color: var(--danger); font-weight: 600; }
.text-green { color: var(--success); font-weight: 600; }

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Tooltip */
.tooltip-card {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  border-radius: var(--radius);
  padding: 12px;
  z-index: 1000;
  display: none;
  min-width: 280px;
  pointer-events: none;
  color: var(--text-primary);
}

.tooltip-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--brand-secondary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.tooltip-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.tooltip-table th,
.tooltip-table td {
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tooltip-table th {
  color: var(--text-muted);
  font-weight: 500;
}

.tooltip-table tr:last-child td {
  border-bottom: none;
}

.student-name-hover {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 4px;
}

.student-name-hover:hover {
  color: var(--brand-secondary);
  text-decoration-color: var(--brand-secondary);
}

/* Table Sorting UI */
.th-sort-label {
  margin-right: 8px;
}

.th-sort-indicator {
  font-size: 16px;
  color: var(--text-muted);
}

.table th:hover .th-sort-indicator {
  color: var(--brand-primary);
}

.table th.th-sorted .th-sort-indicator {
  color: var(--brand-secondary);
}

.subject-title {
  cursor: pointer;
  color: var(--text-primary);
}

.subject-title:hover {
  color: var(--brand-secondary);
}

.modal-overlay {
  position: fixed;
  left: 0; right: 0; top: 0; bottom: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-content {
  width: 92vw;
  height: 88vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--brand-secondary);
}

.modal-body {
  padding: 16px 20px;
  overflow: auto;
  flex: 1;
}
/* Collapsed Sidebar */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}
.app-container .sidebar.collapsed + .main-content {
  margin-left: var(--sidebar-collapsed-width);
}
.sidebar.collapsed .brand span {
  display: none;
}
.sidebar.collapsed .nav-menu {
  padding: 12px 8px;
}
.sidebar.collapsed .nav-group-title {
  display: none;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  gap: 0;
}
.sidebar.collapsed .nav-item span {
  display: none;
}
.sidebar.collapsed .nav-item i {
  font-size: 20px;
}
