/* ============================================
   Wiselume Theme
   Primary Emerald Green: #2E8B57 (brand / CTA)
   Secondary Navy Blue:   #1B2A49 (structure / text)
   Accent 1 Deep Teal:    #014D4E (links)
   Accent 2 Gold:         #D4AF37 (ratings / highlights)
   Neutral Warm White:    #FAF9F6 (background)
   ============================================ */

/* === CSS Variables === */
:root {
  /* Brand palette — Wiselume */
  --wl-emerald: #2E8B57;                 /* Primary — brand / CTA */
  --wl-emerald-light: #3FA76A;
  --wl-emerald-dark: #246B43;            /* hover / solid-button (AA white text) */
  --wl-emerald-lighter: rgba(46, 139, 87, 0.10);
  --wl-navy: #1B2A49;                    /* Secondary — structure / text */
  --wl-navy-light: #2C4170;
  --wl-navy-lighter: rgba(27, 42, 73, 0.08);
  --wl-teal: #014D4E;                    /* Accent 1 — links */
  --wl-teal-light: #0A6E6F;
  --wl-gold: #D4AF37;                    /* Accent 2 — ratings / highlights */
  --wl-gold-dark: #A8862B;
  --wl-warm-white: #FAF9F6;              /* Neutral — background */

  /* Legacy brand aliases (kept so existing rules keep working) */
  --kc-navy: var(--wl-navy);
  --kc-navy-light: var(--wl-navy-light);
  --kc-navy-lighter: var(--wl-navy-lighter);
  --kc-orange: var(--wl-emerald);        /* old CTA accent → emerald */
  --kc-orange-light: var(--wl-emerald-light);
  --kc-orange-lighter: var(--wl-emerald-lighter);
  --kc-gold: var(--wl-gold);

  --tu-red: var(--wl-emerald);           /* CTA / brand accent → emerald */
  --tu-red-light: var(--wl-emerald-light);
  --tu-red-lighter: var(--wl-emerald-lighter);
  --tu-yellow: var(--wl-gold);           /* ratings, warnings */
  --tu-yellow-light: #F5EDD2;
  --tu-navy: var(--wl-navy);             /* structural dark */
  --tu-navy-light: var(--wl-navy-light);

  /* Semantic tokens */
  --primary: var(--wl-emerald);
  --primary-light: var(--wl-emerald-light);
  --primary-dark: var(--wl-emerald-dark);
  --primary-lighter: var(--wl-emerald-lighter);
  --primary-fg: #fff;
  --accent: var(--wl-teal);
  --accent-fg: #fff;
  --background: var(--wl-warm-white);
  --foreground: var(--wl-navy);
  --muted: #EFEDE8;
  --muted-fg: #5C5F66;
  --border: #E2DFD8;
  --card: #ffffff;
  --card-fg: var(--wl-navy);
  --heading: var(--wl-navy);
  --destructive: #C53030;
  --success: #16A34A;
  --link: var(--wl-teal);
  --radius: 8px;
  --radius-sm: 8px;
  --radius-lg: 8px;
  --radius-xl: 8px;
  --shadow-sm: 0 1px 3px rgba(27,42,73,0.06), 0 1px 2px rgba(27,42,73,0.04);
  --shadow-md: 0 4px 8px rgba(27,42,73,0.08), 0 2px 4px rgba(27,42,73,0.04);
  --shadow-lg: 0 12px 24px rgba(27,42,73,0.10);
}

/* === Base & Typography System === */
* { box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.9375rem;  /* 15px base */
  line-height: 1.6;
  background-color: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.3; margin-bottom: 0.75rem; }
h2 { font-size: 1.5rem;  font-weight: 700; line-height: 1.3; margin-bottom: 0.5rem; }
h3 { font-size: 1.25rem; font-weight: 700; line-height: 1.35; margin-bottom: 0.5rem; }
h4 { font-size: 1.0625rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.375rem; }
h5 { font-size: 0.9375rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.25rem; }
h6 { font-size: 0.875rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.25rem; }
h1, h2, h3, h4, h5, h6 {
  color: var(--heading);
  letter-spacing: -0.01em;
}
p { margin-bottom: 0.5rem; }
small, .small { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }

/* === Lucide Icon Defaults === */
[data-lucide] {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  display: inline-block;
  stroke-width: 2;
}

/* === Override Bootstrap Primary === */
.btn-primary {
  background-color: var(--tu-red) !important;
  border-color: var(--tu-red) !important;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--tu-red-light) !important;
  border-color: var(--tu-red-light) !important;
}
.btn-outline-primary {
  color: var(--tu-red) !important;
  border-color: var(--tu-red) !important;
}
.btn-outline-primary:hover {
  background-color: var(--tu-red) !important;
  border-color: var(--tu-red) !important;
  color: var(--primary-fg) !important;
}
.btn-success {
  background-color: var(--success) !important;
  border-color: var(--success) !important;
}
.text-primary { color: var(--tu-red) !important; }
.bg-primary { background-color: var(--tu-red) !important; }
a { color: var(--link); }
a:hover { color: var(--wl-teal-light); }
.badge.bg-primary { background-color: var(--tu-red) !important; }
.progress-bar { background-color: var(--tu-red) !important; }

