/* ==============================================================================
   TRỢ LÝ ẢO KHĂN QUÀNG ĐỎ - DESIGN SYSTEM & STYLESHEET
   Màu chủ đạo: Đỏ cờ Tổ quốc & Khăn Quàng Đỏ (#D32F2F, #E53935), Vàng sao (#FBC02D)
   Phong cách: Tươi sáng, thân thiện học đường, hiện đại, chuẩn UI/UX
   ============================================================================== */

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

:root {
  --primary: #D32F2F;
  --primary-hover: #B71C1C;
  --primary-light: #FFEBEE;
  --primary-gradient: linear-gradient(135deg, #D32F2F 0%, #E53935 50%, #FF5252 100%);
  
  --secondary: #FBC02D;
  --secondary-hover: #F57F17;
  
  --accent: #1976D2;
  --accent-light: #E3F2FD;
  
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  
  --border: #E2E8F0;
  --border-focus: #D32F2F;
  
  --success: #10B981;
  --success-light: #ECFDF5;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --info: #3B82F6;
  --info-light: #EFF6FF;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
}

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

/* Sidebar Navigation:
   - Ở màn hình chat ở ngoài: Ẩn HOÀN TOÀN menu bên trái.
   - Khi Giáo viên, Admin, Editor đăng nhập (body.staff-logged-in): Menu bên trái để nguyên cố định như ban đầu.
*/
.sidebar {
  display: none !important;
}

.btn-sidebar-toggle,
.btn-sidebar-close,
.sidebar-backdrop {
  display: none !important;
}

/* Với Giáo viên, Admin, Editor đăng nhập: Menu trái vẫn để nguyên cố định */
body.staff-logged-in .sidebar {
  display: flex !important;
  position: static !important;
  width: 280px !important;
  background: #FFFFFF !important;
  border-right: 1px solid var(--border) !important;
  flex-direction: column !important;
  flex-shrink: 0 !important;
  transform: none !important;
  box-shadow: none !important;
  z-index: 10 !important;
  transition: none !important;
}

body.staff-logged-in #guest-brand-logo {
  display: none !important;
}

body.staff-logged-in #admin-view-heading {
  display: block !important;
}

/* Header Brand Identity */
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.header-brand:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.header-logo-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5px;
  box-shadow: 0 2px 8px rgba(18, 6, 69, 0.12), 0 0 0 1.5px rgba(211, 47, 47, 0.25);
  flex-shrink: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.header-brand:hover .header-logo-badge {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(211, 47, 47, 0.25), 0 0 0 2px rgba(211, 47, 47, 0.4);
}

.header-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  display: block;
}

.header-brand-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header-school-name {
  font-size: 13.5px;
  font-weight: 800;
  color: #1E293B;
  letter-spacing: 0.3px;
  line-height: 1.25;
}

.header-app-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

.ai-pill {
  background: linear-gradient(135deg, #D32F2F 0%, #E53935 100%);
  color: #FFFFFF;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 3px rgba(211, 47, 47, 0.3);
}

/* Sidebar Brand Header */
.sidebar-logo-badge {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(18, 6, 69, 0.12), 0 0 0 1.5px rgba(211, 47, 47, 0.2);
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  display: block;
}

.sidebar-school-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #64748B;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.brand-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #FFF5F5 0%, #FFFFFF 100%);
}

.brand-logo {
  width: 44px;
  height: 44px;
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(211, 47, 47, 0.3);
}

.brand-title h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.brand-title p {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

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

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 12px 4px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(211, 47, 47, 0.25);
}

.nav-item .icon {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item .badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.user-panel {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: #FCFCFD;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  border: 2px solid #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-logout:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-page);
}

/* Top App Header */
.top-header {
  height: 64px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}

.page-heading h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-secondary-action {
  padding: 8px 14px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

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

/* Page Content View */
.content-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: none;
}

.content-view.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

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

/* Chat Screen Styling (Phong cách ChatGPT toàn màn hình) */
#view-chat.content-view {
  padding: 0;
  height: calc(100vh - 64px);
  overflow: hidden;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #FFFFFF;
  border: none;
  overflow: hidden;
}

