/* ==========================================
   MASA - Premium Dark Glassmorphism Design
   ========================================== */

:root {
  /* Colors */
  --bg-app: #080c14;
  --bg-sidebar: #0b111e;
  --bg-card: rgba(17, 25, 40, 0.75);
  --bg-card-hover: rgba(26, 38, 60, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(59, 130, 246, 0.3);
  
  --accent-blue: #3b82f6;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-inverse: #0f172a;
  
  /* Fonts */
  --font-family: 'Outfit', 'Sarabun', sans-serif;
  
  /* Borders & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.25);
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base resets & styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(239, 68, 68, 0.06) 0px, transparent 50%);
}

button {
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  outline: none;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar Styling */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-red));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

.logo-text h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1.2;
  background: linear-gradient(to right, #ffffff, #e2e8f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-menu {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 15px;
  transition: var(--transition-fast);
}

.nav-item i {
  font-size: 20px;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), transparent);
  color: var(--accent-blue);
  border-left: 3px solid var(--accent-blue);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
}

.user-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-dot.warning {
  background-color: var(--accent-yellow);
  box-shadow: 0 0 8px var(--accent-yellow);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  height: 70px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(8, 12, 20, 0.5);
  backdrop-filter: blur(10px);
}

.top-bar h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
}

.quick-stats {
  display: flex;
  gap: 16px;
}

.stat-badge {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  display: flex;
  gap: 6px;
}

.stat-badge .stat-label {
  color: var(--text-muted);
}

.stat-badge .stat-val {
  color: var(--accent-red);
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Tab Panels */
.tab-panel {
  display: none;
  height: 100%;
  animation: fadeIn 0.3s ease-out;
}

.tab-panel.active {
  display: block;
}

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

/* ==========================================
   CHAT LAYOUT & MESSAGES
   ========================================== */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  gap: 16px;
  max-width: 85%;
  align-self: flex-start;
}

.message.student-msg {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.avatar.coordinator {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
}

.avatar.student {
  background: #374151;
  color: var(--text-main);
}

.msg-bubble {
  padding: 16px;
  border-radius: var(--radius-md);
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  font-size: 15px;
  color: var(--text-main);
  word-break: break-word;
}

.message.student-msg .msg-bubble {
  background-color: var(--accent-blue);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* System Welcome Msg list formatting */
.msg-bubble h3 {
  font-size: 17px;
  margin-bottom: 8px;
  color: var(--accent-blue);
}

.msg-bubble p {
  margin-bottom: 8px;
}

.msg-bubble ul {
  margin-left: 20px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.api-key-hint {
  font-size: 13px;
  color: var(--accent-yellow);
  background-color: rgba(245, 158, 11, 0.1);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-yellow);
}

/* Routing Info Banner inside message response */
.routing-info {
  margin-top: 10px;
  padding: 8px 12px;
  background-color: rgba(139, 92, 246, 0.08);
  border: 1px dashed rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #c084fc;
}

.routing-info strong {
  color: white;
}

/* Typing Indicator */
.typing-indicator-wrapper {
  display: none;
  gap: 16px;
  padding: 24px;
  align-items: center;
}

.typing-bubble {
  padding: 12px 18px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.typing-bubble .dots {
  display: flex;
  gap: 4px;
}

.typing-bubble .dots span {
  width: 6px;
  height: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-bubble .dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-bubble .dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.spinner {
  animation: spin 1s infinite linear;
}

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

/* Chat Input Bar */
.chat-input-wrapper {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  background-color: rgba(11, 17, 30, 0.4);
}

.chat-input-form {
  display: flex;
  gap: 12px;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: var(--transition-fast);
}

.chat-input-form:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
}

.chat-input-form textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 15px;
  resize: none;
  padding: 6px 4px;
  max-height: 120px;
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition-fast);
}

.btn-send:hover {
  background-color: #2563eb;
  transform: scale(1.05);
}

/* Markdown Rendering Customization */
.markdown-body pre {
  background-color: #0d1117;
  padding: 14px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.markdown-body code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  color: #f43f5e;
  background-color: rgba(244, 63, 94, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.markdown-body pre code {
  color: #e2e8f0;
  background-color: transparent;
  padding: 0;
  font-size: 13px;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin-top: 16px;
  margin-bottom: 8px;
  color: var(--text-main);
  font-weight: 600;
}

.markdown-body p {
  margin-bottom: 12px;
}

.markdown-body ul, .markdown-body ol {
  margin-left: 20px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
  font-size: 14px;
}

.markdown-body th {
  background-color: rgba(255, 255, 255, 0.03);
}

/* ==========================================
   ACTIVE RECALL (FLASHCARDS)
   ========================================== */
.recall-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 24px;
}

.recall-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-row {
  display: flex;
  gap: 16px;
}

.stat-card {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  text-align: center;
  min-width: 140px;
}

.stat-card h3 {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-blue);
  line-height: 1.2;
}

.stat-card.urgent h3 {
  color: var(--accent-red);
}

.stat-card span {
  font-size: 12px;
  color: var(--text-muted);
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-fast);
}

