/* ====== MONSTER THEME STYLING SYSTEM ====== */

:root {
  /* Cute Pastel Claymorphic Color System */
  --bg: #fdfaf6;            /* Soft warm cream background */
  --surface: #ffffff;
  --surface2: #fcf4eb;       /* Soft peach surface */
  --border: #f5e7db;         /* Soft peachy-tan border */
  --text: #4a3e3d;           /* Dark cocoa text (softer than black) */
  --text2: #756665;          /* Muted cocoa text */
  --text3: #aba09f;          /* Light cocoa text */
  
  /* Accent Colors matching evolutionary monster colors */
  --accent: #ff7043;         /* Bright coral */
  --accent-light: #ffede7;
  --purple: #ab47bc;         /* Playful purple */
  --purple-light: #f3e5f5;
  --teal: #26a69a;           /* Friendly teal */
  --teal-light: #e0f2f1;
  --amber: #ffa726;          /* Happy orange-yellow */
  --amber-light: #fff3e0;
  --coral: #ff7043;          /* Warm coral */
  --coral-light: #ffede7;
  --green: #66bb6a;          /* Sage green */
  --green-light: #e8f5e9;
  --red: #ef5350;            /* Soft red */
  --red-light: #ffebee;
  
  --radius: 18px;            /* Bubbly rounded corners */
  --radius-lg: 24px;         /* Extra rounded for major cards */
  --radius-sm: 10px;
  
  /* Soft clay-like 3D shadows */
  --shadow: 0 8px 20px rgba(175, 140, 120, 0.08), 0 2px 6px rgba(175, 140, 120, 0.05);
  --shadow-hover: 0 12px 28px rgba(175, 140, 120, 0.16), 0 4px 10px rgba(175, 140, 120, 0.08);
}

/* Dark Mode Theme */
body.dark-theme, html.dark-theme {
  --bg: #211e22;            /* Dark plum-grey */
  --surface: #2d2830;       /* Deep plum card surface */
  --surface2: #38323c;
  --border: #4d4453;
  --text: #f0ebf1;          /* Bright warm grey */
  --text2: #cabecf;
  --text3: #9b8c9e;
  
  --accent: #ff8a65;
  --accent-light: #3d2c2f;
  --purple: #ba68c8;
  --purple-light: #3b2046;
  --teal: #4db6ac;
  --teal-light: #163635;
  --amber: #ffb74d;
  --amber-light: #3a2a11;
  --coral: #ff8a65;
  --coral-light: #3d2c2f;
  --green: #81c784;
  --green-light: #1e3322;
  --red: #e57373;
  --red-light: #3f1f21;
  
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 14px 35px rgba(0, 0, 0, 0.5);
}

/* Global Reset & Base Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Fredoka', 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Styling (Drawer Mode on Mobile) */
.sidebar {
  width: 250px;
  background: var(--surface);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.main {
  flex: 1;
  overflow: auto;
  min-width: 0;
}

.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 2px solid var(--border);
}

.sidebar-brand h1 {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--accent);
}

.sidebar-brand p {
  font-size: 10px;
  color: var(--text3);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  padding: 16px 10px;
  flex: 1;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 18px;
}

.nav-label {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text3);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 0 12px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text2);
  transition: all .2s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-weight: 600;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
  transform: translateX(4px);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 0 2px 4px rgba(255, 112, 67, 0.05);
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-purple { background: var(--purple); }
.dot-teal { background: var(--teal); }
.dot-amber { background: var(--amber); }
.dot-coral { background: var(--coral); }

.sidebar-bottom {
  padding: 16px;
  border-top: 2px solid var(--border);
}

.class-select {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.2s;
}

.class-select:focus {
  border-color: var(--accent);
}

/* Topbar Styling */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 16px;
}

.topbar h2 {
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Bubbly Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 99px; /* Rounded pill style */
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all .2s cubic-bezier(0.175, 0.885, 0.32, 1.255);
  font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: #f4511e;
  box-shadow: 0 6px 14px rgba(255, 112, 67, 0.3);
}

