/* ===== RESTAURANT QR SYSTEM ===== */
:root {
  --primary: #e67e22;
  --primary-dark: #d35400;
  --secondary: #2c3e50;
  --success: #27ae60;
  --danger: #c0392b;
  --warning: #f39c12;
  --info: #3498db;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dfe6e9;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --radius: 12px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(8px, 2vw, 20px);
  width: 100%;
}

/* ===== HEADER ===== */
.header {
  background: var(--secondary);
  color: white;
  padding: clamp(12px, 3vw, 20px);
  text-align: center;
  border-radius: var(--radius);
  margin-bottom: clamp(12px, 2vw, 20px);
  box-shadow: var(--shadow);
}
.header h1 {
  font-size: clamp(1.1rem, 4vw, 1.8rem);
  margin-bottom: 5px;
  word-break: break-word;
}
.header p {
  opacity: 0.8;
  font-size: clamp(0.8rem, 2.5vw, 0.95rem);
}

/* ===== NAV ===== */
.nav {
  display: flex;
  gap: clamp(6px, 1.5vw, 10px);
  margin-bottom: clamp(12px, 2vw, 20px);
  flex-wrap: wrap;
}
.nav-btn {
  padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 24px);
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}
.nav-btn:hover { background: var(--primary); color: white; }
.nav-btn.active { background: var(--primary); color: white; }

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: clamp(14px, 3vw, 24px);
  margin-bottom: clamp(12px, 2vw, 20px);
  box-shadow: var(--shadow);
  width: 100%;
  overflow: hidden;
}
.card-title {
  font-size: clamp(1.05rem, 3.5vw, 1.3rem);
  margin-bottom: 16px;
  color: var(--secondary);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 8px;
  word-break: break-word;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: clamp(10px, 2vw, 16px);
  width: 100%;
}
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text);
  font-size: clamp(0.85rem, 2.5vw, 1rem);
}
.form-group input,
.form-group select {
  width: 100%;
  padding: clamp(10px, 2.5vw, 12px) clamp(12px, 2.5vw, 16px);
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: clamp(0.9rem, 3vw, 1rem);
  transition: border-color 0.2s;
  min-height: 44px;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  padding: clamp(10px, 2.5vw, 12px) clamp(16px, 3vw, 28px);
  border: none;
  border-radius: 8px;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a93226; }
.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #2980b9; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #e67e22; }

/* ===== SCANNER ===== */
.scanner-container {
  text-align: center;
  padding: clamp(10px, 2.5vw, 20px);
}
#reader {
  width: 100%;
  max-width: 500px;
  margin: 0 auto 20px;
  border-radius: var(--radius);
  overflow: hidden;
}
#reader video {
  width: 100% !important;
  height: auto !important;
  max-height: 70vh;
  object-fit: cover;
}
.scan-result {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
  padding: clamp(10px, 2.5vw, 16px);
  border-radius: 8px;
  margin-top: 16px;
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  word-break: break-word;
}
.scan-error {
  background: #f8d7da !important;
  border: 1px solid #f5c6cb !important;
  color: #721c24 !important;
}

/* ===== QR DISPLAY ===== */
.qr-display {
  text-align: center;
  padding: clamp(10px, 2.5vw, 20px);
}
.qr-code-box {
  display: inline-block;
  padding: clamp(16px, 4vw, 28px);
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: clamp(8px, 2vw, 16px);
  text-align: center;
  max-width: 100%;
}
.qr-code-box canvas,
.qr-code-box img {
  display: block;
  margin: 0 auto 10px;
  max-width: 100%;
  height: auto;
}
.qr-code-box .name {
  font-weight: 700;
  font-size: clamp(0.95rem, 3vw, 1.1rem);
  color: var(--secondary);
  word-break: break-word;
}
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: clamp(16px, 3vw, 32px);
  margin-top: 24px;
}

/* ===== TABLES ===== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -clamp(14px, 3vw, 24px);
  padding: 0 clamp(14px, 3vw, 24px);
}
.table-wrap table {
  min-width: 600px;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: clamp(0.8rem, 2.5vw, 0.95rem);
}
th, td {
  padding: clamp(8px, 2vw, 12px) clamp(10px, 2vw, 16px);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  background: var(--secondary);
  color: white;
  font-weight: 600;
}
tr:hover { background: #f8f9fa; }
.total-row {
  font-weight: 700;
  background: #fff3e0 !important;
}

/* Mobile card-style table fallback */
@media (max-width: 600px) {
  .mobile-cards .table-wrap table,
  .mobile-cards .table-wrap thead,
  .mobile-cards .table-wrap tbody,
  .mobile-cards .table-wrap th,
  .mobile-cards .table-wrap td,
  .mobile-cards .table-wrap tr {
    display: block;
    width: 100%;
  }
  .mobile-cards .table-wrap thead {
    display: none;
  }
  .mobile-cards .table-wrap tr {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: white;
  }
  .mobile-cards .table-wrap td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    white-space: normal;
  }
  .mobile-cards .table-wrap td:last-child {
    border-bottom: none;
  }
  .mobile-cards .table-wrap td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-light);
    margin-right: 10px;
    flex-shrink: 0;
  }
}

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: clamp(10px, 2vw, 16px);
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: clamp(14px, 3vw, 20px);
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--primary);
}
.stat-card.green { border-top-color: var(--success); }
.stat-card.blue { border-top-color: var(--info); }
.stat-card.orange { border-top-color: var(--warning); }
.stat-card.red { border-top-color: var(--danger); }
.stat-value {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  color: var(--secondary);
  margin: 8px 0;
}
.stat-label {
  color: var(--text-light);
  font-size: clamp(0.75rem, 2vw, 0.9rem);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: clamp(10px, 3vw, 20px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: clamp(18px, 4vw, 28px);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal h3 {
  margin-bottom: 16px;
  color: var(--secondary);
  font-size: clamp(1rem, 3.5vw, 1.25rem);
}
.modal p {
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  word-break: break-word;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ===== LOGIN ===== */
.login-box {
  max-width: 400px;
  margin: clamp(20px, 8vw, 60px) auto;
  text-align: center;
  padding: 0 clamp(8px, 2vw, 20px);
}
.login-box .card { padding: clamp(20px, 5vw, 40px); }
.login-box h2 {
  margin-bottom: 8px;
  color: var(--secondary);
  font-size: clamp(1.1rem, 4vw, 1.5rem);
}
.login-box p {
  color: var(--text-light);
  margin-bottom: 24px;
  font-size: clamp(0.8rem, 2.5vw, 0.95rem);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: clamp(12px, 3vw, 14px) clamp(16px, 4vw, 24px);
  border-radius: 8px;
  color: white;
  font-weight: 600;
  z-index: 2000;
  transform: translateX(150%);
  transition: transform 0.3s;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  max-width: calc(100vw - 40px);
  word-break: break-word;
}
.toast.show { transform: translateX(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

/* ===== HIDDEN ===== */
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .qr-grid { grid-template-columns: 1fr; }
  .nav { justify-content: center; }
  .modal-actions { justify-content: stretch; }
  .modal-actions .btn { flex: 1; }
}

/* ===== QR PRINT STYLES ===== */
@media print {
  .qr-grid {
    gap: 40px !important;
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .qr-code-box {
    padding: 32px !important;
    margin: 20px !important;
    box-shadow: none !important;
    border: 2px solid #ddd;
    page-break-inside: avoid;
  }
  .qr-code-box canvas,
  .qr-code-box img {
    width: 280px !important;
    height: 280px !important;
  }
}
