/* ========================================
   THUBA DAUROH - Design System
   Matching eid.thubaproject.com aesthetic
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ---- CSS Variables ---- */
:root {
  --bg-primary: #0d0d1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #0a2e2e;
  --bg-card-alt: #0d3535;
  --bg-input: #0a1e2e;
  --gold: #D4AF37;
  --gold-light: #F3E5AB;
  --gold-dark: #AA8C2C;
  --gold-gradient: linear-gradient(135deg, #D4AF37, #F3E5AB, #D4AF37);
  --teal: #0a4a4a;
  --teal-light: #0d6060;
  --text-primary: #F2F2F0;
  --text-secondary: #b0b0c0;
  --text-muted: #6a6a7a;
  --border-gold: rgba(212, 175, 55, 0.4);
  --border-teal: rgba(10, 74, 74, 0.6);
  --shadow-gold: 0 0 30px rgba(212, 175, 55, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  /* Prevent text size adjustment on orientation change (iOS/Android) */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  /* Subtle Islamic Pattern Base */
  background-image: url("data:image/svg+xml,%3Csvg width='28' height='49' viewBox='0 0 28 49' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4af37' fill-opacity='0.04'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v13.2l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.65V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  color: var(--text-primary);
  min-height: 100vh;
  /* iOS safe area support */
  min-height: -webkit-fill-available;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Smooth momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
  /* Prevent pull-to-refresh on mobile */
  overscroll-behavior-y: contain;
}

/* Top-left glowing blob */
body::before {
  content: '';
  position: fixed;
  top: -15%;
  left: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--gold-light) 0%, var(--gold) 40%, transparent 70%);
  border-radius: 50%;
  mix-blend-mode: screen;
  filter: blur(80px);
  opacity: 0.3;
  animation: pulseBlob 15s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
  transform: translateZ(0); /* Hardware acceleration */
}

/* Bottom-right glowing blob */
body::after {
  content: '';
  position: fixed;
  bottom: -15%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--gold) 0%, var(--gold-dark) 40%, transparent 70%);
  border-radius: 50%;
  mix-blend-mode: screen;
  filter: blur(80px);
  opacity: 0.3;
  animation: pulseBlob 15s ease-in-out infinite;
  animation-delay: 7.5s;
  pointer-events: none;
  z-index: 0;
  transform: translateZ(0); /* Hardware acceleration */
}

@keyframes pulseBlob {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1) translate(0, 0) translateZ(0);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.05) translate(15px, -15px) translateZ(0);
  }
}

/* ---- Layout ---- */
.page-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Contains the rotating ornaments */
}

/* Unique Rotating Geometric Mandalas */
.page-wrapper::before,
.page-wrapper::after {
  content: '';
  position: fixed;
  width: 900px;
  height: 900px;
  background-image: url("data:image/svg+xml,%3Csvg width='900' height='900' viewBox='0 0 900 900' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cg id='s'%3E%3Crect x='-200' y='-200' width='400' height='400' fill='none' stroke='%23d4af37' stroke-width='2'/%3E%3Crect x='-200' y='-200' width='400' height='400' fill='none' stroke='%23d4af37' stroke-width='2' transform='rotate(45)'/%3E%3C/g%3E%3Cg id='o'%3E%3Cuse href='%23s' transform='scale(1)' /%3E%3Cuse href='%23s' transform='scale(0.85) rotate(22.5)' /%3E%3Cuse href='%23s' transform='scale(0.7)' /%3E%3Cuse href='%23s' transform='scale(0.55) rotate(22.5)' /%3E%3Cuse href='%23s' transform='scale(0.4)' /%3E%3Ccircle cx='0' cy='0' r='282.8' fill='none' stroke='%23d4af37' stroke-width='1.5' stroke-dasharray='6 6' /%3E%3Ccircle cx='0' cy='0' r='315' fill='none' stroke='%23d4af37' stroke-width='1' /%3E%3Ccircle cx='0' cy='0' r='345' fill='none' stroke='%23d4af37' stroke-width='0.5' /%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23o' x='450' y='450' /%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.12; /* Subtle yet visible luxury */
  pointer-events: none;
  z-index: -1;
}

.page-wrapper::before {
  top: -300px;
  right: -300px;
  animation: spinSlow 90s linear infinite;
}

.page-wrapper::after {
  bottom: -300px;
  left: -300px;
  animation: spinSlowReverse 120s linear infinite;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes spinSlowReverse {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  /* iOS safe area horizontal padding */
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  width: 100%;
}

/* ---- Header ---- */
.page-header {
  text-align: center;
  padding: 48px 24px 32px;
}

.page-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 12px;
  /* drop-shadow-md equivalent */
  text-shadow: 0 4px 6px rgba(0, 0, 0, 0.5), 0 2px 20px rgba(212, 175, 55, 0.3);
}

.page-header p {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ---- Main Card (Glassmorphism) ---- */
.main-card {
  background: linear-gradient(145deg, rgba(10, 46, 46, 0.8), rgba(13, 53, 53, 0.6));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card), var(--shadow-gold);
  overflow: hidden;
  margin: 0 auto 40px;
  max-width: 1000px;
}

.main-card-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 500px;
}

