@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

@font-face {
  font-family: 'ITF Qomra Arabic';
  src: url('/fonts/ITFQomra-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'ITF Qomra Arabic';
  src: url('/fonts/ITFQomra-medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'ITF Qomra Arabic';
  src: url('/fonts/ITFQomra-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  /* Brand Colors */
  --primary: #745C4D;
  --primary-dark: #644E44;
  --primary-deep: #483A31;
  --primary-2a: #2A201E;

  --bg-light: #FFF4F0;
  --highlight: #F7DDD0;
  --blue-light: #DEF2FB;
  --blue-dark: #BDE7FA;

  /* Neutrals */
  --n-50: #F5F3F1;
  --n-100: #EDE8E4;
  --n-200: #DDD4CC;
  --n-300: #C8BAB0;
  --n-400: #A89080;

  /* Text */
  --text-primary: #483A31;
  --text-secondary: #745C4D;
  --text-muted: rgba(72, 58, 49, 0.65);
  --text-on-dark: #FFF4F0;

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md-sm: 12px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 42px;

  /* Border radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 180ms var(--ease);
  --t-med: 320ms var(--ease);
  --t-slow: 520ms var(--ease);

  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(116, 92, 77, 0.08);
  --shadow-md: 0 8px 24px rgba(72, 58, 49, 0.10);
  --shadow-lg: 0 16px 36px rgba(116, 92, 77, 0.16);
}

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

body {
  font-family: 'ITF Qomra Arabic', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-primary);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 244, 240, 0.94);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(116, 92, 77, 0.12);
  padding: 14px 24px;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

/* Mobile hamburger toggle — only rendered on pages that need a collapsible header menu */
.mobile-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  border: 1.5px solid rgba(116, 92, 77, 0.25);
  background: #ffffff;
  color: var(--primary-deep);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-fast);
}

.mobile-menu-toggle:hover {
  background: rgba(116, 92, 77, 0.08);
}

.brand-logo-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo-group img {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.brand-divider {
  width: 1px;
  height: 28px;
  background-color: rgba(116, 92, 77, 0.2);
}

.project-title-badge {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-deep);
  display: flex;
  flex-direction: column;
}

.project-title-badge span {
  font-size: 11px;
  color: var(--primary);
  font-weight: 500;
}

/* Nav links */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--r-md);
  border: none;
  cursor: pointer;
  transition: all var(--t-med);
  text-decoration: none;
  font-family: inherit;
}

.btn--primary {
  background: var(--primary);
  color: var(--text-on-dark);
  box-shadow: 0 6px 18px rgba(116, 92, 77, 0.25);
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translate3d(0, -2px, 0);
  box-shadow: 0 10px 26px rgba(116, 92, 77, 0.32);
}

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

.btn--secondary:hover:not(:disabled) {
  background: rgba(116, 92, 77, 0.08);
}

.btn--outline-dark {
  background: rgba(255, 244, 240, 0.15);
  color: var(--text-on-dark);
  border: 1px solid rgba(255, 244, 240, 0.3);
}

.btn--outline-dark:hover {
  background: rgba(255, 244, 240, 0.25);
}

.btn--lg {
  padding: 16px 32px;
  font-size: 17px;
  border-radius: var(--r-lg);
}

.btn--full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* Container */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-xl) var(--sp-lg);
  flex: 1;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(116, 92, 77, 0.08);
  color: var(--primary);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
}

.badge--highlight {
  background: var(--highlight);
  color: var(--primary-deep);
  font-weight: 700;
}

.badge--success {
  background: #E6F4EA;
  color: #137333;
}

.badge--warning {
  background: #FEF7E0;
  color: #B06000;
}

.badge--danger {
  background: #FCE8E6;
  color: #C5221F;
}

/* Hero Section */
.hero {
  text-align: center;
  max-width: 800px;
  margin: 0 auto var(--sp-xl) auto;
  animation: fadeIn 600ms var(--ease);
}

.hero-eyebrow {
  margin-bottom: 12px;
}

.hero-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  color: var(--primary-deep);
  line-height: 1.25;
  margin-bottom: 16px;
}