.btn-outline {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text2);
}
.btn-outline:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--text3);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 11.5px;
  border-radius: 12px;
}

.btn-danger {
  background: var(--red-light);
  color: var(--red);
}
.btn-danger:hover {
  background: #ffcdd2;
}

.btn-teal {
  background: var(--teal-light);
  color: var(--teal);
}
.btn-teal:hover {
  background: #b2dfdb;
}

/* Content Container */
.content {
  padding: 24px;
}

.panel {
  display: none;
}
.panel.active {
  display: block;
}

/* Dashboard Statistics Cards */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card .label {
  font-size: 11px;
  color: var(--text3);
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  font-family: 'Fredoka', sans-serif;
}

.stat-card .sub {
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 4px;
  font-weight: 600;
}

.stat-purple .value { color: var(--purple); }
.stat-teal .value { color: var(--teal); }
.stat-amber .value { color: var(--amber); }
.stat-coral .value { color: var(--coral); }
.stat-green .value { color: var(--green); }
.stat-red .value { color: var(--red); }

/* Bubbly Claymorphic Cards */
.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 2px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface2);
}

.card-header h3 {
  font-size: 15px;
  font-weight: 800;
}

.card-body {
  padding: 20px;
}

/* Table Styling */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.tbl th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text3);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface2);
}

.tbl td {
  padding: 12px 14px;
  border-bottom: 1.5px solid var(--border);
  color: var(--text);
  vertical-align: middle;
  transition: background 0.15s;
}

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

.tbl tr:hover td {
  background: var(--surface2);
}

.tbl th.ctr, .tbl td.ctr {
  text-align: center;
}

/* Avatar Badges */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.05);
}

.av-p { background: var(--purple-light); color: var(--purple); }
.av-t { background: var(--teal-light); color: var(--teal); }
.av-a { background: var(--amber-light); color: var(--amber); }
.av-c { background: var(--coral-light); color: var(--coral); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

.badge-A { background: var(--green-light); color: var(--green); }
.badge-B { background: var(--teal-light); color: var(--teal); }
.badge-C { background: var(--amber-light); color: var(--amber); }
.badge-D { background: var(--coral-light); color: var(--coral); }
.badge-F { background: var(--red-light); color: var(--red); }

.badge-pos { background: var(--green-light); color: var(--green); }
.badge-neg { background: var(--red-light); color: var(--red); }
.badge-info { background: var(--accent-light); color: var(--accent); }

/* Forms & Inputs */
.form-row {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text2);
}

.form-group input, .form-group select, .form-group textarea, .inp {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: all .2s ease;
  font-weight: 500;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

.score-cell input {
  width: 68px;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  text-align: center;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  font-weight: 700;
}

.score-cell input:focus {
  border-color: var(--accent);
}

/* Attendance styling */
.att-period-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.att-period-tab {
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  transition: all .15s;
}

.att-period-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.att-table-wrap {
  overflow-x: auto;
}

.att-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.att-tbl th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text3);
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  background: var(--surface2);
}

.att-tbl td {
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--border);
  vertical-align: middle;
}

.att-tbl tr:last-child td {
  border-bottom: none;
}

.att-tbl tr:hover td {
  background: var(--surface2);
}

.att-btn {
  padding: 4px 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 800;
  font-family: inherit;
  transition: all .15s;
  min-width: 44px;
}

.att-btn.P { background: var(--green-light); color: var(--green); }
.att-btn.L { background: var(--amber-light); color: var(--amber); }
.att-btn.A { background: var(--red-light); color: var(--red); }
.att-btn.E { background: var(--teal-light); color: var(--teal); }

.att-btn:hover {
  filter: brightness(.93);
  transform: translateY(-1px);
}

/* Behavior list */
.behavior-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  background: var(--surface);
}

.beh-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.beh-pos { background: var(--green-light); color: var(--green); }
.beh-neg { background: var(--red-light); color: var(--red); }

/* Assignment */
.asn-item {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
}

.asn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.asn-pending { background: var(--amber); }
.asn-done { background: var(--green); }
.asn-overdue { background: var(--red); }

