/* ===================================================
   Theme หลัก
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700;800&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  /* === Blue Color Palette === */
  --kmitl-red: #1556C0;
  --kmitl-red-dark: #0d3f94;
  --kmitl-red-light: #1e6be0;
  --kmitl-red-muted: rgba(21, 86, 192, 0.08);
  --kmitl-red-border: rgba(21, 86, 192, 0.18);
  --kmitl-gold: #c9a227;
  --kmitl-gold-light: #e8c04a;
  --kmitl-gold-pale: #fdf6e3;

  /* Backgrounds */
  --bg-primary: #f5f6fa;
  --bg-secondary: #ffffff;
  --bg-glass: #ffffff;
  --bg-sidebar: #1556C0;
  /* Royal Blue sidebar */
  --bg-sidebar-hover: rgba(255, 255, 255, 0.12);
  --bg-sidebar-active: rgba(255, 255, 255, 0.18);
  --bg-navbar: #ffffff;
  --bg-header-bar: #0d3f94;
  /* Darker blue for top-strip */

  /* Borders */
  --border-glass: #dde3ed;
  --border-light: #e8ecf4;
  --border-red: rgba(21, 86, 192, 0.2);

  /* Text */
  --text-primary: #1a1f36;
  --text-secondary: #44506a;
  --text-muted: #8492a6;
  --text-on-dark: #ffffff;
  --text-on-dark-sub: rgba(255, 255, 255, 0.78);
  --text-on-dark-muted: rgba(255, 255, 255, 0.48);

  /* Accent */
  --accent-primary: #1556C0;
  --accent-primary-hover: #1e6be0;
  --accent-gradient: linear-gradient(135deg, #1556C0 0%, #2979FF 100%);
  --accent-gold-gradient: linear-gradient(135deg, #c9a227 0%, #e8c04a 100%);

  /* Status */
  --color-normal: #2e7d32;
  --color-normal-bg: #e8f5e9;
  --color-normal-border: #a5d6a7;
  --color-risk: #e65100;
  --color-risk-bg: #fff3e0;
  --color-risk-border: #ffcc80;
  --color-problem: #b71c1c;
  --color-problem-bg: #ffebee;
  --color-problem-border: #ef9a9a;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.07);
  --shadow-md: 0 3px 14px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.14);
  --shadow-red: 0 4px 18px rgba(21, 86, 192, 0.25);
}

/* ──────────────────────────────────── BASE ─── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Sarabun', 'Prompt', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.7;
  font-size: 16px;
}

/* ──────────────────────────────── LAYOUT ─── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  background: var(--bg-primary);
}

/* ──────────────────────────────── SIDEBAR ─── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 3px 0 16px rgba(0, 0, 0, 0.20);
}

/* Top strip — gold accent bar */
.sidebar-header {
  padding: 0;
  border-bottom: 3px solid var(--kmitl-gold);
  background: var(--bg-header-bar);
}

.sidebar-header-inner {
  padding: 22px 20px 18px;
}

.sidebar-logo {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  background: var(--accent-gold-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 10px;
  box-shadow: 0 3px 10px rgba(201, 162, 39, 0.45);
}

.sidebar-title {
  font-family: 'Prompt', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-on-dark);
  line-height: 1.35;
}

.sidebar-subtitle {
  font-size: 0.78rem;
  color: var(--text-on-dark-sub);
  margin-top: 3px;
}

/* Nav items */
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-on-dark-sub);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.18s;
  margin-bottom: 3px;
  border-left: 3px solid transparent;
}

.sidebar-nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-on-dark);
  border-left-color: var(--kmitl-gold);
}

.sidebar-nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--kmitl-gold-light);
  border-left-color: var(--kmitl-gold);
  font-weight: 700;
}

.sidebar-nav-icon {
  font-size: 1rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-on-dark-muted);
  font-size: 0.83rem;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}

.sidebar-logout-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffaaaa;
}

/* ──────────────────────────────── NAVBAR ─── */
.navbar {
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-navbar);
  border-bottom: 3px solid var(--kmitl-red);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 58px;
}

.navbar-title {
  font-family: 'Prompt', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--kmitl-red);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
  border: 2px solid var(--kmitl-gold);
}

.navbar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.navbar-user-dept {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ────────────────────────── PAGE CONTAINER ─── */
.page-container {
  padding: 24px 28px;
}

.page-header {
  margin-bottom: 22px;
}

.page-title {
  font-family: 'Prompt', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--kmitl-red);
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 22px;
  background: var(--accent-gold-gradient);
  border-radius: 2px;
  flex-shrink: 0;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ────────────────────────── CARDS / PANELS ─── */
.dashboard-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.dashboard-card-title {
  font-family: 'Prompt', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--kmitl-red);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--kmitl-gold-pale);
}

/* ──────────────────────────────── TABLES ─── */
.students-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  flex: 1;
  min-width: 240px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.search-box:hover {
  border-color: var(--kmitl-red);
  box-shadow: 0 2px 8px rgba(21, 86, 192, 0.08);
}

.search-box:focus-within {
  border-color: var(--kmitl-red);
  box-shadow: 0 0 0 3px rgba(21, 86, 192, 0.15);
}

.search-icon {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
}

.search-input::placeholder {
  color: #b0b0b0;
}

