:root {
  --primary: #1e3a8a;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --dept-a: #2563eb;
  --dept-b: #059669;
  --dept-c: #d97706;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Sarabun", "Noto Sans Thai", "Segoe UI", Roboto, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
}

/* Nav Header */
.top-nav {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 1.8rem;
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

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

.nav-links {
  display: flex;
  gap: 12px;
}

.nav-link {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
  background: #334155;
  color: #fff;
  border-color: #475569;
}

/* Common Components */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-a { background: #dbeafe; color: #1d4ed8; }
.badge-b { background: #d1fae5; color: #047857; }
.badge-c { background: #fef3c7; color: #b45309; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

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

.btn-primary {
  background: #2563eb;
  color: #fff;
}
.btn-primary:hover {
  background: #1d4ed8;
}

.btn-success {
  background: #10b981;
  color: #fff;
}
.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: #f59e0b;
  color: #1e293b;
}
.btn-warning:hover {
  background: #d97706;
}

.btn-secondary {
  background: #334155;
  color: #f1f5f9;
}
.btn-secondary:hover {
  background: #475569;
}

/* Display Screen (TV) */
.display-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  padding: 24px;
  height: calc(100vh - 80px);
}

.current-card {
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.current-card.calling {
  animation: callGlow 1.2s infinite alternate ease-in-out;
}

@keyframes callGlow {
  0% { border-color: #2563eb; box-shadow: 0 0 25px rgba(37, 99, 235, 0.4); }
  100% { border-color: #60a5fa; box-shadow: 0 0 50px rgba(96, 165, 250, 0.8); }
}

.queue-label {
  font-size: 1.6rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.queue-number-huge {
  font-size: 8rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  line-height: 1.1;
  margin: 12px 0;
  text-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.dept-banner-large {
  font-size: 2.2rem;
  font-weight: 700;
  padding: 12px 32px;
  border-radius: 16px;
  margin-top: 16px;
}

.history-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 28px;
  display: flex;
  flex-direction: column;
}

.history-header {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.history-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.3s ease;
}

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

.history-num {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
}

.history-dept {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Caller Panel */
.panel-container {
  max-width: 800px;
  margin: 32px auto;
  padding: 0 20px;
}

.control-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 32px;
  margin-bottom: 24px;
}

.grid-departments {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 20px 0;
}

.dept-select-btn {
  background: #0f172a;
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 20px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
}

.dept-select-btn:hover {
  border-color: #64748b;
}

.dept-select-btn.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.dept-letter {
  font-size: 2.4rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.dept-name {
  font-size: 0.95rem;
  color: #cbd5e1;
  font-weight: 600;
}

.call-actions-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 14px;
  margin-top: 24px;
}

/* Audio Banner Notice */
.audio-gate {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2563eb;
  color: white;
  padding: 14px 28px;
  border-radius: 9999px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(37,99,235,0.4);
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
}