/* Weight slider */
.weight-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1.5px solid var(--border);
}

.weight-row:last-child {
  border-bottom: none;
}

.weight-row label {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
}

.weight-row input[type=range] {
  width: 140px;
  cursor: pointer;
}

.weight-val {
  width: 45px;
  text-align: right;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
}

/* Dashboard items */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.dashboard-grid-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (min-width: 1025px) {
  .dashboard-grid-container {
    grid-template-columns: 1fr 1fr;
  }
  .dash-card-1 {
    grid-column: 1;
    grid-row: 1;
  }
  .dash-card-3 {
    grid-column: 1;
    grid-row: 2;
  }
  .dash-card-2 {
    grid-column: 2;
    grid-row: 1;
  }
  .dash-card-4 {
    grid-column: 2;
    grid-row: 2;
  }
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .5s ease;
}

.risk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1.5px solid var(--border);
}

.risk-item:last-child {
  border-bottom: none;
}

.risk-level {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.risk-high { background: var(--red); }
.risk-med { background: var(--amber); }
.risk-low { background: var(--teal); }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 160px;
  padding-top: 15px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}

.bar-fill {
  width: 100%;
  border-radius: 8px 8px 0 0;
  min-height: 4px;
  transition: height .5s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.bar-label {
  font-size: 10px;
  color: var(--text3);
  font-weight: 600;
}

.bar-val {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text2);
}

/* Interactive Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(48, 38, 38, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 3px solid var(--border);
  padding: 24px;
  width: 520px;
  max-width: 94vw;
  max-height: 88vh;
  overflow-y: auto;
  transform: scale(0.9) translateY(20px);
  transition: transform .3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity .3s;
  box-shadow: 0 20px 48px rgba(0,0,0,0.15);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal h2 {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid var(--border);
}

/* Upload zones */
.upload-zone {
  border: 3px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--surface2);
}

.upload-zone:hover, .upload-zone.drag {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone p {
  font-size: 13.5px;
  color: var(--text3);
  margin-top: 8px;
  font-weight: 600;
}

.upload-zone span {
  font-size: 32px;
}

/* Subject tabs */
.subject-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.subject-tab {
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  transition: all .15s;
}

.subject-tab.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

/* Messages */
.msg-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  background: var(--surface);
}

.msg-unread {
  border-left: 4px solid var(--accent);
}

.msg-name {
  font-size: 13.5px;
  font-weight: 700;
}

.msg-time {
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
}

.msg-body {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
}

/* Toast alert */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #332d2c;
  color: #fff;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 10000;
  opacity: 0;
  transform: translateY(12px);
  transition: all .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
  border: 1px stroke rgba(255,255,255,0.1);
}

.toast.show {
  opacity: 1;
  transform: none;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text3);
}

/* Sync Header bar */
.sync-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
  font-size: 12.5px;
  flex-wrap: wrap;
  font-weight: 600;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

.sync-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-dot.connected {
  background: var(--green);
  animation: pulse 2s infinite;
}

.sync-dot.disconnected {
  background: var(--text3);
}

.sync-dot.syncing {
  background: var(--amber);
  animation: spin .8s linear infinite;
}

.sync-dot.error {
  background: var(--red);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(1.15); }
}

.setup-banner {
  background: var(--accent-light);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
}

.setup-banner h4 {
  color: var(--accent);
  font-size: 15px;
  margin-bottom: 8px;
  font-weight: 800;
}

.setup-banner ol {
  padding-left: 20px;
  color: var(--text2);
  line-height: 1.8;
  font-weight: 600;
}

.setup-banner code {
  background: rgba(255, 112, 67, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 12px;
  color: var(--accent);
  font-weight: bold;
}

/* Drag and Drop schedule builder */
.dnd-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
}

.dnd-subject-chip {
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: grab;
  font-size: 13px;
  font-weight: 700;
  user-select: none;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dnd-subject-chip:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-1px);
}

.dnd-subject-chip:active {
  cursor: grabbing;
  transform: scale(.96);
}