/* ---- Flyer Section ---- */
.flyer-section {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.3), rgba(10, 46, 46, 0.3));
  border-right: 1px solid var(--border-gold);
}

.flyer-section img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.flyer-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  height: 100%;
}

.flyer-placeholder .event-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

.flyer-placeholder h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

.flyer-placeholder .event-subtitle {
  font-size: 1rem;
  color: var(--gold-light);
  margin-bottom: 24px;
  font-weight: 500;
}

.flyer-placeholder .event-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.flyer-placeholder .event-detail-item {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(196, 164, 74, 0.08);
  border: 1px solid rgba(196, 164, 74, 0.15);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.flyer-placeholder .event-detail-item .icon {
  font-size: 1.2rem;
  color: var(--gold);
  flex-shrink: 0;
}

.flyer-placeholder .event-detail-item span {
  color: var(--text-primary);
  font-weight: 500;
}

/* ---- Form Section ---- */
.form-section {
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.form-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.form-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ---- Form Elements ---- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  /* 16px prevents iOS auto-zoom on input focus */
  font-size: 16px;
  transition: var(--transition);
  outline: none;
  /* Remove iOS input shadow */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Minimum 44px touch target (Apple HIG) */
  min-height: 48px;
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196, 164, 74, 0.15), 0 0 20px rgba(196, 164, 74, 0.1);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  width: 100%;
  /* Minimum 44px touch target (Apple HIG / Material Design) */
  min-height: 48px;
  /* Remove iOS button styling */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Prevent text selection on double-tap */
  -webkit-user-select: none;
  user-select: none;
  /* Improve touch responsiveness */
  touch-action: manipulation;
}

.btn-primary {
  background: var(--gold-gradient);
  color: var(--bg-primary);
  box-shadow: 0 4px 15px rgba(196, 164, 74, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(196, 164, 74, 0.45);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

/* Disable hover effects on touch devices (prevents sticky hover on mobile) */
@media (hover: none) {
  .btn-primary:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(196, 164, 74, 0.3);
    filter: none;
  }
  .btn-outline:hover {
    background: transparent;
    border-color: var(--border-gold);
  }
  .stat-card:hover {
    transform: none;
  }
}

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

.btn-outline:hover {
  background: rgba(196, 164, 74, 0.1);
  border-color: var(--gold);
}

.btn-secondary {
  background: rgba(10, 74, 74, 0.5);
  color: var(--text-primary);
  border: 1px solid var(--border-teal);
}

.btn-secondary:hover {
  background: rgba(10, 74, 74, 0.8);
}

.btn-danger {
  background: rgba(180, 40, 40, 0.3);
  color: #ff6b6b;
  border: 1px solid rgba(180, 40, 40, 0.4);
}

.btn-danger:hover {
  background: rgba(180, 40, 40, 0.5);
}

.btn-sm {
  padding: 10px 16px;
  font-size: 0.85rem;
  /* Still maintain 44px min touch target */
  min-height: 44px;
}

/* ---- SVG Icon Utilities ---- */
.icon-svg {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  flex-shrink: 0;
  /* Inherit color from parent text */
  color: currentColor;
}

.icon-svg-sm {
  width: 0.85em;
  height: 0.85em;
}

.icon-svg-lg {
  width: 1.25em;
  height: 1.25em;
}

.icon-svg-xl {
  width: 1.5em;
  height: 1.5em;
}

/* Large decorative icons (success checkmark, lock, mosque hero) */
.icon-hero {
  width: 64px;
  height: 64px;
  display: block;
  margin: 0 auto;
  color: var(--gold);
}

.icon-hero-sm {
  width: 48px;
  height: 48px;
  display: block;
  margin: 0 auto;
  color: var(--gold);
}

.btn-icon {
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
}

.btn-icon .icon-svg {
  width: 1.1em;
  height: 1.1em;
}

/* ---- Alert / Error Messages ---- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-error {
  background: #dc2626;
  border: 2px solid #ef4444;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.5);
}

.alert-success {
  background: rgba(40, 180, 80, 0.15);
  border: 1px solid rgba(40, 180, 80, 0.3);
  color: #6bff8b;
}

.alert-warning {
  background: rgba(196, 164, 74, 0.15);
  border: 1px solid rgba(196, 164, 74, 0.3);
  color: var(--gold-light);
}

.alert-gift {
  background: linear-gradient(135deg, rgba(196, 164, 74, 0.2), rgba(40, 180, 80, 0.15));
  border: 1px solid var(--gold);
  color: var(--gold-light);
  font-size: 1.05rem;
  padding: 18px 22px;
  animation: giftPulse 2s infinite;
}

@keyframes giftPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196, 164, 74, 0.3); }
  50% { box-shadow: 0 0 20px 5px rgba(196, 164, 74, 0.15); }
}

/* ---- Success Page ---- */
.success-container {
  text-align: center;
  padding: 48px 24px;
}

.success-card {
  background: linear-gradient(145deg, rgba(10, 46, 46, 0.8), rgba(13, 53, 53, 0.6));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card), var(--shadow-gold);
  padding: 48px;
  max-width: 550px;
  margin: 0 auto;
}

