* {
  box-sizing: border-box;
}

/* Color Theme Variables */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #60a5fa;
  --header-bg: #0f172a;
  --header-border: #1e293b;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --bg-gradient-1: rgba(37, 99, 235, 0.35);
  --bg-gradient-2: rgba(59, 130, 246, 0.25);
  --success-bg: #dcfce7;
  --error-bg: #fee2e2;
  --info-bg: #dbeafe;
}

/* Ocean Theme (Teal) */
body[data-theme="ocean"] {
  --primary-color: #0891b2;
  --primary-dark: #0e7490;
  --primary-light: #06b6d4;
  --header-bg: #082f49;
  --header-border: #0f3a52;
  --bg-gradient-1: rgba(6, 182, 212, 0.35);
  --bg-gradient-2: rgba(34, 197, 231, 0.25);
}

/* Forest Theme (Green) */
body[data-theme="forest"] {
  --primary-color: #059669;
  --primary-dark: #047857;
  --primary-light: #10b981;
  --header-bg: #064e3b;
  --header-border: #065f46;
  --bg-gradient-1: rgba(16, 185, 129, 0.35);
  --bg-gradient-2: rgba(74, 222, 128, 0.25);
}

/* Sunset Theme (Orange) */
body[data-theme="sunset"] {
  --primary-color: #d97706;
  --primary-dark: #b45309;
  --primary-light: #f59e0b;
  --header-bg: #78350f;
  --header-border: #92400e;
  --bg-gradient-1: rgba(217, 119, 6, 0.35);
  --bg-gradient-2: rgba(245, 158, 11, 0.25);
  --text-primary: #1f2937;
}

/* Royal Theme (Purple) */
body[data-theme="royal"] {
  --primary-color: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-light: #a78bfa;
  --header-bg: #4c1d95;
  --header-border: #5b21b6;
  --bg-gradient-1: rgba(124, 58, 237, 0.35);
  --bg-gradient-2: rgba(167, 139, 250, 0.25);
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background:
    radial-gradient(circle at 12% 10%, var(--bg-gradient-1), transparent 40%),
    radial-gradient(circle at 88% 14%, var(--bg-gradient-2), transparent 38%),
    linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 50%, #dbeafe 100%);
  color: var(--text-primary);
  line-height: 1.4;
  min-height: 100vh;
  transition: background 0.5s ease, color 0.5s ease;
}

.container {
  width: min(1520px, 98%);
  margin: 0 auto;
}

.site-header {
  background: var(--header-bg);
  color: #fff;
  padding: 0.7rem 0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.25);
  transition: background 0.5s ease;
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-header a {
  color: #cbd5e1;
  margin-right: 0.8rem;
  text-decoration: none;
}

.site-header a:hover {
  color: #fff;
}

.site-header h1 {
  margin: 0;
  font-size: 1.35rem;
}

.site-header nav {
  display: flex;
  gap: 0.6rem;
}

.nav-dropdown {
  position: relative;
}

.dropdown-toggle {
  background: var(--header-border);
  color: #cbd5e1;
  border: 1px solid #334155;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-toggle:hover {
  background: #334155;
  color: #fff;
  border-color: #475569;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.dropdown-toggle::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform 0.3s ease;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--header-bg);
  border: 1px solid #334155;
  border-radius: 8px;
  margin-top: 0.4rem;
  min-width: 200px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.3s ease;
  z-index: 1000;
}

.dropdown-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  color: #cbd5e1;
  text-decoration: none;
  transition: all 0.2s ease;
  border-bottom: 1px solid #334155;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: #334155;
  color: #fff;
  padding-left: 1.2rem;
}

.dropdown-toggle:has(+ .dropdown-menu.active)::after {
  transform: rotate(180deg);
}

main.container {
  padding: 0.7rem 0 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0.65rem auto;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  width: 100%;
  max-width: 1000px;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
  transform: translateY(-2px);
}

.card h2,
.card h3 {
  margin: 0 0 0.35rem 0;
}