.dnd-subject-chip.dragging {
  opacity: .4;
}

.dnd-cell {
  border: 2px dashed var(--border);
  border-radius: 10px;
  min-height: 56px;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.dnd-cell.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.dnd-cell.has-subject {
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--surface);
}

.dnd-pill {
  background: var(--accent-light);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  width: 100%;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(255, 112, 67, 0.05);
}

.dnd-pill:hover {
  background: #ffdcd0;
}

.dnd-pill .dnd-del {
  opacity: 0;
  transition: opacity .15s;
  color: var(--red);
  font-size: 14px;
}

.dnd-pill:hover .dnd-del {
  opacity: 1;
}

.dnd-day-header {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text2);
  text-align: center;
  padding: 8px;
  background: var(--surface2);
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

.dnd-period-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text3);
  text-align: center;
  padding: 6px;
  white-space: nowrap;
}

.sumv-btn {
  padding: 9px 18px;
  font-size: 12.5px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-family: inherit;
  border-left: 2px solid var(--border);
  transition: all .15s;
}

.sumv-btn:first-child {
  border-left: none;
}

.sumv-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.sumv-btn.active {
  background: var(--accent);
  color: #fff;
}

.stat-big {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-big .lbl {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text3);
  letter-spacing: .06em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.stat-big .val {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
  font-family: 'Fredoka', sans-serif;
}

.stat-big .sub {
  font-size: 12.5px;
  margin-top: 6px;
  font-weight: 600;
}

.risk-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1.5px solid var(--border);
  gap: 12px;
}

.risk-row:last-child {
  border-bottom: none;
}

.phase-tab {
  padding: 8px 20px;
  font-size: 12.5px;
  font-weight: 700;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: var(--text3);
  border-bottom: 3.5px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}

.phase-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.work-row {
  display: grid;
  grid-template-columns: 32px 1fr 90px 90px 90px 90px;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1.5px solid var(--border);
  gap: 8px;
  font-size: 13px;
}

.work-row:hover {
  background: var(--surface2);
}

.score-inp {
  width: 66px;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  font-size: 12.5px;
  text-align: center;
  font-family: inherit;
  outline: none;
  font-weight: 700;
  transition: border-color .15s;
}

.score-inp:focus {
  border-color: var(--accent);
}

.score-badge {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}

.sync-progress {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  z-index: 9999;
}

.version-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.version-card.current {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Numeric Grading Badges */
.badge-4 { background: var(--green-light); color: var(--green); }
.badge-3\.5, .badge-3_5 { background: var(--green-light); color: var(--green); }
.badge-3 { background: var(--teal-light); color: var(--teal); }
.badge-2\.5, .badge-2_5 { background: var(--teal-light); color: var(--teal); }
.badge-2 { background: var(--amber-light); color: var(--amber); }
.badge-1\.5, .badge-1_5 { background: var(--amber-light); color: var(--amber); }
.badge-1 { background: var(--coral-light); color: var(--coral); }
.badge-0 { background: var(--red-light); color: var(--red); }

/* ====== BEHAVIOR REDESIGN MODULE STYLING ====== */
.beh-header-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.beh-title-wrap {
  flex: 1;
  min-width: 250px;
}

.beh-search-wrap {
  width: 320px;
  max-width: 100%;
}

.beh-main-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.beh-grid-col {
  min-width: 0;
}

.beh-sidebar-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.beh-student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

/* Claymorphic Student Card with evolution stats */
.beh-student-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 18px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: all .25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.beh-student-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

.beh-student-card h4 {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.beh-student-card p {
  font-size: 11.5px;
  color: var(--text3);
  margin-bottom: 12px;
  font-weight: 600;
}

.beh-score-text {
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1;
  font-family: 'Fredoka', sans-serif;
}

.beh-score-high { color: var(--green); }
.beh-score-normal { color: var(--purple); }

.beh-btn-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: auto;
}

.beh-btn-give {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}

.beh-btn-give:hover {
  background: #f4511e;
  transform: translateY(-1px);
}

.beh-btn-take {
  flex: 1;
  background: transparent;
  border: 2px solid var(--red);
  color: var(--red);
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}

.beh-btn-take:hover {
  background: var(--red);
  color: #fff;
  transform: translateY(-1px);
}

/* Leaderboard */
.beh-leader-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1.5px solid var(--border);
  transition: background .2s;
}