.hero-subtitle {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto;
}

/* Main Form Card */
.card {
  background: #ffffff;
  border-radius: var(--r-xl);
  padding: clamp(24px, 4vw, 40px);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(116, 92, 77, 0.12);
  margin-bottom: var(--sp-xl);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--highlight) 100%);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-lg);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-deep);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-control {
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  font-family: inherit;
  color: var(--primary-deep);
  background-color: var(--n-50);
  border: 1.5px solid var(--n-200);
  border-radius: var(--r-md);
  outline: none;
  transition: all var(--t-fast);
}

.form-control:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(116, 92, 77, 0.15);
}

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

/* Custom Date & Time Selector Pills */
.pills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.pill-option {
  position: relative;
}

.pill-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.pill-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  background: var(--n-50);
  border: 1.5px solid var(--n-200);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: center;
}

.pill-label .day-name {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.pill-label .date-val, .pill-label .time-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-deep);
}

.pill-label .cap-badge {
  font-size: 11px;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: rgba(116, 92, 77, 0.08);
  color: var(--primary);
}

.pill-option input[type="radio"]:checked + .pill-label {
  background: var(--highlight);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(116, 92, 77, 0.18);
  transform: translate3d(0, -1px, 0);
}

.pill-option input[type="radio"]:checked + .pill-label .date-val,
.pill-option input[type="radio"]:checked + .pill-label .time-val {
  color: var(--primary-deep);
}

.pill-option.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.pill-option.disabled .pill-label {
  background: var(--n-100);
  border-color: transparent;
  cursor: not-allowed;
}

.pill-option.disabled .cap-badge {
  background: #FCE8E6;
  color: #C5221F;
}

/* Section Title inside card */
.section-subtitle {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-deep);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-subtitle svg {
  color: var(--primary);
}

/* Printable Ticket Card Design */
.ticket-wrapper {
  max-width: 650px;
  margin: 0 auto;
  animation: cardIn 600ms var(--ease);
}

.ticket-card {
  background: #ffffff;
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(116, 92, 77, 0.2);
}

.ticket-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-deep) 100%);
  color: var(--text-on-dark);
  padding: 32px 28px;
  text-align: center;
  position: relative;
}

.ticket-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 60%;
  height: 200%;
  background: radial-gradient(circle, rgba(247, 221, 208, 0.18) 0%, transparent 60%);
  pointer-events: none;
}

.ticket-body {
  padding: 32px 28px;
}

.ticket-qr-box {
  text-align: center;
  margin-bottom: 24px;
}

.ticket-qr-box img {
  width: 220px;
  height: 220px;
  border-radius: var(--r-lg);
  border: 4px solid var(--highlight);
  padding: 10px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.ticket-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  background: var(--bg-light);
  border-radius: var(--r-lg);
  padding: 20px;
  border: 1px solid rgba(116, 92, 77, 0.12);
}

.ticket-info-item {
  display: flex;
  flex-direction: column;
}

.ticket-info-item .lbl {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.ticket-info-item .val {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-deep);
  margin-top: 2px;
}

/* Stats / KPI Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-lg);
  margin-bottom: var(--sp-xl);
}

.stat-card {
  background: #ffffff;
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(116, 92, 77, 0.12);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  background: var(--bg-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-deep);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-lbl {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid rgba(116, 92, 77, 0.12);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 14.5px;
}

.data-table th {
  background: var(--n-50);
  color: var(--primary-deep);
  font-weight: 700;
  padding: 14px 18px;
  border-bottom: 1px solid var(--n-200);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--n-100);
  color: var(--text-primary);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: rgba(255, 244, 240, 0.5);
}

/* Scanner Layout */
.scanner-container {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.camera-box {
  width: 100%;
  border-radius: var(--r-xl);
  overflow: hidden;
  background: #000;
  position: relative;
  box-shadow: var(--shadow-lg);
  border: 4px solid var(--primary);
  min-height: 280px;
}

#reader {
  width: 100%;
}

.scan-result-card {
  margin-top: var(--sp-lg);
  padding: 24px;
  border-radius: var(--r-lg);
  text-align: center;
  animation: cardIn 400ms var(--ease);
}

