* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: #334155;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ==========================================
   THANH HEADER TRÊN ĐẦU (DARK THEME)
   ========================================== */
.top-navbar {
  height: 52px;
  background-color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 100;
  flex-shrink: 0;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
}

.nav-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f59e0b;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s;
}

.nav-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Thiết kế nút Xuất PDF trên header */
.btn-export-pdf {
  
  color: #f59e0b;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  gap: 6px;
  border: none;
}

.btn-export-pdf:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.btn-export-pdf:disabled {
  background-color: #6c757d;
  cursor: not-allowed;
}

/* ==========================================
   BỐ CỤC CHÍNH (APP LAYOUT)
   ========================================== */
.app-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 52px);
  position: relative;
  overflow: hidden;
}

/* CỘT NHẬP THÔNG SỐ (SIDEBAR BÊN TRÁI) */
.sidebar-panel {
  width: 360px;
  min-width: 320px;
  height: 100%;
  background: white;
  padding: 20px;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  z-index: 90;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease-in-out;
}

/* Sidebar ẩn mặc định khi bấm nút toggle */
.sidebar-panel.collapsed {
  transform: translateX(-100%);
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #0056b3;
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.sidebar-header h3 {
  margin: 0;
  color: #1a252f;
}

.close-sidebar-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #64748b;
}

/* STYLE ACCORDION (MENU SỔ XUỐNG) */
.acc-group {
  border: 1px solid #dce4ec;
  border-radius: 6px;
  margin-bottom: 10px;
  background-color: #fcfdfe;
  overflow: hidden;
}

.acc-title {
  font-weight: bold;
  font-size: 14px;
  color: #1a252f;
  padding: 12px 15px;
  background-color: #f1f5f9;
  cursor: pointer;
  user-select: none;
  outline: none;
  transition: background 0.2s;
}

.acc-title:hover {
  background-color: #e2e8f0;
  color: #0056b3;
}

.acc-group[open] .acc-title {
  background-color: #e2e8f0;
  border-bottom: 1px solid #cbd5e1;
  color: #0056b3;
}

.acc-content {
  padding: 12px 15px;
  max-height: 350px;
  overflow-y: auto;
}

.form-group {
  margin-bottom: 12px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: bold;
  color: #475569;
}

.form-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
}

.form-group input:focus {
  border-color: #0056b3;
  outline: none;
}

/* CỘT HIỂN THỊ BẢN VẼ (BÊN PHẢI) */
.preview-panel {
  flex: 1;
  padding: 25px;
  overflow-y: auto;
  background-color: #475569;
  display: flex;
  justify-content: center;
}

#svg-preview-list {
  display: flex;
  flex-direction: column;
  gap: 25px;
  width: 100%;
  max-width: 950px;
  align-items: center;
}

/* KIỂU DÁNG TỪNG TRANG BẢN VẼ */
.svg-page-item {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  width: 100%;
}

.svg-content {
  display: flex;
  justify-content: center;
}

.svg-content svg {
  width: 100%;
  height: auto;
}

/* OVERLAY LỚP MỜ MOBILE */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 85;
}

/* ==========================================
   TỐI ƯU CHO ĐIỆN THOẠI (<= 768px)
   ========================================== */
@media screen and (max-width: 768px) {
  .sidebar-panel {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    transform: translateX(-100%);
  }

  .sidebar-panel.active {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .close-sidebar-btn {
    display: block;
  }

  .preview-panel {
    padding: 12px 8px;
  }

  .svg-page-item {
    padding: 8px;
  }
}

/* TỐI ƯU KHI IN / XUẤT PDF TRÀN VIỀN A4 */
@media print {
  @page {
    size: A4 portrait;
    margin: 0 !important;
  }

  html, body, .app-layout {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: white !important;
  }

  .top-navbar, .sidebar-panel, .sidebar-overlay {
    display: none !important;
  }

  .preview-panel {
    padding: 0 !important;
    margin: 0 !important;
    width: 210mm !important;
    overflow: visible !important;
    background: white !important;
  }

  #svg-preview-list {
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 210mm !important;
    max-width: none !important;
  }

  .svg-page-item {
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 210mm !important;
    height: 297mm !important;
    max-width: 210mm !important;
    max-height: 297mm !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    display: block !important;
  }

  .svg-content {
    width: 210mm !important;
    height: 297mm !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .svg-content svg {
    width: 210mm !important;
    height: 297mm !important;
    max-width: none !important;
    max-height: none !important;
    display: block !important;
  }
}


/* THÊM CÁC ĐOẠN CSS NÀY VÀO CUỐI FILE style.css */

.table-row-item {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
  position: relative;
}

.row-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: bold;
  font-size: 13px;
  color: #0056b3;
}

.btn-delete-row {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
}

.btn-delete-row:hover {
  background: #dc2626;
}

.row-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.row-inputs-grid .full-width {
  grid-column: span 2;
}

.btn-add-row {
  width: 100%;
  padding: 10px;
  background-color: #0284c7;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
  margin-top: 5px;
}

.btn-add-row:hover {
  background-color: #0369a1;
}

/* Định dạng bảng hiển thị trên SVG Trang 2 */
.svg-dynamic-table {
  width: 100%;
  border-collapse: collapse;
  font-family: Arial, sans-serif;
  font-size: 13px;
  background: white;
}

.svg-dynamic-table th, .svg-dynamic-table td {
  border: 1px solid #1e293b;
  padding: 8px;
  text-align: center;
  word-wrap: break-word;
  white-space: pre-line;
}

/* Thêm CSS cho ô textarea ở sidebar cho đẹp mắt */
.table-row-item textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  font-family: Arial, sans-serif;
  resize: vertical;
}

.svg-dynamic-table th {
  background-color: #f1f5f9;
  font-weight: bold;
  color: #0f172a;
}


/* css bảng thông báo xóa hàng bảng giá */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.custom-modal-box {
  background: #ffffff;
  padding: 24px;
  border-radius: 12px;
  width: 380px;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  animation: modalScaleIn 0.2s ease-in-out;
}

@keyframes modalScaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.custom-modal-box h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 18px;
  color: #1e293b;
}

.custom-modal-box p {
  color: #64748b;
  font-size: 14px;
  margin-bottom: 24px;
}

.custom-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.custom-modal-actions button {
  flex: 1;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
}

.btn-modal-cancel {
  background-color: #f1f5f9;
  color: #334155;
}

.btn-modal-cancel:hover {
  background-color: #e2e8f0;
}

.btn-modal-danger {
  background-color: #ef4444;
  color: #ffffff;
}

.btn-modal-danger:hover {
  background-color: #dc2626;
}