.beh-leader-row:hover {
  background: var(--surface2);
}

.beh-leader-row:last-child {
  border-bottom: none;
}

.beh-badge-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  font-family: 'Fredoka', sans-serif;
}

.beh-badge-gold {
  background: #fff8e1;
  color: #f57c00;
  border: 2px solid #ffe082;
}

.beh-badge-silver {
  background: #eceff1;
  color: #455a64;
  border: 2px solid #cfd8dc;
}

.beh-badge-bronze {
  background: #efebe9;
  color: #5d4037;
  border: 2px solid #d7ccc8;
}

.beh-badge-normal {
  background: var(--border);
  color: var(--text2);
}

.beh-highlight-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  font-weight: 600;
}

.beh-highlight-item:last-child {
  margin-bottom: 0;
}

.beh-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.beh-quick-chip {
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text2);
  transition: all .2s;
  text-align: left;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 8px;
}

.beh-quick-chip:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  transform: translateY(-1px);
}

.beh-quick-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 10px rgba(255,112,67,0.2);
}

/* Attendance calendar */
.att-tab-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  border-bottom: 2.5px solid var(--border);
  padding-bottom: 10px;
  gap: 10px;
}

.att-main-tab-btn {
  border: none;
  background: transparent;
  color: var(--text2);
  padding: 10px 24px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.att-main-tab-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.att-main-tab-btn.active {
  background: var(--accent);
  color: #fff !important;
  box-shadow: 0 6px 16px rgba(255, 112, 67, 0.25);
}

.att-layout-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

.cal-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px 6px;
  text-align: center;
  margin-top: 12px;
  width: 100%;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: var(--surface);
  min-width: 0;
  font-family: 'Fredoka', sans-serif;
}

.cal-day:hover:not(.empty) {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
  border-color: var(--text3);
}

.cal-day.empty {
  border: none;
  background: transparent;
  cursor: default;
}

.cal-day.weekend {
  background: var(--surface2);
  color: var(--text3);
}

.cal-day.holiday {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-light);
}

.cal-day.checked {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-light);
}

.cal-day.unchecked {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-light);
}

.cal-day.selected {
  outline: 3px solid var(--accent);
  outline-offset: -1.5px;
  z-index: 2;
}

.cal-day.outside-term {
  opacity: 0.4;
  background: var(--surface2);
}

.cal-day .holiday-lbl {
  position: absolute;
  bottom: 4px;
  left: 2px;
  right: 2px;
  font-size: 8px;
  font-weight: 700;
  color: var(--amber);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.period-switch-card {
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: var(--surface);
  flex: 0 0 230px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.period-switch-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.period-switch-card.active {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-hover) !important;
}

/* User profiles & Account items */
.sidebar-profile-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  border: 2px solid transparent;
}

.sidebar-profile-btn.logged-out {
  background: var(--red-light) !important;
  border: 2px dashed var(--red) !important;
  color: var(--red) !important;
}

.sidebar-profile-btn.logged-in {
  background: var(--surface2);
  border: 2px solid var(--border);
  color: var(--text);
}

.sidebar-profile-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.profile-avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--border);
  background: rgba(0, 0, 0, 0.05);
}

.profile-dropdown {
  display: none;
  position: absolute;
  bottom: 80px;
  left: 14px;
  right: 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.15);
  z-index: 1000;
  animation: slideUpDropdown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-dropdown-header {
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 10px;
}

.profile-dropdown-name {
  font-weight: 800;
  color: var(--text);
  font-size: 14px;
}

.profile-dropdown-email {
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 2px;
}