.success-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.success-card h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.success-card .participant-name,
.success-card .participant-phone {
  font-size: 1.2rem;
  color: var(--gold);
  margin-bottom: 0;
  font-weight: 600;
}

.success-card .participant-name {
  text-transform: uppercase;
}

.success-card .participant-phone {
  border-left: 1px solid var(--border-teal);
  padding-left: 15px;
}

.qr-wrapper {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 20px;
  display: inline-block;
  margin-bottom: 28px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.qr-wrapper img {
  display: block;
  width: 250px;
  height: 250px;
}

.qr-id {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-family: monospace;
  word-break: break-all;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.success-instruction {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 20px;
  padding: 12px;
  background: rgba(196, 164, 74, 0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(196, 164, 74, 0.15);
}

/* ---- Footer ---- */
.page-footer {
  text-align: center;
  padding: 24px;
  /* iOS safe area bottom padding */
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}

.page-footer .heart {
  color: #e74c3c;
}

/* ---- Admin Login ---- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: linear-gradient(145deg, rgba(10, 46, 46, 0.8), rgba(13, 53, 53, 0.6));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card), var(--shadow-gold);
  padding: 48px;
  width: 100%;
  max-width: 420px;
}

.login-card h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.login-card .login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 32px;
}

.login-card .lock-icon {
  text-align: center;
  font-size: 3rem;
  margin-bottom: 16px;
}

/* ---- Admin Dashboard ---- */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: rgba(10, 46, 46, 0.6);
  border-bottom: 1px solid var(--border-gold);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  color: var(--gold);
  font-size: 1.3rem;
}

.admin-header .nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-header .nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.admin-header .nav-links a:hover,
.admin-header .nav-links a.active {
  color: var(--gold);
  background: rgba(196, 164, 74, 0.1);
}

.dashboard-content {
  padding: 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

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

.stat-card {
  background: linear-gradient(145deg, rgba(10, 46, 46, 0.6), rgba(13, 53, 53, 0.4));
  border: 1px solid var(--border-teal);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-gold);
  transform: translateY(-2px);
}

.stat-card .stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card.highlight {
  border-color: var(--gold);
  background: linear-gradient(145deg, rgba(196, 164, 74, 0.1), rgba(10, 46, 46, 0.6));
}

/* ---- Data Table ---- */
.table-container {
  background: linear-gradient(145deg, rgba(10, 46, 46, 0.5), rgba(13, 53, 53, 0.3));
  border: 1px solid var(--border-teal);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-teal);
  flex-wrap: wrap;
  gap: 12px;
}

.table-header h3 {
  color: var(--gold);
  font-size: 1rem;
  font-weight: 700;
}

.search-input {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  /* 16px prevents iOS auto-zoom */
  font-size: 16px;
  outline: none;
  min-width: 200px;
  min-height: 44px;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(196, 164, 74, 0.15);
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border-teal);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  /* Min touch target */
  min-height: 36px;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.filter-btn:hover,
.filter-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(196, 164, 74, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-teal);
  background: rgba(0, 0, 0, 0.2);
}