.chat-banner {
  padding: 14px 20px;
  background: linear-gradient(90deg, #FFF5F5 0%, #FFFDF5 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.chat-banner strong {
  color: var(--primary);
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

/* ChatGPT style Welcome Screen */
.chat-welcome-box {
  margin: auto;
  text-align: center;
  max-width: 520px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-in;
}

/* Welcome Avatar & School Branding */
.welcome-avatar-wrapper {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.welcome-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid #FFCDD2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(211, 47, 47, 0.18), 0 0 0 4px rgba(255, 235, 238, 0.6);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.welcome-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 28px rgba(211, 47, 47, 0.25), 0 0 0 6px rgba(255, 235, 238, 0.8);
}

.welcome-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  display: block;
}

.welcome-badge-icon {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 32px;
  height: 32px;
  background: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 0 0 2px #FFCDD2;
  animation: gentleBounce 2.5s ease-in-out infinite;
}

@keyframes gentleBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.welcome-school-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFF5F5;
  border: 1px solid #FFCDD2;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.welcome-title {
  font-size: 22px;
  font-weight: 700;
  color: #1E293B;
  margin-bottom: 8px;
}

.welcome-subtitle {
  font-size: 14px;
  color: #64748B;
  line-height: 1.5;
}

.message-row {
  display: flex;
  gap: 12px;
  max-width: 90%;
  animation: fadeIn 0.2s ease-in;
}

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

.message-row.assistant {
  align-self: flex-start;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.message-row.user .msg-avatar {
  background: #E2E8F0;
  color: #475569;
}

.message-row.assistant .msg-avatar {
  background: #FFFFFF;
  border: 1.5px solid #FFCDD2;
  box-shadow: 0 2px 6px rgba(211, 47, 47, 0.2);
  padding: 1.5px;
  overflow: hidden;
}

.bot-bubble-logo,
.message-row.assistant .msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  display: block;
}

.msg-bubble {
  background: #F1F5F9;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
  position: relative;
}

.message-row.user .msg-bubble {
  background: var(--primary);
  color: #FFFFFF;
  border-top-right-radius: 4px;
}

.message-row.assistant .msg-bubble {
  background: #FFFFFF;
  color: var(--text-main);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-top-left-radius: 4px;
}

/* Khung cảnh báo vi phạm chuẩn mực học đường trong khung chat */
.chat-alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chat-alert-banner.warning {
  background: #FFFBEB;
  border: 1px solid #FCD34D;
  border-left: 5px solid #F59E0B;
  color: #92400E;
}
.chat-alert-banner.danger {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-left: 5px solid #EF4444;
  color: #991B1B;
}
.chat-alert-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}
.chat-alert-content {
  flex: 1;
}
.chat-alert-content strong {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 13px;
  letter-spacing: 0.2px;
}
.user-violation-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #FFFBEB;
  color: #B45309;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 9999px;
  border: 1px solid #FCD34D;
  margin-bottom: 6px;
}

.msg-sources {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
}

.msg-sources-title {
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.source-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #FFF5F5;
  color: var(--primary);
  border: 1px solid #FFCDD2;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  margin-right: 6px;
  margin-bottom: 4px;
  font-size: 11px;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-light);
}