.profile-dropdown-btn {
  display: flex;
  align-items: center;
  width: 100%;
  border: none;
  background: none;
  color: var(--text2);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.profile-dropdown-btn:hover {
  color: var(--text);
  background: var(--surface2);
}

.profile-dropdown-btn.logout {
  color: var(--red);
  font-weight: 700;
}

.profile-dropdown-btn.logout:hover {
  background: var(--red-light);
}

.topbar-profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.topbar-profile-avatar:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.topbar-dropdown-custom {
  bottom: auto !important;
  top: 46px !important;
  right: 0 !important;
  left: auto !important;
  width: 250px !important;
}

/* Semester controls */
.semester-segmented-control {
  display: inline-flex;
  background: var(--surface2);
  border: 2px solid var(--border);
  padding: 4px;
  border-radius: 14px;
  gap: 6px;
  align-items: center;
}

.semester-segmented-control .segment-btn {
  border: none;
  background: transparent;
  color: var(--text2);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.semester-segmented-control .segment-btn:hover {
  color: var(--text);
  background: rgba(0,0,0,0.03);
}

.semester-segmented-control .segment-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* Monster Level & Progress Bar styling inside student cards */
.monster-level-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  margin-top: 4px;
  margin-bottom: 4px;
  font-family: 'Fredoka', sans-serif;
  letter-spacing: 0.02em;
}

.monster-level-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 10px;
}

.monster-exp-bar-container {
  width: 85%;
  height: 9px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 14px;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}

.monster-exp-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ====== MOBILE DRAWER & LAYOUT RULES ====== */
#sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 18px;
  padding: 0;
  border-radius: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(48, 38, 38, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* Floating bottom navigation bar */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 16px; /* Floating look */
  left: 16px;
  right: 16px;
  height: 64px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid var(--border);
  border-radius: 24px;
  z-index: 900;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px;
  box-shadow: 0 10px 30px rgba(185, 160, 140, 0.16);
  animation: slideUpNav 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

body.dark-theme .bottom-nav {
  background: rgba(45, 40, 48, 0.92);
}

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

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  flex: 1;
  height: 100%;
  gap: 3px;
  font-family: inherit;
  font-weight: 700;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bottom-nav-item:hover {
  color: var(--text);
}

.bottom-nav-item.active {
  color: var(--accent);
  transform: translateY(-4px) scale(1.08);
}

.bottom-nav-icon {
  font-size: 22px;
}

.bottom-nav-label {
  font-size: 10px;
  letter-spacing: 0.02em;
}

/* Grids and Responsive Columns */
.rwd-grid-sidebar-left {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
}

.rwd-grid-sidebar-right {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.rwd-grid-2col, .rwd-grid-2col-compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.rwd-grid-2col-compact {
  gap: 12px;
}

.rwd-grid-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

.rwd-grid-4col {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.rwd-grid-8col {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
}

.rwd-grid-autofit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

/* Media Query breakpoints */
@media (max-width: 900px) {
  #sidebar-toggle-btn {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    width: 250px;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: 6px 0 30px rgba(0,0,0,0.25);
    border-right: none;
  }
  .sidebar.show {
    transform: translateX(0);
  }
}

@media (max-width: 1150px) {
  .rwd-grid-sidebar-left,
  .rwd-grid-sidebar-right,
  .beh-main-layout,
  .att-layout-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
  }
  .main {
    padding-bottom: 96px !important; /* Extra room for floating bottom nav */
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .rwd-grid-2col,
  .rwd-grid-3col {
    grid-template-columns: 1fr !important;
  }
  .rwd-grid-4col {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .rwd-grid-8col {
    grid-template-columns: repeat(4, 1fr) !important;
  }
  .sync-bar {
    display: none !important;
  }
  .mobile-offline-badge {
    display: inline-block !important;
  }
  .content {
    padding: 16px;
  }
  .topbar {
    padding: 14px 16px;
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr !important;
  }
  .rwd-grid-2col-compact {
    grid-template-columns: 1fr !important;
  }
  .rwd-grid-4col {
    grid-template-columns: 1fr !important;
  }
  .rwd-grid-8col {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .card-header {
    padding: 12px 14px;
  }
  .card-body {
    padding: 14px;
  }
}