table tbody td {
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(10, 74, 74, 0.2);
}

table tbody tr:hover {
  background: rgba(196, 164, 74, 0.05);
}

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

.badge-success {
  background: rgba(40, 180, 80, 0.15);
  color: #6bff8b;
  border: 1px solid rgba(40, 180, 80, 0.3);
}

.badge-pending {
  background: rgba(196, 164, 74, 0.15);
  color: var(--gold-light);
  border: 1px solid rgba(196, 164, 74, 0.3);
}

.badge-gift {
  background: rgba(196, 164, 74, 0.2);
  color: var(--gold);
  border: 1px solid var(--gold);
}

/* ---- Scanner Page ---- */
.scanner-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 32px 24px;
}

.scanner-box {
  background: linear-gradient(145deg, rgba(10, 46, 46, 0.8), rgba(13, 53, 53, 0.6));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.scanner-video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #000;
}

.scanner-video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scanner-frame {
  width: 60%;
  aspect-ratio: 1;
  border: 3px solid var(--gold);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  animation: scanPulse 2s infinite;
}

@keyframes scanPulse {
  0%, 100% { border-color: var(--gold); }
  50% { border-color: var(--gold-light); box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), 0 0 30px rgba(196, 164, 74, 0.3); }
}

.scanner-controls {
  padding: 20px;
  text-align: center;
}

.scan-result {
  padding: 20px;
  border-top: 1px solid var(--border-teal);
}

.scan-result-card {
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
}

.scan-result-card h3 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.scan-result-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.gift-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(196, 164, 74, 0.1);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  color: var(--gold);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* Manual input */
.manual-input-section {
  padding: 20px;
  border-top: 1px solid var(--border-teal);
}

.manual-input-section h4 {
  color: var(--gold);
  font-size: 0.85rem;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group input {
  flex: 1;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  /* 16px prevents iOS auto-zoom */
  font-size: 16px;
  outline: none;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}

.input-group input:focus {
  border-color: var(--gold);
}

.input-group .btn {
  width: auto;
  white-space: nowrap;
}

/* ---- 404 & Error Pages ---- */
.error-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
}

.error-container h1 {
  font-size: 6rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 8px;
}

.error-container p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ---- Responsive ---- */