/* === Navbar (tu.ac.th Style — Dark Navy) === */
#mainNav {
  background: var(--tu-navy) !important;
  border-bottom: 3px solid var(--tu-red);
  padding: 0;
  height: 60px;
  z-index: 1030;
  backdrop-filter: none;
}
#mainNav .container {
  max-width: 1280px;
  height: 100%;
  display: flex;
  align-items: center;
}
#mainNav .navbar-brand {
  color: #fff !important;
  font-size: 1.125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--tu-red);
  color: white;
  font-size: 1.1rem;
}
/* Brand logo rendered from /logo.svg, tinted white via mask so it reads on the emerald badge */
.brand-icon .brand-logo {
  display: block;
  width: 70%;
  height: 70%;
  background-color: currentColor;
  -webkit-mask: url('/logo.svg') center / contain no-repeat;
  mask: url('/logo.svg') center / contain no-repeat;
}
#mainNav .nav-link {
  color: rgba(255,255,255,0.7) !important;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem !important;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
#mainNav .nav-link:hover {
  color: #fff !important;
  background: rgba(255,255,255,0.1);
}
#mainNav .nav-link.text-warning {
  color: var(--tu-yellow) !important;
  background: rgba(245,179,0,0.1);
}
#mainNav .nav-link.text-warning:hover {
  background: rgba(245,179,0,0.2);
}
.navbar-toggler {
  border-color: rgba(255,255,255,0.2) !important;
}
.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.8)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* === Mobile Drawer (Slide from Right) === */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}
.drawer-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 300px;
  max-width: 85vw;
  background: var(--tu-navy);
  z-index: 1050;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
  border-left: 3px solid var(--tu-red);
}
.mobile-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  min-height: 64px;
}
.drawer-brand {
  display: flex;
  align-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}
.drawer-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all 0.15s;
  line-height: 1;
}
.drawer-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}
.drawer-close [data-lucide] {
  width: 20px;
  height: 20px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.drawer-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.drawer-nav .nav-item {
  width: 100%;
}
.drawer-nav .nav-link {
  display: flex !important;
  align-items: center;
  gap: 0.6rem;
  color: rgba(255,255,255,0.8) !important;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.7rem 1rem !important;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  width: 100%;
}
.drawer-nav .nav-link:hover,
.drawer-nav .nav-link.active {
  color: #fff !important;
  background: rgba(255,255,255,0.1) !important;
}
.drawer-nav .nav-link [data-lucide] {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.75;
}
/* Avatar row in drawer */
.drawer-nav .nav-link .avatar-circle {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}
/* Dropdown in drawer — flatten it */
.drawer-nav .dropdown-toggle::after {
  display: none;
}
.drawer-nav .dropdown-menu {
  position: static !important;
  transform: none !important;
  background: rgba(255,255,255,0.07);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: none;
  padding: 0.25rem 0;
  margin-top: 0.25rem;
  display: none;
}
.drawer-nav .dropdown.open .dropdown-menu {
  display: block;
}
.drawer-nav .dropdown-item {
  color: rgba(255,255,255,0.75) !important;
  font-size: 0.875rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-sm);
}
.drawer-nav .dropdown-item:hover {
  background: rgba(255,255,255,0.1) !important;
  color: #fff !important;
}
.drawer-nav .dropdown-item.text-danger {
  color: #ff8a8a !important;
}
.drawer-nav .dropdown-divider,
.drawer-nav .dropdown-header { display: none; }

.drawer-divider {
  border-color: rgba(255,255,255,0.12);
  margin: 0.5rem 0.25rem;
}

/* Notification bell in drawer */
.drawer-nav .notification-bell-btn {
  width: 100%;
  justify-content: flex-start;
  gap: 0.6rem;
  color: rgba(255,255,255,0.8);
  font-size: 0.9375rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
}
.drawer-nav .notification-bell-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* === Avatar Dropdown === */
.avatar-toggle {
  padding: 0.25rem !important;
  display: flex !important;
  align-items: center;
}
.avatar-toggle::after {
  display: none;
}
.avatar-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--tu-red);
  border: 2px solid rgba(255,255,255,0.3);
  transition: border-color 0.15s;
}
.avatar-toggle:hover .avatar-circle {
  border-color: var(--tu-yellow);
}
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-fallback {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
}
.avatar-dropdown {
  width: 224px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem 0;
  margin-top: 0.5rem !important;
}
.avatar-dropdown .dropdown-header {
  padding: 0.5rem 1rem;
  line-height: 1.4;
}
.avatar-dropdown .dropdown-header .fw-semibold {
  font-size: 0.875rem;
}
.avatar-dropdown .dropdown-header small {
  font-size: 0.75rem;
}
.avatar-dropdown .dropdown-item {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  color: var(--foreground);
}
.avatar-dropdown .dropdown-item:hover {
  background: var(--muted);
}
.avatar-dropdown .dropdown-item.text-danger:hover {
  background: #fef2f2;
}
.avatar-dropdown .dropdown-divider {
  margin: 0.25rem 0;
  border-color: var(--border);
}