.filter-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231556C0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 36px 8px 14px;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.filter-select:hover {
  border-color: var(--kmitl-red);
  box-shadow: 0 2px 8px rgba(21, 86, 192, 0.12);
  transform: translateY(-1px);
}

.filter-select:focus {
  border-color: var(--kmitl-red);
  box-shadow: 0 0 0 3px rgba(21, 86, 192, 0.15);
  background-color: var(--bg-secondary);
}

.filter-select option {
  font-family: 'Sarabun', 'Prompt', sans-serif;
  font-size: 0.95rem;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 12px;
}

.custom-select-hidden {
  display: none !important;
}

/* Custom Select Replacement Styling with rounded corners and shadows */
.custom-select-container {
  position: relative;
  display: inline-block;
  min-width: 180px;
  user-select: none;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-select-trigger:hover {
  border-color: var(--kmitl-red);
  box-shadow: 0 2px 8px rgba(21, 86, 192, 0.12);
  transform: translateY(-1px);
}

.custom-select-container.open .custom-select-trigger {
  border-color: var(--kmitl-red);
  box-shadow: 0 0 0 3px rgba(21, 86, 192, 0.15);
  transform: translateY(0);
}

/* Custom Dropdown Arrow */
.custom-select-trigger::after {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--kmitl-red);
  border-bottom: 2px solid var(--kmitl-red);
  transform: rotate(45deg);
  transition: transform 0.25s ease;
  margin-left: 12px;
  margin-top: -3px;
  flex-shrink: 0;
}

.custom-select-container.open .custom-select-trigger::after {
  transform: rotate(-135deg);
  margin-top: 3px;
}

/* Custom Dropdown Menu with rounded corners and shadow */
.custom-select-options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  /* Rounded corners! */
  box-shadow: var(--shadow-lg);
  /* Soft premium shadow! */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  max-height: 250px;
  overflow-y: auto;
}

.custom-select-container.open .custom-select-options {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Option Items */
.custom-select-option {
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.custom-select-option:hover {
  background-color: var(--kmitl-red-muted);
  color: var(--kmitl-red);
}

.custom-select-option.selected {
  background-color: var(--kmitl-red);
  color: white;
}

.students-table-wrapper {
  background: white;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.students-table {
  width: 100%;
  border-collapse: collapse;
}

.students-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.88rem;
  font-weight: 700;
  color: white;
  background: var(--kmitl-red);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.students-table td {
  padding: 9px 14px;
  font-size: 0.92rem;
  border-top: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.students-table tbody tr {
  transition: background 0.12s;
}

.students-table tbody tr:hover {
  background: #f0f5ff;
}

.student-code {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  color: var(--kmitl-red);
  font-weight: 700;
}

.student-name {
  font-weight: 600;
  color: var(--text-primary);
}

/* ──────────────────────────────── BADGES ─── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge.normal {
  background: var(--color-normal-bg);
  color: var(--color-normal);
  border: 1px solid var(--color-normal-border);
}

.badge.risk {
  background: var(--color-risk-bg);
  color: var(--color-risk);
  border: 1px solid var(--color-risk-border);
}

.badge.problem {
  background: var(--color-problem-bg);
  color: var(--color-problem);
  border: 1px solid var(--color-problem-border);
}

.badge.pending {
  background: #f5f5f5;
  color: var(--text-muted);
  border: 1px solid var(--border-glass);
}

/* ────────────────────────────── PAGINATION ─── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.pagination-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: white;
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 0.80rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--kmitl-red);
  color: white;
  border-color: var(--kmitl-red);
}

.pagination-btn.active {
  background: var(--accent-gradient);
  color: white;
  border-color: transparent;
  font-weight: 700;
}

.pagination-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 8px;
}

/* ─────────────────────────────── BUTTONS ─── */
.btn {
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  border: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}


.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(139, 0, 0, 0.25);
}

.btn-primary:hover {
  opacity: 0.88;
  transform: translateY(-1px);
  box-shadow: var(--shadow-red);
}

.btn-outline {
  background: transparent;
  color: var(--kmitl-red);
  border: 1.5px solid var(--kmitl-red);
}

.btn-outline:hover {
  background: var(--kmitl-red);
  color: white;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.78rem;
}

.btn-gold {
  background: var(--accent-gold-gradient);
  color: white;
}

.btn-gold:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

/* ───────────────────────────────── FORMS ─── */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 9px 13px;
  background: white;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--kmitl-red);
  box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.09);
}

.form-input::placeholder {
  color: #bbb;
}



/* ─────────────────────────────── TOAST ─── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  background: var(--kmitl-red);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: var(--shadow-red);
  z-index: 9999;
  animation: slideUp 0.3s ease;
  border-left: 4px solid var(--kmitl-gold);
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ─────────────────────────────── LOADING ─── */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f0f0f0;
  border-top-color: var(--kmitl-red);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─────────────────────────── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* ───────────────────────────────── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 45, 110, 0.40);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: white;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 30px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.20);
  animation: fadeInUp 0.28s ease;
  border-top: 4px solid var(--kmitl-red);
}

@keyframes fadeInUp {
  from {
    transform: translateY(22px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-title {
  font-family: 'Prompt', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--kmitl-red);
  padding-bottom: 12px;
  border-bottom: 2px solid #e0ecff;
}


/* ──────────────────────────── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .navbar {
    padding: 0 16px;
  }

  .page-container {
    padding: 14px 16px;
  }
}