/* ====================================================================
   DESIGN SYSTEM & VARIABLES
   ==================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Light Theme Variables */
  --bg-primary: #f4f7f6;
  --bg-secondary: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.7);
  --border-glass: rgba(255, 255, 255, 0.4);
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  
  --primary: #00796b;
  --primary-hover: #005b50;
  --primary-light: rgba(0, 121, 107, 0.1);
  --secondary: #0284c7;
  
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  
  --shadow-sm: 0 2px 8px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 16px -6px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.08);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* Dark Theme Variables */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-glass: rgba(30, 41, 59, 0.7);
  --border-glass: rgba(255, 255, 255, 0.05);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-light: #64748b;
  
  --primary: #0d9488;
  --primary-hover: #14b8a6;
  --primary-light: rgba(13, 148, 136, 0.2);
  --secondary: #38bdf8;
  
  --success: #34d399;
  --success-light: rgba(52, 211, 153, 0.15);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.15);
  --danger: #f87171;
  --danger-light: rgba(248, 113, 113, 0.15);
  
  --shadow-sm: 0 2px 8px -1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 16px -6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.4);
}

/* ====================================================================
   BASE STYLES & RESET
   ==================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* ====================================================================
   HEADER & HERO SECTION
   ==================================================================== */
header {
  background: linear-gradient(135deg, #005b50 0%, #0f172a 100%);
  padding: 3rem 2rem;
  border-radius: var(--radius-lg);
  color: #ffffff;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.header-content {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 2rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo-container {
  font-size: 3rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 1rem;
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.brand-title h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #a5f3fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-title p {
  color: #94a3b8;
  font-size: 1rem;
  margin-top: 0.25rem;
}

.theme-switch {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #ffffff;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.theme-switch:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* ====================================================================
   STATS METRICS PANELS
   ==================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.metric-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
}

.metric-info {
  display: flex;
  flex-direction: column;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Colors for specific metric categories */
.total-card .metric-icon {
  background: var(--primary-light);
  color: var(--primary);
}
.co-card .metric-icon {
  background: var(--success-light);
  color: var(--success);
}
.thieu-card .metric-icon {
  background: var(--warning-light);
  color: var(--warning);
}
.ngoai-card .metric-icon {
  background: var(--danger-light);
  color: var(--danger);
}

/* ====================================================================
   FILTER AND CONTROLS SECTION
   ==================================================================== */
.controls-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transition: var(--transition);
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.filters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: center;
}

.select-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.select-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.filter-select {
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

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

.button-group {
  display: flex;
  gap: 0.75rem;
}

.btn {
  padding: 0.75rem 1.25rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-primary);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(239, 108, 108, 0.2);
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
  background: var(--success);
  color: #ffffff;
}

/* ====================================================================
   DATA PRESENTATION & VIEW TOGGLE
   ==================================================================== */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.results-count {
  font-weight: 500;
  color: var(--text-secondary);
}

.view-toggles {
  display: flex;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

.toggle-btn {
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.toggle-btn.active {
  background: var(--primary);
  color: #ffffff;
}

/* --- GRID VIEW LAYOUT --- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.program-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
  cursor: pointer;
}

.program-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.card-top {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.card-section {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 3.2em;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-glass);
}

/* Badges styling */
.badge {
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

/* --- TABLE VIEW LAYOUT --- */
.table-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  display: none; /* Controlled via JS class */
}

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

.data-table th, .data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-glass);
}

.data-table th {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
}

.data-table tr {
  cursor: pointer;
  transition: var(--transition);
}

.data-table tr:hover {
  background: rgba(0, 121, 107, 0.03);
}

.col-action {
  text-align: right;
}

/* ====================================================================
   PAGINATION CONTROL
   ==================================================================== */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
  flex-wrap: wrap;
}

.page-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.page-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ====================================================================
   MODAL DETAIL VIEW
   ==================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none; /* Displayed via class active */
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.25s ease;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.75rem 2rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}

.modal-title-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-close {
  background: var(--bg-primary);
  border: none;
  font-size: 1.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--danger-light);
  color: var(--danger);
  transform: rotate(90deg);
}

.modal-body {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  background: var(--bg-primary);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
}

.detail-value {
  font-weight: 500;
  color: var(--text-primary);
}

.note-box {
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.95rem;
}

