/* CSS for So Quan Ly Hoa Chat & Dung Cu Thi Nghiem - 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;
}

/* App 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, #0284c7, #2563eb);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 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;
}

.btn-danger-outline {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}
.btn-danger-outline:hover {
  background: #fee2e2;
}

/* First-time Welcome Banner */
.welcome-sample-banner {
  background: linear-gradient(135deg, #0284c7, #1d4ed8);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.3);
  margin-bottom: 16px;
}

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

.banner-icon {
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.banner-text h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.banner-text p {
  font-size: 0.9rem;
  opacity: 0.95;
  line-height: 1.4;
}

.banner-buttons {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.btn-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-banner-sample {
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.btn-banner-sample:hover {
  background: #f8fafc;
  transform: translateY(-1px);
}

.btn-banner-empty {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.btn-banner-empty:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* School Info Bar */
.teacher-bar {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 20px 0;
}

.teacher-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  background: #ffffff;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.info-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.info-field input {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  outline: none;
  transition: border-color 0.2s;
}
.info-field input:focus {
  border-color: var(--primary);
  background: #ffffff;
}

/* Main Container */
.main-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

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

.stat-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

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

/* Safety Alert Box */
.safety-alert-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 5px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.alert-box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #92400e;
  font-weight: 700;
  margin-bottom: 6px;
}

.alert-box-content {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.alert-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.alert-tag-low {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-tag-exp {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 16px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

/* Tab Panels */
.tab-panel {
  display: none;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

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

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

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.search-input-wrapper {
  position: relative;
  min-width: 240px;
  flex: 1;
}

.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.search-input-wrapper input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  outline: none;
}
.search-input-wrapper input:focus {
  border-color: var(--primary);
}

.select-filter {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  background: #ffffff;
  color: #334155;
  outline: none;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

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

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.btn-secondary:hover {
  background: #e2e8f0;
}

/* Data Table */
.table-responsive {
  overflow-x: auto;
}

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

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

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  color: #1e293b;
  vertical-align: middle;
}

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

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

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.badge-corrosive {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.badge-flammable {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.badge-toxic {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}

.badge-oxidizing {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-safe {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.badge-subject {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-low-alert {
  background: #dc2626;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-exp-alert {
  background: #d97706;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.table-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

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

.btn-icon:hover {
  background: #f1f5f9;
  color: var(--primary);
  border-color: #cbd5e1;
}

.btn-icon-delete:hover {
  color: var(--danger);
  border-color: #fca5a5;
  background: #fef2f2;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #64748b;
}

.empty-state svg {
  margin-bottom: 12px;
  color: #94a3b8;
}

.empty-state p {
  font-size: 0.95rem;
  margin-bottom: 16px;
}

/* Safety Guide tab */
.safety-guide-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
}

.guide-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #ffffff;
}

.guide-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
}

.hazard-corrosive {
  background: #fef2f2;
  color: #991b1b;
  border-bottom: 1px solid #fee2e2;
}

.hazard-flammable {
  background: #fff7ed;
  color: #9a3412;
  border-bottom: 1px solid #ffedd5;
}

.hazard-toxic {
  background: #faf5ff;
  color: #6b21a8;
  border-bottom: 1px solid #f3e8ff;
}

.hazard-glassware {
  background: #f0fdfa;
  color: #0f766e;
  border-bottom: 1px solid #ccfbf1;
}

.guide-body {
  padding: 14px 16px;
  font-size: 0.85rem;
  color: #334155;
  line-height: 1.6;
}

.guide-body p {
  margin-bottom: 8px;
}

.guide-body ul {
  padding-left: 20px;
}

.guide-body li {
  margin-bottom: 6px;
}

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

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.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.1rem;
  font-weight: 800;
  color: #0f172a;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 20px;
}

.form-group.span-2 {
  grid-column: span 2;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  font-family: inherit;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================================================
   PRINT LAYOUT & STYLES (A4 Chuẩn Biên Bản Thanh Tra & Sư Phạm)
   ========================================================================== */
.print-container {
  display: none;
  background: #ffffff;
  color: #000000;
  padding: 20mm 15mm;
  font-family: 'Times New Roman', Times, serif;
  font-size: 11pt;
  line-height: 1.35;
}

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

.print-header-left {
  width: 48%;
  font-size: 10.5pt;
}

.print-school {
  font-weight: bold;
  text-transform: uppercase;
}

.print-dept {
  font-weight: bold;
  text-transform: uppercase;
  border-bottom: 1px solid #000;
  display: inline-block;
  padding-bottom: 2px;
  margin-bottom: 4px;
}

.print-address {
  font-style: italic;
  font-size: 9.5pt;
}

.print-header-right {
  width: 50%;
  font-size: 10.5pt;
}

.print-cxhc {
  font-size: 10pt;
}

.print-dltd {
  font-size: 10.5pt;
  border-bottom: 1px solid #000;
  display: inline-block;
  padding-bottom: 2px;
  margin-bottom: 4px;
}

.print-date {
  font-style: italic;
  font-size: 10pt;
}

.print-title-box {
  text-align: center;
  margin: 18px 0;
}

.print-title-box h2 {
  font-size: 15pt;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.print-subtitle {
  font-style: italic;
  font-size: 10.5pt;
  margin-top: 2px;
}

.print-meta-row {
  display: flex;
  justify-content: center;
  gap: 25px;
  font-size: 10.5pt;
  margin-top: 8px;
}

.print-section-title {
  font-weight: bold;
  font-size: 11pt;
  margin: 12px 0 6px 0;
  text-transform: uppercase;
}

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

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

.print-table th {
  background: #f0f0f0;
  text-align: center;
  font-weight: bold;
}

.print-signatures {
  display: flex;
  justify-content: space-between;
  text-align: center;
  margin-top: 30px;
  page-break-inside: avoid;
}

.sig-block {
  width: 30%;
}

.sig-title {
  font-size: 10.5pt;
}

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

.sig-space {
  height: 60px;
}

.sig-name {
  font-weight: bold;
  font-size: 10.5pt;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 10mm;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .no-print {
    display: none !important;
  }
  .print-container {
    display: block !important;
    padding: 0 !important;
  }
}