.scan-result-card.success {
  background: #E6F4EA;
  border: 2px solid #137333;
  color: #137333;
}

.scan-result-card.error {
  background: #FCE8E6;
  border: 2px solid #C5221F;
  color: #C5221F;
}

.scan-result-card.warning {
  background: #FEF7E0;
  border: 2px solid #B06000;
  color: #B06000;
}

/* Keyframe Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cardIn {
  from { opacity: 0; transform: translate3d(0, 12px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* Footer */
.site-footer {
  margin-top: auto;
  background: var(--primary-deep);
  color: var(--text-on-dark);
  padding: 24px;
  text-align: center;
  font-size: 13px;
}

.site-footer p {
  opacity: 0.8;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--r-md);
  background: var(--primary-deep);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: cardIn 300ms var(--ease);
}

.toast.error { background: #C5221F; }
.toast.success { background: #137333; }

/* ============================================================
   RESPONSIVE — Mobile & Tablet
   ============================================================ */

/* Admin dashboard: collapsible header menu (hamburger) on tablet/mobile */
@media (max-width: 860px) {
  #headerActionsMenu {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    right: 0;
    left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    background: #ffffff;
    padding: 14px 18px 20px;
    border-bottom: 1px solid rgba(116, 92, 77, 0.15);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
    box-shadow: var(--shadow-md);
    z-index: 99;
  }

  #headerActionsMenu.open {
    display: flex;
  }

  #headerActionsMenu .btn {
    width: 100%;
    justify-content: center;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }
}

/* Tablet tier (≤900px) */
@media (max-width: 900px) {
  .container { padding: var(--sp-lg) var(--sp-md); }
  .form-grid { gap: var(--sp-md); }
  .stats-grid { gap: var(--sp-md); }
}

/* Bookings table → stacked cards on tablet/mobile */
@media (max-width: 768px) {
  .table-wrapper {
    overflow-x: visible;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .data-table {
    border-collapse: separate;
    border-spacing: 0 12px;
  }

  .data-table thead { display: none; }

  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    background: #ffffff;
    border: 1px solid rgba(116, 92, 77, 0.14);
    border-radius: var(--r-lg);
    padding: 4px 16px;
    box-shadow: var(--shadow-sm);
  }

  .data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--n-100);
    text-align: left;
  }

  .data-table td:last-child { border-bottom: none; }

  .data-table td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
  }

  .data-table td.actions-cell {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .data-table td.actions-cell::before { margin-bottom: 2px; }

  .data-table td.actions-cell > div { width: 100%; }

  .data-table td.actions-cell .btn,
  .data-table td.actions-cell a.btn {
    flex: 1;
    min-width: 0;
  }
}

/* Phone tier (≤640px) */
@media (max-width: 640px) {
  .site-header { padding: 12px 16px; }
  .brand-logo-group img { height: 34px; }
  .project-title-badge span { display: none; }
  .ticket-info-grid { grid-template-columns: 1fr; }
  .container { padding: 20px 14px; }

  .header-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

  .hero-title { font-size: clamp(24px, 7vw, 32px); }
  .hero-subtitle { font-size: 15px; }

  .card { padding: 20px 16px; }

  .pills-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .pill-label { padding: 10px 6px; }

  .btn--lg { padding: 14px 22px; font-size: 15.5px; }

  .ticket-qr-box img { width: min(220px, 62vw); height: auto; }
  .ticket-header { padding: 24px 18px; }
  .ticket-body { padding: 22px 16px; }
}

/* Small phone tier (≤480px) */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 42px; height: 42px; font-size: 18px !important; }
  .stat-val { font-size: 21px; }
  .stat-lbl { font-size: 11.5px; }

  .form-control { padding: 12px 14px; font-size: 15px; }
  .btn { padding: 11px 18px; font-size: 14px; }

  .toast-container { right: 12px; left: 12px; bottom: 16px; }
  .toast { width: 100%; }
}

/* Ensure comfortable tap targets on touch devices */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 44px; }
  .pill-label { min-height: 44px; }
  input.form-control, select.form-control { min-height: 44px; }
}