.btn-primary {
  background-color: var(--accent-blue);
  color: white;
}

.btn-primary:hover {
  background-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.btn-danger {
  background-color: var(--accent-red);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.flashcard-arena {
  flex: 1;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 30px;
  backdrop-filter: blur(20px);
}

.arena-empty-state {
  text-align: center;
  color: var(--text-muted);
}

.arena-empty-state i {
  font-size: 64px;
  color: var(--accent-green);
  margin-bottom: 16px;
}

.arena-empty-state h3 {
  color: var(--text-main);
  margin-bottom: 8px;
}

.card-play-wrapper {
  width: 100%;
  max-width: 550px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.card-subject-tag {
  background-color: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent-blue);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Perspective card flip animation container */
.flashcard {
  perspective: 1000px;
  width: 100%;
  height: 280px;
  cursor: pointer;
  position: relative;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.card-side {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.card-front {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
}

.card-front::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.3;
}

.card-back {
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(31, 41, 55, 0.95));
  transform: rotateY(180deg);
}

.card-hint {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.card-text {
  font-size: 24px;
  font-weight: 600;
  color: white;
}

.card-answer-content {
  font-size: 16px;
  text-align: left;
  width: 100%;
  color: #e2e8f0;
  overflow-y: auto;
  max-height: 160px;
}

.click-to-reveal {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sm2-controls {
  width: 100%;
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.sm2-controls p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.rating-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
}

.btn-rating {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.02);
  transition: var(--transition-fast);
}

.btn-rating strong {
  font-size: 18px;
  margin-bottom: 2px;
}

.btn-rating span {
  font-size: 9px;
  color: var(--text-muted);
}

.btn-rating:hover {
  transform: translateY(-3px);
  color: white;
}

.rate-0:hover { background-color: rgba(239, 68, 68, 0.2); border-color: var(--accent-red); }
.rate-1:hover { background-color: rgba(245, 158, 11, 0.2); border-color: var(--accent-yellow); }
.rate-2:hover { background-color: rgba(245, 158, 11, 0.2); border-color: var(--accent-yellow); }
.rate-3:hover { background-color: rgba(59, 130, 246, 0.2); border-color: var(--accent-blue); }
.rate-4:hover { background-color: rgba(16, 185, 129, 0.2); border-color: var(--accent-green); }
.rate-5:hover { background-color: rgba(16, 185, 129, 0.25); border-color: var(--accent-green); }

/* Modal Styles */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.wide {
  max-width: 750px;
}

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

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.btn-close {
  font-size: 20px;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.btn-close:hover {
  color: white;
}

form {
  padding: 24px;
}

.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.form-group select, .form-group input {
  padding: 12px;
  border-radius: var(--radius-md);
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  outline: none;
  font-family: var(--font-family);
  font-size: 14px;
}

.form-group select:focus, .form-group input:focus {
  border-color: var(--accent-blue);
}

.form-help {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================
   QUIZ ARENA
   ========================================== */
.quiz-container {
  height: 100%;
}

.quiz-setup {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.quiz-setup-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 550px;
  text-align: center;
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

.quiz-setup-card::after {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 150px; height: 150px;
  background-color: rgba(59, 130, 246, 0.05);
  border-radius: 50%;
  filter: blur(20px);
}

.icon-decor {
  font-size: 52px;
  color: var(--accent-blue);
  margin-bottom: 16px;
  display: inline-block;
}

.quiz-setup-card h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.quiz-setup-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.quiz-mode-actions {
  display: flex;
  gap: 16px;
  margin-top: 24px;
  justify-content: center;
}

.quiz-play-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  backdrop-filter: blur(20px);
  max-width: 700px;
  margin: 0 auto;
}

.quiz-play-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.quiz-tag {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}

.quiz-source-badge {
  background-color: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #c084fc;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
}

.quiz-question-section h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  line-height: 1.4;
}

.quiz-options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.quiz-option-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 15px;
  transition: var(--transition-fast);
}

.quiz-option-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.quiz-option-btn.selected {
  border-color: var(--accent-blue);
  background-color: rgba(59, 130, 246, 0.1);
  color: white;
}

.quiz-option-idx {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.quiz-option-btn.selected .quiz-option-idx {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
}

.quiz-feedback-box {
  margin-top: 24px;
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.01);
  animation: fadeIn 0.4s ease-out;
}

.feedback-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.feedback-indicator.correct {
  color: var(--accent-green);
}

.feedback-indicator.incorrect {
  color: var(--accent-red);
}

.feedback-content {
  font-size: 14px;
  color: var(--text-muted);
}

/* ==========================================
   CURRICULUM / SUBJECTS GRID
   ========================================== */
.subjects-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.subjects-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 20px;
}

.subjects-search-bar i {
  font-size: 20px;
  color: var(--text-muted);
}

.subjects-search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: white;
  font-family: var(--font-family);
  font-size: 15px;
}

.semester-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--accent-blue);
  margin-top: 24px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.subject-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.subject-card:hover {
  background-color: var(--bg-card-hover);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}

.sub-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.sub-code {
  font-family: 'Outfit';
  font-weight: 700;
  font-size: 16px;
  color: white;
}

.sub-credits {
  font-size: 11px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
}

.sub-name-th {
  font-size: 14px;
  color: var(--text-main);
  font-weight: 500;
  margin-bottom: 2px;
}

.sub-name-en {
  font-size: 12px;
  color: var(--text-muted);
}

.sub-footer {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sub-domain-badge {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.domain-programming { background-color: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.domain-network { background-color: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }
.domain-database { background-color: rgba(139, 92, 246, 0.1); color: var(--accent-purple); }
.domain-business { background-color: rgba(245, 158, 11, 0.1); color: var(--accent-yellow); }
.domain-language { background-color: rgba(236, 72, 153, 0.1); color: #ec4899; }
.domain-data_ai { background-color: rgba(239, 68, 68, 0.1); color: var(--accent-red); }

.btn-card-action {
  font-size: 12px;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition-fast);
}

.btn-card-action:hover {
  text-decoration: underline;
}

/* ==========================================
   HISTORY TABLE LOGS
   ========================================== */
.history-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

.history-table-wrapper {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.history-table th, .history-table td {
  padding: 16px 24px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-color);
}

.history-table th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 600;
}

.history-table tbody tr {
  transition: var(--transition-fast);
}

.history-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.history-detail-content {
  padding: 24px;
  max-height: 480px;
  overflow-y: auto;
}

.detail-meta {
  display: flex;
  gap: 24px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 13px;
}

.detail-block {
  margin-bottom: 24px;
}

.detail-block h4 {
  font-size: 14px;
  color: var(--accent-blue);
  margin-bottom: 10px;
}

.detail-query {
  background-color: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 14px;
  white-space: pre-wrap;
  color: white;
}

.detail-response {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

/* ==========================================
   SETTINGS PANEL & UTILITIES
   ========================================== */
.settings-container {
  display: flex;
  justify-content: center;
}

.settings-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 600px;
  width: 100%;
  backdrop-filter: blur(20px);
}

.settings-card h2 {
  font-size: 22px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.input-password-wrapper {
  position: relative;
  display: flex;
}

.input-password-wrapper input {
  flex: 1;
  padding-right: 48px;
}

.btn-toggle-visibility {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 20px;
}

.btn-toggle-visibility:hover {
  color: white;
}

.settings-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 32px;
}

.api-guide-section {
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
}

.api-guide-section h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.api-guide-section ol {
  margin-left: 20px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-guide-section a {
  color: var(--accent-blue);
  text-decoration: none;
}

.api-guide-section a:hover {
  text-decoration: underline;
}

/* Response Tagging Colors for Routing information */
.spec-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  margin-right: 6px;
  margin-top: 4px;
}

/* ==========================================
   LOGIN SCREEN & USER ADMIN PANEL
   ========================================== */
.login-container {
  display: flex;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(239, 68, 68, 0.1) 0px, transparent 50%);
  align-items: center;
  justify-content: center;
  z-index: 2000;
  overflow-y: auto;
  padding: 24px;
}

.login-card {
  background-color: var(--bg-card);
  backdrop-filter: blur(25px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 40px;
  box-shadow: var(--shadow-md);
  position: relative;
}

.login-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-red)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.2;
}

.brand-large {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon-large {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-red));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: white;
  margin: 0 auto 16px auto;
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.45);
}

.brand-large h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(to right, #ffffff, #e2e8f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.brand-large span {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.auth-switch-text {
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch-text span {
  color: var(--accent-blue);
  cursor: pointer;
  text-decoration: underline;
  font-weight: 500;
}

.auth-switch-text span:hover {
  color: #60a5fa;
}

.user-info-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.user-details strong {
  font-size: 14px;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details span {
  font-size: 11px;
  color: var(--accent-blue);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.btn-logout-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition-fast);
}

.btn-logout-icon:hover {
  background-color: var(--accent-red);
  color: white;
  transform: scale(1.05);
}