/* Tablets & small laptops */
@media (max-width: 768px) {
  .main-card-inner {
    grid-template-columns: 1fr;
  }

  .flyer-section {
    border-right: none;
    border-bottom: 1px solid var(--border-gold);
    min-height: auto;
  }

  .flyer-placeholder {
    padding: 28px 20px;
  }

  .flyer-placeholder .event-icon {
    font-size: 3rem;
    margin-bottom: 12px;
  }

  .flyer-placeholder h2 {
    font-size: 1.4rem;
  }

  .form-section {
    padding: 28px 20px;
  }

  .page-header {
    padding: 32px 16px 24px;
  }

  .page-header h1 {
    font-size: 1.5rem;
    letter-spacing: 1px;
  }

  .page-header p {
    font-size: 0.9rem;
  }

  .success-card {
    padding: 28px 20px;
  }

  .qr-wrapper {
    padding: 16px;
  }

  .qr-wrapper img {
    width: 220px;
    height: 220px;
  }

  .admin-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    padding: 16px;
  }

  .admin-header .brand {
    font-size: 0.95rem;
  }

  .admin-header .nav-links {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .admin-header .nav-links a {
    font-size: 0.8rem;
    padding: 8px 10px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-card .stat-value {
    font-size: 2rem;
  }

  .dashboard-content {
    padding: 20px 16px;
  }

  .table-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 16px;
  }

  .search-input {
    width: 100%;
    min-width: unset;
  }

  table {
    display: table;
    min-width: 800px;
  }

  table thead th,
  table tbody td {
    padding: 10px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .login-card {
    padding: 28px 20px;
  }

  .scanner-container {
    padding: 20px 16px;
  }

  .scanner-controls {
    padding: 16px;
  }

  .manual-input-section {
    padding: 16px;
  }

  .container {
    padding: 0 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card .stat-value {
    font-size: 1.6rem;
  }

  .stat-card .stat-label {
    font-size: 0.7rem;
  }

  .page-header h1 {
    font-size: 1.2rem;
  }

  .flyer-placeholder h2 {
    font-size: 1.2rem;
  }

  .success-card h2 {
    font-size: 1.2rem;
  }

  .qr-wrapper img {
    width: 200px;
    height: 200px;
  }

  .form-title {
    font-size: 1.1rem;
  }

  .main-card {
    margin: 0 auto 24px;
  }

  .input-group {
    flex-direction: column;
  }

  .input-group .btn {
    width: 100%;
  }

  .filter-group {
    width: 100%;
    justify-content: flex-start;
  }

  .error-container h1 {
    font-size: 4rem;
  }
}

/* Very small phones (320px like iPhone SE) */
@media (max-width: 360px) {
  .page-header h1 {
    font-size: 1.05rem;
    letter-spacing: 0.5px;
  }

  .flyer-placeholder h2 {
    font-size: 1.05rem;
  }

  .flyer-placeholder .event-detail-item {
    font-size: 0.8rem;
    padding: 8px 12px;
  }

  .form-section {
    padding: 20px 16px;
  }

  .success-card {
    padding: 24px 16px;
  }

  .qr-wrapper img {
    width: 180px;
    height: 180px;
  }

  .stat-card .stat-value {
    font-size: 1.4rem;
  }

  .login-card {
    padding: 24px 16px;
  }
}

/* ---- Animations ---- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.5s ease-out forwards;
}

.animate-in-delay-1 { animation-delay: 0.1s; opacity: 0; }
.animate-in-delay-2 { animation-delay: 0.2s; opacity: 0; }
.animate-in-delay-3 { animation-delay: 0.3s; opacity: 0; }

/* ---- Loading Spinner ---- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(196, 164, 74, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Scrollbar (desktop only) ---- */
@media (pointer: fine) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: var(--bg-primary);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--teal);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--teal-light);
  }
}

/* ---- Mobile-specific fixes ---- */

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .page-header {
    padding: 16px;
  }

  .flyer-section {
    display: none;
  }

  .main-card-inner {
    grid-template-columns: 1fr;
  }

  .success-container {
    padding: 16px;
  }

  .login-container {
    padding: 16px;
  }
}

/* Fix html5-qrcode library styles for mobile */
#qr-reader {
  border: none !important;
  width: 100% !important;
}

#qr-reader video {
  width: 100% !important;
  height: auto !important;
  object-fit: cover;
  border-radius: 0;
}

#qr-reader__scan_region {
  min-height: 250px;
}

#qr-reader__dashboard {
  padding: 8px !important;
}

#qr-reader__dashboard button {
  background: var(--gold-gradient) !important;
  color: var(--bg-primary) !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
  padding: 10px 16px !important;
  font-family: 'Inter', sans-serif !important;
  font-weight: 600 !important;
  min-height: 44px !important;
  cursor: pointer !important;
  touch-action: manipulation;
}

#qr-reader__dashboard select {
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-gold) !important;
  border-radius: var(--radius-sm) !important;
  padding: 8px 12px !important;
  font-size: 16px !important;
  min-height: 44px !important;
  -webkit-appearance: none !important;
}

/* Ensure tap highlight color matches theme */
* {
  -webkit-tap-highlight-color: rgba(196, 164, 74, 0.15);
}

/* Select elements styling for mobile */
select {
  font-size: 16px;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}

/* Ensure images don't overflow on mobile */
img {
  max-width: 100%;
  height: auto;
}

/* ---- Modal ---- */
.modal {
  display: none; 
  position: fixed; 
  z-index: 1000; 
  left: 0;
  top: 0;
  width: 100%; 
  height: 100%; 
  overflow: auto; 
  background-color: rgba(13, 13, 26, 0.8); 
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.show {
  display: block;
  opacity: 1;
}

.modal-content {
  background: linear-gradient(145deg, rgba(10, 46, 46, 0.95), rgba(13, 53, 53, 0.9));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  margin: 15% auto; 
  padding: 30px;
  width: 90%; 
  max-width: 450px;
  box-shadow: var(--shadow-card), var(--shadow-gold);
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.modal.show .modal-content {
  transform: translateY(0);
}

.close-modal {
  color: var(--text-secondary);
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition);
}

.close-modal:hover,
.close-modal:focus {
  color: var(--gold);
  text-decoration: none;
}
