/* CSS for So Quan Ly Do Dung Day Hoc - TCT.VN */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background-color: #f1f5f9;
  color: #334155;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  border: 1px solid #e2e8f0;
}

.btn-back:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.header-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.header-left .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  background: #f8fafc;
  color: #334155;
}

.btn-sample {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}
.btn-sample:hover {
  background: #dcfce7;
}

.btn-backup {
  background: #f5f3ff;
  color: #5b21b6;
  border-color: #ddd6fe;
}
.btn-backup:hover {
  background: #ede9fe;
}

.btn-restore {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}
.btn-restore:hover {
  background: #fef3c7;
}

.btn-print {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}
.btn-print:hover {
  background: #dbeafe;
}

/* Teacher Bar & Stats */
.teacher-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
}

.teacher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.info-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-group label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.5px;
}

.info-group input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
}

.info-group input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.stat-card {
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* Navigation Tabs */
.nav-tabs {
  background: #ffffff;
  display: flex;
  gap: 8px;
  padding: 6px 24px 0;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--primary);
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Main Container */
.main-container {
  padding: 24px;
  max-width: 1540px;
  margin: 0 auto;
}

.tab-pane {
  display: none;
}

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

/* Panels */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.tag-badge {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.search-box input {
  border: none;
  outline: none;
  font-size: 0.85rem;
  width: 200px;
  background: transparent;
}

.select-filter {
  padding: 7px 12px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: #1e293b;
  outline: none;
}

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

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(37,99,235,0.2);
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background-color: #e2e8f0;
}

/* Data Table */
.table-responsive {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

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

.data-table th {
  background-color: #f8fafc;
  padding: 12px 14px;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.data-table .text-center {
  text-align: center;
}

/* Badges */
.badge-status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.badge-moi { background: #dcfce7; color: #15803d; }
.badge-tot { background: #e0f2fe; color: #0369a1; }
.badge-can-sua { background: #fef3c7; color: #b45309; }
.badge-da-tra { background: #f1f5f9; color: #64748b; }

.badge-source {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.badge-source-personal { background: #ede9fe; color: #6d28d9; }
.badge-source-school { background: #fef2f2; color: #b91c1c; }

.badge-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Actions in row */
.action-btn-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.btn-icon.delete:hover {
  background-color: #fee2e2;
  color: #ef4444;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
  margin-top: 16px;
}

.empty-state p {
  margin: 12px 0 16px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Schedule Tab Grid */
.schedule-layout-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
}

@media (max-width: 960px) {
  .schedule-layout-grid {
    grid-template-columns: 1fr;
  }
}

.schedule-week-container {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.schedule-week-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.schedule-week-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.schedule-days-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-card {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
}

.day-card:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.day-card.active {
  background: #eff6ff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

.day-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e293b;
}

.day-card-count {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
}

.day-card-count.has-items {
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
}

.schedule-table-container {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.table-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.badge {
  padding: 4px 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 4px;
}

.item-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.item-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e2e8f0;
  color: #1e293b;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.item-chip.warn-broken {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.2s ease-out;
}

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

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #0f172a;
}

.modal-body {
  padding: 20px;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.col-4 { flex: 4; }
.col-6 { flex: 6; }
.col-8 { flex: 8; }

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

.form-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  outline: none;
  background: #f8fafc;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.item-multi-select-container {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}

.checkbox-item:hover {
  background: #e2e8f0;
}

.modal-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: #1e293b;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease-out;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.toast-success { background: #065f46; border-left: 4px solid #10b981; }
.toast.toast-error { background: #991b1b; border-left: 4px solid #ef4444; }
.toast.toast-info { background: #1e3a8a; border-left: 4px solid #3b82f6; }

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

/* PRINT PREVIEW & A4 DOCUMENT STYLES */
.print-control-bar {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.print-selector-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.a4-document-container {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

.a4-page {
  background: #ffffff;
  width: 210mm;
  min-height: 297mm;
  padding: 20mm 15mm;
  margin: 0 auto;
  box-shadow: 0 0 15px rgba(0,0,0,0.1);
  color: #000000;
  font-family: 'Be Vietnam Pro', 'Times New Roman', serif;
}

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

.doc-header-col {
  flex: 1;
}

.doc-school-name {
  font-size: 13pt;
  font-weight: 700;
  text-transform: uppercase;
}

.doc-dept-name {
  font-size: 11pt;
  font-weight: 700;
  text-transform: uppercase;
}

.doc-divider-line {
  width: 120px;
  height: 1px;
  background-color: #000000;
  margin-top: 4px;
}

.doc-header-col.text-right {
  text-align: center;
}

.doc-national-motto {
  font-size: 12pt;
  font-weight: 700;
}

.doc-national-sub {
  font-size: 11pt;
  font-weight: 600;
}

.doc-header-col.text-right .doc-divider-line {
  margin: 4px auto 0;
}

.doc-title-block {
  text-align: center;
  margin: 25px 0 20px;
}

.doc-title-block h2 {
  font-size: 15pt;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.doc-sub-title {
  font-size: 11pt;
  font-style: italic;
  margin-bottom: 8px;
}

.doc-meta-info {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 11pt;
  margin-top: 6px;
  flex-wrap: wrap;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10pt;
  margin-bottom: 24px;
}

.print-table th,
.print-table td {
  border: 1px solid #000000;
  padding: 6px 8px;
  vertical-align: middle;
}

.print-table th {
  background-color: #f1f5f9;
  font-weight: 700;
  text-align: center;
}

.print-table .text-center {
  text-align: center;
}

.doc-signature-block {
  display: flex;
  justify-content: space-between;
  margin-top: 30px;
  page-break-inside: avoid;
}

.sig-col {
  flex: 1;
  text-align: center;
}

.sig-title {
  font-weight: 700;
  font-size: 10pt;
}

.sig-note {
  font-size: 9pt;
  font-style: italic;
}

.sig-date {
  font-size: 10pt;
  font-style: italic;
  margin-bottom: 4px;
}

.sig-space {
  height: 70px;
}

/* PRINT MEDIA QUERIES */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  
  .no-print,
  .no-print-section {
    display: none !important;
  }

  .nav-tabs,
  .app-header,
  .teacher-bar,
  .print-control-bar,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }

  .main-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  #tab-print-preview {
    display: block !important;
  }

  .a4-document-container {
    padding: 0 !important;
    margin: 0 !important;
  }

  .a4-page {
    box-shadow: none !important;
    padding: 10mm 10mm !important;
    width: 100% !important;
    margin: 0 !important;
  }

  @page {
    size: A4 portrait;
    margin: 10mm;
  }
}

/* Welcome Banner & Danger Outline */
.btn-danger-outline {
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
}
.btn-danger-outline:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

.welcome-sample-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
  border: 1px solid #bfdbfe;
  border-left: 5px solid #2563eb;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  animation: fadeIn 0.3s ease-in-out;
}

.welcome-banner-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.welcome-banner-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
  flex-shrink: 0;
}

.welcome-banner-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 2px;
}

.welcome-banner-desc {
  font-size: 13.5px;
  color: #334155;
  margin: 0;
}

.welcome-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-banner-empty {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-banner-empty:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.btn-banner-sample {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: #2563eb;
  border: 1px solid #1d4ed8;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transition: all 0.2s ease;
}

.btn-banner-sample:hover {
  background: #1d4ed8;
}

@media (max-width: 768px) {
  .welcome-sample-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .welcome-banner-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

