/* ==========================================================================
   KÍNH GIANGKOI SAAS PWA - DESIGN SYSTEM & MODERN STYLESHEET
   ========================================================================== */

:root {
  --primary: #0d6efd;
  --primary-hover: #0b5ed7;
  --primary-light: #e7f1ff;
  --secondary: #6c757d;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --dark: #0f172a;
  --light: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: #f1f5f9;
  color: var(--text-main);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   App Header & Container
   -------------------------------------------------------------------------- */
.app-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shop-brand {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 17px;
  color: var(--dark);
}

.brand-icon {
  color: var(--primary);
  font-size: 20px;
}

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

.btn-icon {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover, .btn-icon:active {
  background: var(--border-color);
  color: var(--dark);
}

.app-container {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  padding: 16px;
  position: relative;
}

/* --------------------------------------------------------------------------
   Screen Navigation & Transitions
   -------------------------------------------------------------------------- */
.screen {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.screen.active {
  display: block;
}

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

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

.screen-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--dark);
}

.btn-back {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--dark);
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   1. Auth & Login Card
   -------------------------------------------------------------------------- */
.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
  margin-top: 40px;
  border: 1px solid rgba(255,255,255,0.8);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.hero-icon-wrapper {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #0d6efd, #0284c7);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
  box-shadow: 0 8px 20px rgba(13, 110, 253, 0.3);
}

.hero-icon {
  font-size: 36px;
  color: #ffffff;
}

.auth-header h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--dark);
}

.auth-header .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Form Controls & Inputs
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 14px;
}

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

.form-control {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  color: var(--dark);
  background-color: var(--light);
  transition: all 0.2s ease;
}

textarea.form-control {
  height: auto;
  padding: 10px 14px;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.12);
}

/* --------------------------------------------------------------------------
   Buttons & Badges
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-sm {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-lg {
  height: 52px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

.btn-flex {
  flex: 1;
}

.btn-primary {
  background: linear-gradient(135deg, #0d6efd, #0284c7);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25);
}

.btn-primary:hover, .btn-primary:active {
  background: linear-gradient(135deg, #0b5ed7, #0369a1);
  box-shadow: 0 6px 16px rgba(13, 110, 253, 0.35);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--dark);
}

.btn-outline-primary {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

.btn-outline-secondary {
  background: transparent;
  border: 1.5px solid var(--secondary);
  color: var(--secondary);
}

.btn-light-warning {
  background: var(--warning-light);
  color: #b45309;
  border: 1px solid #fcd34d;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.badge-warning {
  background-color: var(--warning-light);
  color: #b45309;
}

.badge-danger {
  background-color: var(--danger-light);
  color: #b91c1c;
}

.badge-success {
  background-color: var(--success-light);
  color: #047857;
}

/* --------------------------------------------------------------------------
   2. Home Screen Layout
   -------------------------------------------------------------------------- */
.expiry-banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #92400e;
  font-size: 13px;
  font-weight: 600;
}

.expiry-banner-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-hero {
  text-align: center;
  margin: 10px 0 24px 0;
}

.glass-illustration img {
  width: 140px;
  height: 140px;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.1));
}

.shop-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--dark);
  margin-top: 8px;
}

.shop-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

.home-menu-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.menu-card {
  display: flex;
  align-items: center;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--card-bg);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: left;
  width: 100%;
}

.menu-card:hover, .menu-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.menu-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-right: 16px;
  flex-shrink: 0;
}

.menu-card-primary .menu-icon {
  background: var(--primary-light);
  color: var(--primary);
}

.menu-card-success .menu-icon {
  background: var(--success-light);
  color: var(--success);
}

.menu-card-info .menu-icon {
  background: #e0f2fe;
  color: #0284c7;
}

.menu-card-dark .menu-icon {
  background: #f1f5f9;
  color: var(--dark);
}

.menu-content {
  flex: 1;
}

.menu-content h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark);
}

.menu-content p {
  font-size: 13px;
  color: var(--text-muted);
}

.menu-arrow {
  color: var(--text-muted);
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   3. Card Boxes & Order Form Controls
   -------------------------------------------------------------------------- */
.card-box {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.card-box-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--dark);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}

.order-row-item {
  background: var(--light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
}

.row-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #fee2e2;
  color: var(--danger);
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.grid-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.calc-preview-text {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  margin-top: 4px;
}

.fixed-bottom-bar {
  margin-top: 24px;
  margin-bottom: 16px;
}

/* --------------------------------------------------------------------------
   4. Price List Screen
   -------------------------------------------------------------------------- */
.price-list-wrapper {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.price-table-header {
  display: flex;
  background: var(--light);
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.col-name { flex: 1; }
.col-price { width: 140px; text-align: right; }

.price-item-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s ease;
  cursor: pointer;
}

.price-item-row:last-child {
  border-bottom: none;
}

.price-item-row:hover {
  background: #f8fafc;
}

.price-item-name {
  flex: 1;
  font-weight: 600;
  color: var(--dark);
}

.price-item-val {
  width: 140px;
  text-align: right;
  font-weight: 700;
  color: var(--primary);
}

.price-item-actions {
  display: flex;
  gap: 6px;
  margin-left: 8px;
}

.price-list-hint {
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px;
}

/* --------------------------------------------------------------------------
   5. History Screen
   -------------------------------------------------------------------------- */
.search-input-group {
  position: relative;
}

.search-input-group i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input-group .form-control {
  padding-left: 40px;
}

.history-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.history-code {
  font-weight: 700;
  color: var(--primary);
}

.history-date {
  font-size: 12px;
  color: var(--text-muted);
}

.history-cust-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--dark);
}