.card p {
  margin: 0.2rem 0 0.45rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(460px, 1.35fr);
  gap: 0.75rem;
  align-items: start;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.dashboard-col {
  min-width: 0;
}

.dashboard-col .card {
  margin-top: 0;
}

.student-dashboard {
  grid-template-columns: minmax(340px, 1fr) minmax(380px, 1fr);
}

.student-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
}

.student-hero-badges {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.badge {
  background: #e0ecff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.muted {
  color: #4b5563;
  font-size: 0.88rem;
}

.student-form {
  grid-template-columns: 1fr;
  gap: 0.7rem;
}

.student-form-block {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  background: #fbfdff;
}

.student-identity {
  background: #f8fbff;
}

.student-identity-grid,
.student-time-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.block-title {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #475569;
  font-weight: 700;
}

.student-submit-row {
  display: flex;
  justify-content: flex-end;
}

.student-submit-row button {
  min-width: 170px;
}

.grid-form {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  align-items: end;
}

.inline-form {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.92rem;
}

.days-fieldset {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 0.55rem 0.55rem;
  margin: 0;
  background: #f8fafc;
}

.days-fieldset legend {
  font-size: 0.92rem;
  padding: 0 0.3rem;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.35rem;
}

.checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  padding: 0.15rem 0.25rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:hover {
  transform: scale(1.1);
}

.checkbox-label input[type="checkbox"]:checked {
  accent-color: var(--primary-color);
}

.checkbox-label:hover {
  background: #eef2ff;
  padding: 0.2rem 0.35rem;
}

input,
select,
button {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  transition: all 0.2s ease;
}

input:focus,
select:focus {
  outline: 2px solid #bfdbfe;
  border-color: #60a5fa;
}

input:hover,
select:hover {
  border-color: #9ca3af;
}

button {
  background: var(--primary-color);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

button:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

button.danger {
  background: #dc2626;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
}

button.danger:hover {
  background: #b91c1c;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
  transform: translateY(-2px);
}

button.danger:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.55rem;
  font-size: 0.95rem;
}

th,
td {
  border-bottom: 1px solid #e5e7eb;
  padding: 0.5rem;
  text-align: left;
}

th {
  background: #f8fafc;
  font-weight: 600;
}

tbody tr {
  transition: all 0.2s ease;
}

tbody tr:hover {
  background: #f8fbff;
  box-shadow: inset 0 0 8px rgba(37, 99, 235, 0.05);
}

.messages {
  margin-top: 0.55rem;
  width: 100%;
}

.message {
  padding: 0.6rem;
  border-radius: 8px;
  margin: 0.3rem 0;
}

.message.success {
  background: #dcfce7;
}

.message.error {
  background: #fee2e2;
}

.message.info {
  background: #dbeafe;
}

small {
  color: #4b5563;
  font-size: 0.8rem;
}

.dropdown-divider {
  height: 1px;
  background: #334155;
  margin: 0.4rem 0;
}

.dropdown-label {
  padding: 0.5rem 1rem 0.3rem;
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.theme-option {
  background: none;
  border: none;
  color: #cbd5e1;
  padding: 0.7rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  position: relative;
}

.theme-option:hover {
  background: #334155;
  color: #fff;
  padding-left: 1.3rem;
  transform: none;
  box-shadow: none;
}

.theme-option.active {
  background: var(--primary-color);
  color: #fff;
  font-weight: 600;
}

.theme-option.active::before {
  content: '✓';
  position: absolute;
  left: 0.6rem;
  font-weight: bold;
}

.sort-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 0.75rem 0 1rem;
  padding: 0.6rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.sort-controls label {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: #475569;
  flex-direction: row;
  gap: 0;
}

.sort-select {
  min-width: 200px;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #1f2937;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sort-select:hover {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.sort-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

@media (max-width: 980px) {
  .dashboard-grid,
  .student-dashboard {
    grid-template-columns: 1fr;
  }

  .student-identity-grid,
  .student-time-grid {
    grid-template-columns: 1fr;
  }

  .student-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .sort-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .sort-select {
    width: 100%;
  }
}
