/* CSS Cho Sổ Kiểm Kê & Bàn Giao Cơ Sở Vật Chất Phòng Học - TCT.VN */
:root {
  --primary-color: #1e3a8a;
  --primary-light: #2563eb;
  --primary-dark: #1e293b;
  --primary-subtle: #eff6ff;
  --secondary-color: #0d9488;
  --accent-color: #f59e0b;
  --danger-color: #ef4444;
  --success-color: #10b981;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App Header */
.app-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  color: #ffffff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.header-icon {
  background: rgba(255, 255, 255, 0.2);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.25;
}

.app-header .subtitle {
  font-size: 12px;
  color: #cbd5e1;
  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: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-sample {
  background: #f59e0b;
  color: #ffffff;
}
.btn-sample:hover {
  background: #d97706;
}

.btn-backup {
  background: #0284c7;
  color: #ffffff;
}
.btn-backup:hover {
  background: #0369a1;
}

.btn-restore {
  background: #0d9488;
  color: #ffffff;
}
.btn-restore:hover {
  background: #0f766e;
}

.btn-print {
  background: #10b981;
  color: #ffffff;
}
.btn-print:hover {
  background: #059669;
}

.btn-reset {
  background: rgba(239, 68, 68, 0.85);
  color: #ffffff;
}
.btn-reset:hover {
  background: #dc2626;
}

/* Main Container */
.main-container {
  max-width: 1300px;
  width: 100%;
  margin: 20px auto;
  padding: 0 20px;
  flex: 1;
}

/* Init Banner */
.init-banner {
  background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
  border: 2px dashed #3b82f6;
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  animation: fadeIn 0.3s ease-out;
}

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

.banner-badge {
  display: inline-block;
  background: #3b82f6;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.banner-content h2 {
  font-size: 18px;
  font-weight: 800;
  color: #1e3a8a;
  margin-bottom: 6px;
}

.banner-content p {
  color: #475569;
  font-size: 13.5px;
  max-width: 900px;
  margin-bottom: 16px;
}

.banner-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

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

.btn-banner-empty {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
}
.btn-banner-empty:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-banner-sample {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}
.btn-banner-sample:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

/* Card */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  background-color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-tag {
  background: #e2e8f0;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}

.config-grid {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

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

.form-group label {
  font-weight: 600;
  font-size: 12.5px;
  color: #334155;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: #1e293b;
  background-color: #ffffff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

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

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 20px;
  padding-bottom: 2px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--primary-light);
  background: rgba(37, 99, 235, 0.05);
}

.tab-btn.active {
  color: var(--primary-color);
  background: #ffffff;
  box-shadow: 0 -2px 5px rgba(0,0,0,0.03);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color);
  border-radius: 3px 3px 0 0;
}

.tab-content {
  display: none;
}

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

/* Section Actions Bar */
.section-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

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

.search-wrapper {
  position: relative;
  min-width: 260px;
}

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

.search-wrapper input {
  padding-left: 32px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13.5px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e2e8f0;
  color: #334155;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  border: none;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

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

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

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.stat-num {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.text-primary { color: #2563eb; }
.text-success { color: #10b981; }
.text-warning { color: #f59e0b; }
.text-danger { color: #ef4444; }
.text-info { color: #0284c7; }
.text-center { text-align: center; }

/* Table */
.table-container {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

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

.data-table th {
  background-color: #f1f5f9;
  color: #334155;
  font-weight: 700;
  font-size: 12.5px;
  padding: 12px 14px;
  border-bottom: 2px solid #e2e8f0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

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

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

.badge-cat {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
}

.badge-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}

.badge-status.good {
  background: #dcfce7;
  color: #166534;
}

.badge-status.issue {
  background: #fee2e2;
  color: #991b1b;
}

.badge-repair-pending {
  background: #fef3c7;
  color: #92400e;
}

.badge-repair-inprogress {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-repair-completed {
  background: #dcfce7;
  color: #166534;
}

.badge-repair-rejected {
  background: #f3f4f6;
  color: #6b7280;
}

.action-btns {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.btn-icon {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #475569;
  transition: all 0.15s;
}

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

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 12px;
  opacity: 0.6;
}

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

.empty-btns {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* Repair Intro */
.repair-intro {
  display: flex;
  flex-direction: column;
}
.repair-intro strong {
  font-size: 14px;
  color: #1e293b;
}
.repair-intro span {
  font-size: 12px;
  color: #64748b;
}

/* Preview Bar */
.print-config-bar {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.preview-sheet-wrapper {
  background: #64748b;
  padding: 30px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

.a4-sheet {
  background: #ffffff;
  width: 210mm;
  min-height: 297mm;
  padding: 20mm 15mm 20mm 20mm; /* Standard Vietnamese official margin: Left 20-30, Right 15-20, Top/Bottom 20-25 */
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  color: #000000;
  font-family: 'Times New Roman', Times, serif;
  font-size: 13pt;
  line-height: 1.35;
  box-sizing: border-box;
}

/* A4 Formal Print Styling (Used for preview and @media print) */
.doc-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  text-align: center;
}

.doc-header-left {
  width: 45%;
}

.doc-header-right {
  width: 55%;
}

.org-parent {
  font-size: 11pt;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.org-school {
  font-size: 11.5pt;
  font-weight: bold;
  text-transform: uppercase;
  border-bottom: 1px solid #000;
  display: inline-block;
  padding-bottom: 2px;
}

.nation-title {
  font-size: 12pt;
  font-weight: bold;
}

.nation-motto {
  font-size: 11.5pt;
  font-weight: bold;
  border-bottom: 1px solid #000;
  display: inline-block;
  padding-bottom: 2px;
  margin-bottom: 8px;
}

.doc-date-place {
  font-style: italic;
  font-size: 11pt;
}

.doc-title-block {
  text-align: center;
  margin: 18px 0 16px 0;
}

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

.doc-sub-title {
  font-size: 12pt;
  font-style: italic;
  font-weight: bold;
}

.doc-legal-basis {
  font-size: 11pt;
  font-style: italic;
  margin-bottom: 14px;
  text-align: justify;
}

.doc-section-title {
  font-size: 12.5pt;
  font-weight: bold;
  margin: 12px 0 6px 0;
}

.doc-meta-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 12pt;
}

.doc-meta-table td {
  padding: 3px 0;
  vertical-align: top;
}

.doc-data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 16px 0;
  font-size: 11pt;
}

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

.doc-data-table th {
  background-color: #f2f2f2;
  font-weight: bold;
  text-align: center;
}

.doc-signatures {
  margin-top: 30px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
  page-break-inside: avoid;
}

.sig-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sig-role {
  font-weight: bold;
  font-size: 11.5pt;
  text-transform: uppercase;
}

.sig-note {
  font-size: 10.5pt;
  font-style: italic;
  margin-bottom: 60px; /* Space for physical signature and stamp */
}

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

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-dialog {
  background: #ffffff;
  width: 100%;
  max-width: 600px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalScale 0.2s ease-out;
}

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

.modal-header {
  padding: 16px 20px;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 24px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

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

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

/* Footer */
.app-footer {
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 30px;
}

/* Print Only Section */
.print-only {
  display: none;
}

/* PRINT MEDIA QUERY */
@media print {
  @page {
    size: A4 portrait;
    margin: 15mm 15mm 15mm 20mm;
  }

  body {
    background-color: #ffffff !important;
    color: #000000 !important;
    font-family: 'Times New Roman', Times, serif !important;
    font-size: 12pt !important;
  }

  .no-print,
  .app-header,
  .tabs-nav,
  .section-actions-bar,
  .stats-row,
  .modal,
  .app-footer,
  .print-config-bar,
  .preview-sheet-wrapper,
  #init-banner {
    display: none !important;
  }

  .print-only {
    display: block !important;
    width: 100% !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .doc-data-table {
    page-break-inside: auto;
  }

  .doc-data-table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .doc-signatures {
    page-break-inside: avoid;
  }
}