.feedback-buttons {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.btn-feedback {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-feedback:hover {
  background: #F1F5F9;
}

.btn-feedback.active-yes {
  background: var(--success-light);
  color: var(--success);
  border-color: var(--success);
}

.btn-feedback.active-no {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

/* Chat Input Bar (ChatGPT Style) */
.chat-input-wrapper {
  padding: 12px 24px 16px 24px;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.chat-input-bar {
  width: 100%;
  max-width: 820px;
  background: #F8FAFC;
  border: 1.5px solid #E2E8F0;
  border-radius: 28px;
  padding: 6px 8px 6px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: var(--transition);
}

.chat-input-bar:focus-within {
  border-color: var(--primary);
  background: #FFFFFF;
  box-shadow: 0 4px 16px rgba(211, 47, 47, 0.12);
}

.chat-input {
  flex: 1;
  padding: 8px 0;
  border: none;
  font-size: 15px;
  outline: none;
  background: transparent;
  color: #1E293B;
}

.chat-disclaimer {
  font-size: 12px;
  color: #94A3B8;
  text-align: center;
}

.btn-send {
  width: 38px;
  height: 38px;
  background: var(--primary-gradient);
  border: none;
  border-radius: var(--radius-full);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
  box-shadow: 0 4px 10px rgba(211, 47, 47, 0.3);
}

.btn-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(211, 47, 47, 0.4);
}

.btn-send:disabled {
  background: #CBD5E1;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Quick prompt chips */
.quick-prompts {
  display: flex;
  gap: 8px;
  padding: 8px 20px 0 20px;
  overflow-x: auto;
  white-space: nowrap;
}

.chip {
  padding: 6px 12px;
  background: #F1F5F9;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.chip:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #FFCDD2;
}

/* Cards & Tables */
.card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  border-bottom: 1px solid #F1F5F9;
  padding-bottom: 14px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

th {
  background: #F8FAFC;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

tr:hover td {
  background: #FBFDFF;
}

/* Status Badges */
.badge-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-dang_su_dung { background: var(--success-light); color: var(--success); }
.status-cho_duyet { background: var(--warning-light); color: var(--warning); }
.status-tu_choi { background: var(--danger-light); color: var(--danger); }
.status-ngung_su_dung { background: #F1F5F9; color: var(--text-muted); }

/* Dashboard Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.metric-data h3 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.metric-data p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  background: #FFFFFF;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

.btn-primary {
  background: var(--primary-gradient);
  color: #FFFFFF;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(211, 47, 47, 0.35);
  transform: translateY(-1px);
}

.btn-success { background: var(--success); color: #FFF; border: none; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-danger { background: var(--danger); color: #FFF; border: none; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; }

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-box {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 560px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

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

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

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 24px;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #F8FAFC;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
}

.toast {
  padding: 12px 18px;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    height: 100%;
  }
  .sidebar.open {
    left: 0;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .message-row {
    max-width: 95%;
  }
}

/* ==============================================================================
   FULL-SCREEN LOGIN GATEWAY (MANDATORY ACCESS GATEWAY)
   ============================================================================== */
.login-gateway {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: radial-gradient(circle at top left, #FFF1F2 0%, #FFFFFF 40%, #FEF2F2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.login-card-wrapper {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  width: 100%;
  max-width: 1000px;
  min-height: 560px;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(211, 47, 47, 0.15), 0 0 0 1px rgba(226, 232, 240, 0.8);
  overflow: hidden;
  animation: fadeInScale 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-banner {
  background: linear-gradient(145deg, #B71C1C 0%, #D32F2F 45%, #E53935 85%, #FF5252 100%);
  color: #FFFFFF;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-banner::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.login-banner::after {
  content: "";
  position: absolute;
  bottom: -80px;
  left: -40px;
  width: 260px;
  height: 260px;
  background: rgba(251, 192, 45, 0.12);
  border-radius: 50%;
  pointer-events: none;
}

.login-logo-emblem {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.login-logo-glow {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.35) 0%, rgba(255, 255, 255, 0.15) 60%, transparent 100%);
  filter: blur(8px);
  animation: pulseGlow 3s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
  0% { transform: scale(0.95); opacity: 0.6; }
  100% { transform: scale(1.08); opacity: 1; }
}

.login-logo-img {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #FFFFFF;
  padding: 3px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(255, 255, 255, 0.5);
  object-fit: contain;
  display: block;
  animation: gentleFloat 3s ease-in-out infinite alternate;
}

.login-agency-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 2px;
}

.login-emblem {
  font-size: 52px;
  margin-bottom: 16px;
  display: inline-block;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
  animation: gentleFloat 3s ease-in-out infinite alternate;
}

@keyframes gentleFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

.login-school-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #FFD54F;
  margin-bottom: 6px;
}

.login-app-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 16px;
  color: #FFFFFF;
}

.login-desc {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 32px;
}

.login-features {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.feature-item .f-icon {
  font-size: 20px;
  background: rgba(255, 255, 255, 0.15);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}

.feature-item strong {
  font-size: 14px;
  display: block;
  color: #FFFFFF;
  margin-bottom: 2px;
}

.feature-item p {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.4;
  margin: 0;
}

.login-banner-footer {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 18px;
  margin-top: 24px;
}

/* Form Container */
.login-form-container {
  padding: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #FFFFFF;
}

.login-form-header {
  margin-bottom: 28px;
}

.login-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.login-form-header h3 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.login-form-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.quick-login-section {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 18px;
}

.quick-login-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-roles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.role-quick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  font-family: inherit;
}

.role-quick-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.role-icon {
  font-size: 18px;
}

.role-text {
  display: flex;
  flex-direction: column;
}

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

.role-user {
  font-size: 10px;
  color: var(--text-light);
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 14px 0 18px 0;
  color: var(--text-light);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.login-divider span {
  padding: 0 10px;
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-wrap .input-icon {
  position: absolute;
  left: 12px;
  font-size: 15px;
  pointer-events: none;
  color: var(--text-muted);
}

.input-icon-wrap .form-control {
  padding-left: 38px;
}

.btn-login-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--primary-gradient);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(211, 47, 47, 0.25);
  transition: var(--transition);
  margin-top: 14px;
}

.btn-login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(211, 47, 47, 0.35);
}

.btn-login-submit:active {
  transform: translateY(0);
}

.btn-login-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.login-alert-box {
  background: var(--danger-light);
  border: 1px solid #FECACA;
  color: #B91C1C;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  line-height: 1.4;
}

.login-security-notice {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 18px;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

/* Header User Pill */
.header-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px 8px 4px 12px;
  box-shadow: var(--shadow-sm);
}

.header-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.header-user-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

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

.header-user-role {
  font-size: 10px;
  color: var(--text-muted);
}

.btn-header-logout {
  background: #F1F5F9;
  border: none;
  border-radius: var(--radius-full);
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.btn-header-logout:hover {
  background: var(--danger-light);
  color: var(--danger);
}

@media (max-width: 900px) {
  .login-card-wrapper {
    grid-template-columns: 1fr;
    max-width: 480px;
    min-height: auto;
  }
  .login-banner {
    padding: 32px 24px;
  }
  .login-form-container {
    padding: 32px 24px;
  }
}

/* Parent Welcome Box for Zalo OA QR Visitors */
.parent-welcome-box {
  background: linear-gradient(135deg, #FFF9F9 0%, #FFFFFF 100%);
  border: 1.5px solid #FECACA;
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  max-width: 680px;
  margin: 10px auto 20px auto;
  box-shadow: 0 8px 24px rgba(211, 47, 47, 0.08);
  animation: fadeIn 0.3s ease-in;
}

.parent-brand-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.parent-school-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 50%;
  background: #FFFFFF;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 0 0 1px #FECACA;
  flex-shrink: 0;
}

.parent-school-name {
  font-size: 12px;
  font-weight: 800;
  color: #1E293B;
  letter-spacing: 0.3px;
}
.parent-welcome-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FEE2E2;
  color: #B91C1C;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 9999px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.parent-welcome-title {
  font-size: 20px;
  font-weight: 700;
  color: #1E293B;
  margin-bottom: 6px;
}
.parent-welcome-desc {
  font-size: 13.5px;
  color: #64748B;
  line-height: 1.5;
  max-width: 580px;
  margin: 0 auto;
}
.parent-quick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}
.btn-parent-pill {
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  color: #334155;
  border-radius: 9999px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-parent-pill:hover {
  background: #FEF2F2;
  border-color: #FCA5A5;
  color: #DC2626;
  transform: translateY(-1px);
}

/* ============================================================ */
/* EMERGENCY CALMING CARD & WORKFLOW 'Xu_ly_Tin_nhan_Khan_Quang_Do' */
/* ============================================================ */
.emergency-alert-card {
  background: linear-gradient(135deg, #FFF5F5 0%, #FFFFFF 100%);
  border: 2px solid #EF4444;
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.14);
  animation: fadeIn 0.3s ease-in;
}

.emergency-alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #FEE2E2;
}

.emergency-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FEE2E2;
  color: #B91C1C;
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #DC2626;
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
  animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 7px rgba(220, 38, 38, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
  }
}

.emergency-workflow-tag {
  font-size: 10.5px;
  color: #991B1B;
  font-family: monospace;
  background: #FEF2F2;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #FECACA;
  font-weight: 600;
}

.emergency-calming-box {
  background: #FEF2F2;
  border-left: 4px solid #DC2626;
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.emergency-calming-speech {
  font-size: 14.5px;
  font-weight: 700;
  color: #991B1B;
  line-height: 1.55;
  margin-bottom: 12px;
}

.emergency-audio-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-audio-speak {
  background: #DC2626;
  color: #FFFFFF;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.2);
}

.btn-audio-speak:hover {
  background: #B91C1C;
  transform: translateY(-1px);
}

.btn-audio-stop {
  background: #FFFFFF;
  color: #475569;
  border: 1px solid #CBD5E1;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-audio-stop:hover {
  background: #F1F5F9;
  color: #1E293B;
}

.emergency-quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.btn-emergency-action {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.btn-call-hotline {
  background: #DC2626;
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.3);
}

.btn-call-hotline:hover {
  background: #B91C1C;
  transform: translateY(-1px);
}

.btn-call-111 {
  background: #1E293B;
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-call-111:hover {
  background: #0F172A;
  transform: translateY(-1px);
}

.emergency-notice {
  font-size: 11.5px;
  color: #64748B;
  line-height: 1.45;
  margin-top: 8px;
}