.note-box.review-note {
  border-left-color: var(--warning);
  background: var(--warning-light);
}

.actions-section {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--border-glass);
}

.actions-section .btn {
  flex: 1;
  min-width: 180px;
}

/* ====================================================================
   DOCKING UPLOADER / SIMULATED COMPONENT
   ==================================================================== */
.uploader-box {
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  background: var(--bg-primary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.uploader-box:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.uploader-icon {
  font-size: 2rem;
  color: var(--primary);
}

.uploader-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ====================================================================
   ANIMATIONS & MEDIA QUERIES
   ==================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@media(max-width: 768px) {
  .container {
    padding: 1rem;
  }
  header {
    padding: 2rem 1rem;
    border-radius: var(--radius-md);
  }
  .brand-section {
    flex-direction: column;
    text-align: center;
  }
  .filters-row {
    grid-template-columns: 1fr;
  }
  .actions-section {
    flex-direction: column;
  }
  #aiChatWindow {
    right: 16px;
    bottom: 80px;
    width: calc(100vw - 32px);
    height: 480px;
  }
}

/* ====================================================================
   AI CHATBOT WIDGET STYLES
   ==================================================================== */

/* Chatbot Floating Trigger Button */
#aiChatTrigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 121, 107, 0.3);
  z-index: 999;
  transition: var(--transition);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

#aiChatTrigger:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 12px 40px rgba(0, 121, 107, 0.4);
}

.pulse-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background-color: var(--danger);
  border-radius: 50%;
  border: 2px solid #ffffff;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Chatbot Main Window Container */
#aiChatWindow {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 560px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  transform: translateY(30px) scale(0.9);
  opacity: 0;
  pointer-events: none;
}

#aiChatWindow.active {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Chat Header */
.ai-chat-header {
  background: linear-gradient(135deg, var(--primary) 0%, #0f172a 100%);
  color: #ffffff;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-chat-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-chat-brand i {
  font-size: 1.4rem;
  color: var(--secondary);
}

.ai-chat-title h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.ai-chat-title span {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}

.ai-chat-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ai-chat-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  opacity: 0.8;
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1rem;
  transition: var(--transition);
}

.ai-chat-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Chat API Settings Panel */
.ai-chat-settings {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-glass);
  padding: 0.75rem 1rem;
  display: none;
  animation: slideDown 0.25s ease;
}

.ai-settings-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.ai-mode-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ai-mode-btn {
  flex: 1;
  padding: 0.4rem;
  font-size: 0.75rem;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.ai-mode-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.ai-key-input-container {
  display: flex;
  gap: 0.5rem;
}

.ai-key-input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
}

/* Chat Messages Area */
.ai-chat-messages {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.ai-message {
  display: flex;
  gap: 0.75rem;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

.ai-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-message.bot {
  align-self: flex-start;
}

.ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.ai-message.user .ai-msg-avatar {
  background: var(--secondary);
  color: #ffffff;
}

.ai-msg-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
}

.ai-message.user .ai-msg-bubble {
  background: var(--primary);
  color: #ffffff;
  border-top-right-radius: 2px;
}

.ai-message.bot .ai-msg-bubble {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-top-left-radius: 2px;
  border: 1px solid var(--border-glass);
}

/* Chat Program links and formatting inside bubbles */
.ai-msg-bubble p {
  margin-bottom: 0.4rem;
}

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

.ai-msg-bubble ul, .ai-msg-bubble ol {
  margin-left: 1.2rem;
  margin-bottom: 0.4rem;
}

.chat-prog-link {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px dashed var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  margin: 0.2rem 0;
  cursor: pointer;
  transition: var(--transition);
}

.chat-prog-link:hover {
  background: var(--primary);
  color: #ffffff;
  border-style: solid;
}

.chat-prog-status {
  font-size: 0.75rem;
  padding: 0.05rem 0.3rem;
  border-radius: var(--radius-sm);
  margin-left: 0.25rem;
  font-weight: 600;
}

.chat-status-co {
  background: var(--success-light);
  color: var(--success);
}

.chat-status-thieu {
  background: var(--warning-light);
  color: var(--warning);
}

/* Typing Indicator Animation */
.typing-dots {
  display: flex;
  gap: 0.25rem;
  padding: 0.4rem 0.2rem;
  align-items: center;
}

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

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-wave {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Chat Chips Suggestions */
.ai-chat-chips {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  overflow-x: auto;
  white-space: nowrap;
  background: transparent;
  scrollbar-width: none; /* Hide scrollbar for Firefox */
}

.ai-chat-chips::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome/Safari */
}

.ai-chip {
  padding: 0.35rem 0.75rem;
  background: var(--bg-secondary);
  color: var(--primary);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.ai-chip:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* Chat Input Bar */
.ai-chat-input-area {
  padding: 0.75rem 1rem 1rem 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-glass);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ai-chat-input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  font-size: 0.85rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.ai-chat-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.ai-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.ai-chat-send:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.ai-chat-send:disabled {
  background: var(--text-light);
  cursor: not-allowed;
  transform: none;
}

/* ====================================================================
   FULLSCREEN DOCUMENT viewer (MOBILE FRIENDLY)
   ==================================================================== */
.fullscreen-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.98);
  z-index: 2100;
  display: none;
  flex-direction: column;
  overflow: hidden;
  color: #f8fafc;
  font-family: 'Outfit', sans-serif;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  animation: fadeIn 0.2s ease;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(30, 41, 59, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  z-index: 2110;
  flex-shrink: 0;
  gap: 1rem;
}

.viewer-back-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.viewer-back-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
}

