:root {
  --bg-dark: #090d16;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(28, 36, 56, 0.85);
  --bg-input: rgba(14, 19, 31, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.35);
  
  --primary: #6366f1;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --cyan-glow: #06b6d4;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', 'Noto Sans Lao', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.6;
}

/* Atmospheric Glow Background */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #6366f1 0%, rgba(99, 102, 241, 0) 70%);
  top: -100px;
  left: -100px;
}

.orb-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #06b6d4 0%, rgba(6, 182, 212, 0) 70%);
  bottom: -50px;
  right: -50px;
}

/* App Wrapper */
.app-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

/* HEADER */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(10, 14, 23, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
}

.header-left .brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: #fff;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag-version {
  font-size: 10px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 2px 6px;
  border-radius: var(--radius-pill);
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

/* NAV TABS */
.nav-tabs {
  display: flex;
  background: rgba(18, 24, 38, 0.6);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
}

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

.nav-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}

/* HEADER RIGHT */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 4px 14px 4px 6px;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.profile-chip:hover {
  border-color: var(--border-glow);
  background: var(--bg-card-hover);
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-info-text {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.user-major {
  font-size: 10px;
  color: var(--cyan-glow);
}

.api-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.api-chip:hover {
  background: rgba(16, 185, 129, 0.2);
}

.api-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

/* MAIN BODY & VIEWS */
.main-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
}

.view-panel {
  display: none;
  flex: 1;
  height: 100%;
  overflow-y: auto;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
}

/* CHAT VIEW */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  gap: 12px;
}

.principle-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 12px;
}

.banner-icon {
  font-size: 20px;
}

.banner-content {
  color: #cbd5e1;
}

.banner-content strong {
  color: #a5b4fc;
}

.banner-content span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

/* CHAT MESSAGES */
.messages-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 6px;
  scroll-behavior: smooth;
}

.message-bubble {
  max-width: 85%;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  position: relative;
  animation: fadeIn 0.3s ease-out;
}

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

.user-message {
  align-self: flex-end;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
}

.assistant-message {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  border-bottom-left-radius: 4px;
  color: var(--text-main);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11px;
  gap: 12px;
}

.assistant-badge {
  font-weight: 700;
  color: #818cf8;
}

.source-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.verified-tag {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.ai-tag {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

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

.bubble-content p:last-child {
  margin-bottom: 0;
}

.bubble-content ul, .bubble-content ol {
  margin-left: 20px;
  margin-bottom: 8px;
}

.bubble-content li {
  margin-bottom: 4px;
}

.bubble-content pre {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  overflow-x: auto;
  margin: 10px 0;
  position: relative;
}

.bubble-content code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.bubble-feedback-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
  color: var(--text-dim);
}

.feedback-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}

.feedback-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* QUICK PROMPTS */
.quick-prompts-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0;
  white-space: nowrap;
}

.quick-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

.prompt-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.prompt-chip:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--border-glow);
  color: var(--text-main);
}

.chip-test {
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

.chip-test:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: var(--rose);
}

/* CHAT INPUT FORM */
.chat-input-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.chat-form textarea::placeholder {
  color: var(--text-dim);
}

.send-btn {
  background: var(--primary-gradient);
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.send-btn:hover {
  transform: scale(1.05);
}

/* SCHEDULE VIEW */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
}

.panel-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.filter-controls {
  display: flex;
  gap: 10px;
}

.input-search, .select-filter {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
}

.input-search:focus, .select-filter:focus {
  border-color: var(--primary);
}

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 14px 16px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge-room {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.badge-verified {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
}

/* ANNOUNCEMENTS VIEW */
.announcements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.announcement-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
  backdrop-filter: blur(12px);
}

.announcement-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

.ann-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.ann-content {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.ann-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 10px;
}

.priority-high {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
}

.priority-medium {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
}

.priority-normal {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
}

/* ADMIN VIEW */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(12px);
}

.card-heading {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-main);
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input, .form-group select, .form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-primary {
  background: var(--primary-gradient);
  border: none;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* MODAL */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

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

.modal-card {
  background: #0f1524;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.close-modal-btn:hover {
  color: var(--text-main);
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-desc a {
  color: #38bdf8;
}

.api-key-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.hint {
  font-size: 11px;
  color: var(--text-dim);
}

.status-summary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
  .app-header {
    flex-wrap: wrap;
    padding: 12px 16px;
  }
  .nav-tabs {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
  .nav-btn span {
    display: none;
  }
  .nav-btn {
    padding: 8px 12px;
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .message-bubble {
    max-width: 95%;
  }
}