.history-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.history-amount {
  font-weight: 800;
  color: var(--dark);
  font-size: 16px;
}

/* --------------------------------------------------------------------------
   6. Admin Portal
   -------------------------------------------------------------------------- */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.admin-tab {
  flex: 1;
  height: 40px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.admin-tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.admin-view {
  display: none;
}

.admin-view.active {
  display: block;
}

.shop-admin-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.shop-admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.shop-admin-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

.shop-admin-details {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.shop-admin-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Modals Backdrop & Content
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.modal-backdrop.active {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalUp 0.25s ease forwards;
  overflow: hidden;
}

.modal-receipt {
  max-width: 620px;
}

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

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

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--dark);
}

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

.modal-body {
  padding: 18px;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  background: var(--light);
}

/* --------------------------------------------------------------------------
   Receipt Paper Component (Compact Width & Crisp Export)
   -------------------------------------------------------------------------- */
.receipt-paper-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #f1f5f9;
  padding: 16px 8px;
  display: flex;
  justify-content: center;
  padding: 8px 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #f8fafc;
  box-sizing: border-box;
}

.receipt-paper {
  width: 540px;
  background: #ffffff;
  padding: 16px;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  color: #1e293b;
  flex-shrink: 0;
}

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

.receipt-shop-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.receipt-shop-sub {
  font-size: 11.5px;
  color: #444;
  margin-bottom: 4px;
  font-style: italic;
  white-space: pre-line;
  word-break: break-word;
}

.receipt-shop-info {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
}

.receipt-shop-info strong {
  font-weight: 700;
}

.receipt-divider {
  font-size: 11px;
  color: #555;
  margin: 6px 0;
  letter-spacing: 1px;
}

.receipt-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.receipt-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  margin-bottom: 8px;
  color: #222;
}

.receipt-customer {
  font-size: 12px;
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  margin-bottom: 8px;
}

.receipt-customer p {
  margin-bottom: 0;
  white-space: normal;
  word-break: break-word;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.receipt-table th, .receipt-table td {
  border: 1px solid #000000;
  padding: 5px 4px;
  text-align: center;
  white-space: nowrap;
}

.receipt-table th {
  background-color: #f1f5f9;
  font-weight: 700;
  font-size: 11.5px;
}

.receipt-table td.col-glass-name {
  text-align: left;
  white-space: nowrap;
  font-weight: 600;
}

.receipt-section-title {
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 4px;
}

.receipt-total-wrapper {
  border-top: none;
  padding-top: 6px;
  margin-top: 6px;
}

.receipt-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 14.5px;
  font-weight: 800;
}

.receipt-words {
  font-size: 11.5px;
  font-style: italic;
  color: #111;
  white-space: normal;
  word-break: break-word;
}

.receipt-notes-wrapper {
  font-size: 11.5px;
  background: #f1f5f9;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: normal;
  word-break: break-word;
}

.receipt-footer {
  margin-top: 12px;
  font-size: 12.5px;
  font-weight: 700;
}

.shop-brand {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--dark);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}

.shop-brand:hover {
  background: var(--border-color);
}

.header-days-badge {
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
}

.header-days-green {
  color: #10b981; /* Green */
}

.header-days-red {
  color: #ef4444; /* Red */
}

/* --------------------------------------------------------------------------
   A4 PRINT STYLES - CHUẨN KHỔ GIẤY A4 100% HOÀN HẢO KHÔNG BỊ LỖI LỆCH
   -------------------------------------------------------------------------- */
#receiptPaperForPrint {
  display: none;
}

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

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  /* Hide all elements inside body except #receiptPaperForPrint */
  body > *:not(#receiptPaperForPrint) {
    display: none !important;
  }

  /* Show ONLY the print container at root level */
  #receiptPaperForPrint {
    display: block !important;
    width: 100% !important;
    max-width: 180mm !important;
    margin: 0 auto !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
    border: none !important;
  }

  #receiptPaperForPrint * {
    color: #000000 !important;
  }
}

/* --------------------------------------------------------------------------
   Packages & VietQR UI
   -------------------------------------------------------------------------- */
.packages-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.package-card {
  background: var(--light);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.package-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.package-card.recommended {
  border-color: var(--success);
}

.pkg-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

.pkg-name {
  font-size: 13px;
  font-weight: 700;
}

.pkg-price {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
}

.pkg-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.vietqr-container {
  background: var(--light);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border-color);
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 4px;
}

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

.btn-copy-sm {
  background: #e2e8f0;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}

/* Print Utilities Clean End */