.viewer-title-section {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.viewer-doc-title {
  font-size: 1.1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 500px;
  margin: 0 auto;
  color: #ffffff;
}

.viewer-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.viewer-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  text-decoration: none;
}

.viewer-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.05);
  color: #ffffff;
}

.viewer-body-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  padding: 1.5rem;
  position: relative;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  width: 100%;
}

/* PDF Rendering Styles */
.viewer-body-content canvas {
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  background-color: #ffffff;
  max-width: 100%;
  height: auto !important;
  margin: auto;
  transform-origin: center top;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.viewer-body-content img {
  max-width: 95%;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-sm);
  margin: auto;
  transition: transform 0.2s ease;
}

.viewer-body-content pre {
  background: #0f172a;
  color: #38bdf8;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: left;
  max-width: 850px;
  width: 100%;
  height: 90%;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  white-space: pre-wrap;
  word-break: break-all;
  margin: auto;
}

/* Controls Bar for PDF Paging and Zoom */
.pdf-controls-bar {
  display: none; /* Display flex when PDF active */
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  background: rgba(30, 41, 59, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 2110;
  flex-shrink: 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
  flex-wrap: wrap;
}

.pdf-control-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #ffffff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
}

.pdf-control-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #ffffff;
  transform: scale(1.05);
}

.pdf-control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.03);
}

.pdf-page-indicator {
  font-size: 0.95rem;
  font-weight: 500;
  min-width: 110px;
  text-align: center;
  color: #e2e8f0;
}

.pdf-zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: 1.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  padding-left: 1.5rem;
}

.pdf-zoom-text {
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 50px;
  text-align: center;
  color: #94a3b8;
}

/* Mobile specific styling override for Fullscreen Viewer */
@media (max-width: 768px) {
  .viewer-header {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  
  .viewer-back-btn {
    padding: 0.5rem;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    justify-content: center;
  }
  
  .viewer-back-btn span {
    display: none; /* Hide back text on phone screens */
  }
  
  .viewer-doc-title {
    font-size: 0.95rem;
    max-width: 180px;
  }
  
  .viewer-btn {
    width: 38px;
    height: 38px;
    font-size: 0.9rem;
  }
  
  .viewer-body-content {
    padding: 1rem 0.5rem;
  }
  
  .pdf-controls-bar {
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
  }
  
  .pdf-zoom-controls {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
    justify-content: center;
    margin-top: 0.25rem;
  }

  .pdf-control-btn {
    width: 38px;
    height: 38px;
  }
}

/* ====================================================================
   DATABASE SYNCHRONIZATION STATUS STYLES
   ==================================================================== */
.sync-success-status {
  background: var(--success-light) !important;
  color: var(--success) !important;
  border: 1px solid var(--success);
}

.sync-error-status {
  background: var(--danger-light) !important;
  color: var(--danger) !important;
  border: 1px solid var(--danger);
}

.sync-working-status {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border: 1px dashed var(--primary);
}



