/* ============================================
   Event Registration System – Global Styles
   Dynamic theme via CSS variables (primary/secondary)
   ============================================ */

:root {
  --primary: #0a4d8c;
  --primary-dark: #073a6c;
  --primary-light: #1a6dbf;
  --secondary: #d4af37;
  --secondary-dark: #b8932a;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1a2233;
  --text-muted: #5a6378;
  --border: #e6e9f0;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow-sm: 0 2px 8px rgba(20, 32, 60, 0.06);
  --shadow-md: 0 6px 20px rgba(20, 32, 60, 0.08);
  --shadow-lg: 0 20px 50px rgba(20, 32, 60, 0.12);
  --radius: 12px;
  --radius-lg: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body[dir="rtl"] {
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

button, input, select, textarea {
  font: inherit;
}

/* ------------ Layout ------------ */
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* ------------ Top Bar ------------ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 700; font-size: 17px; color: var(--primary);
}
.brand img {
  height: 38px; width: auto; object-fit: contain;
  border-radius: 6px;
}
.brand-fallback {
  width: 38px; height: 38px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
}

.top-actions { display: flex; align-items: center; gap: 10px; }

/* ------------ Language toggle ------------ */
.lang-toggle {
  display: inline-flex; gap: 4px; padding: 4px;
  background: #eef1f7; border-radius: 30px;
}
.lang-toggle button {
  background: transparent; border: 0; padding: 6px 14px;
  border-radius: 30px; cursor: pointer; font-weight: 600;
  color: var(--text-muted); transition: all .2s;
}
.lang-toggle button.active {
  background: var(--primary); color: #fff;
}

/* ------------ Hero ------------ */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 60%, var(--primary-light) 100%);
  color: #fff;
  padding: 60px 20px 80px;
  overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 90% 10%, rgba(255,255,255,.18) 0, transparent 35%),
    radial-gradient(circle at 10% 100%, rgba(255,255,255,.12) 0, transparent 30%);
  pointer-events: none;
}
.hero-inner {
  position: relative; max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center;
}
.hero h1 {
  margin: 0 0 14px; font-size: 38px; line-height: 1.2;
  font-weight: 800;
}
.hero p { font-size: 17px; opacity: .92; line-height: 1.7; margin: 0 0 22px; max-width: 600px; }
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px;
}
.hero-meta .pill {
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.25);
  padding: 8px 14px; border-radius: 30px; font-size: 14px;
  backdrop-filter: blur(6px);
}
.hero-cta {
  display: inline-block; margin-top: 26px;
  background: var(--secondary); color: #1c1500;
  padding: 14px 32px; border-radius: 30px;
  font-weight: 700; font-size: 16px;
  box-shadow: 0 8px 22px rgba(212,175,55,.45);
  transition: transform .2s, box-shadow .2s;
  border: 0; cursor: pointer;
}
.hero-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(212,175,55,.6);
}

.hero-card {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: var(--radius-lg);
  padding: 26px;
  backdrop-filter: blur(8px);
}
.hero-card h3 { margin: 0 0 12px; font-weight: 700; font-size: 18px; }
.hero-card .stat { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.18); }
.hero-card .stat:last-child { border-bottom: 0; }
.hero-card .stat .v { font-weight: 700; font-size: 18px; }

@media (max-width: 860px) {
  .hero { padding: 40px 20px 60px; }
  .hero h1 { font-size: 28px; }
  .hero-inner { grid-template-columns: 1fr; gap: 28px; }
}

/* ------------ Cards ------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 26px;
}
.card h2 { margin: 0 0 6px; font-size: 22px; }
.card .subtitle { color: var(--text-muted); margin: 0 0 22px; }

/* ------------ Forms ------------ */
.form-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.field label .req { color: var(--danger); margin: 0 4px; }
.field input, .field select, .field textarea {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10,77,140,.12);
}
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--text-muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff;
  border: 0; padding: 12px 22px; border-radius: 10px;
  font-weight: 700; cursor: pointer;
  transition: filter .15s, transform .1s;
  box-shadow: 0 4px 12px rgba(10,77,140,.25);
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--secondary); color: #1c1500; box-shadow: 0 4px 12px rgba(212,175,55,.4); }
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); box-shadow: none; }
.btn.danger { background: var(--danger); box-shadow: 0 4px 12px rgba(220,38,38,.3); }
.btn.success { background: var(--success); box-shadow: 0 4px 12px rgba(22,163,74,.3); }
.btn.lg { padding: 14px 28px; font-size: 16px; }
.btn.sm { padding: 8px 14px; font-size: 13px; }
.btn.block { width: 100%; }

/* Checkbox / sessions */
.sessions-list {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.session-card {
  border: 1.5px solid var(--border);
  border-radius: 12px; padding: 14px;
  cursor: pointer; transition: all .15s;
  background: #fbfcfe; position: relative;
}
.session-card:hover { border-color: var(--primary-light); }
.session-card.selected {
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(10,77,140,.05), #fff);
  box-shadow: 0 4px 14px rgba(10,77,140,.12);
}
.session-card .sc-title { font-weight: 700; margin: 0 0 4px; }
.session-card .sc-meta { font-size: 12px; color: var(--text-muted); }
.session-card .sc-check {
  position: absolute; top: 10px; inset-inline-end: 10px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); background: #fff;
  display: grid; place-items: center;
}
.session-card.selected .sc-check {
  background: var(--primary); border-color: var(--primary);
  color: #fff;
}

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table.t {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
table.t th, table.t td {
  padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.t th { background: #fafbfd; font-weight: 700; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table.t tr:hover td { background: #f9fbfe; }

/* Badges */
.badge { display: inline-block; padding: 4px 10px; border-radius: 30px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.no { background: #fee2e2; color: #991b1b; }
.badge.warn { background: #fef3c7; color: #92400e; }

/* Stats grid */
.stats {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 26px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; top: 0; inset-inline-start: 0;
  width: 4px; height: 100%; background: var(--primary);
}
.stat-card .label { color: var(--text-muted); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-card .delta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-card.gold::before { background: var(--secondary); }
.stat-card.green::before { background: var(--success); }
.stat-card.red::before { background: var(--danger); }

/* Toast */
.toast-wrap { position: fixed; top: 20px; inset-inline-end: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #fff; padding: 14px 18px; border-radius: 10px;
  box-shadow: var(--shadow-lg); border-inline-start: 5px solid var(--primary);
  min-width: 260px; max-width: 360px;
  animation: slideIn .25s ease;
}
.toast.ok { border-color: var(--success); }
.toast.err { border-color: var(--danger); }
.toast.warn { border-color: var(--warning); }
.toast h4 { margin: 0 0 4px; font-size: 14px; }
.toast p { margin: 0; font-size: 13px; color: var(--text-muted); }
@keyframes slideIn { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px; backdrop-filter: blur(2px);
}
.modal-back.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; max-width: 560px; width: 100%;
  max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg);
}
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal header h3 { margin: 0; }
.modal .x { background: transparent; border: 0; font-size: 22px; cursor: pointer; color: var(--text-muted); }
.modal .body { padding: 22px; }
.modal footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Loading */
.loader {
  display: inline-block; width: 20px; height: 20px;
  border: 3px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.full-loader {
  display: grid; place-items: center; padding: 60px 0;
  color: var(--text-muted); flex-direction: column;
}
.full-loader .ring {
  width: 48px; height: 48px;
  border: 4px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
  margin-bottom: 14px;
}

/* Empty state */
.empty {
  text-align: center; padding: 50px 20px; color: var(--text-muted);
}
.empty .icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: #eef1f7; display: inline-grid; place-items: center;
  font-size: 28px; margin-bottom: 12px;
}

/* Utilities */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mt-12 { margin-top: 12px; } .mt-18 { margin-top: 18px; } .mt-24 { margin-top: 24px; }
.text-center { text-align: center; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.success-text { color: var(--success); font-weight: 700; }
.danger-text { color: var(--danger); font-weight: 700; }

/* Footer */
.footer { text-align: center; padding: 28px 20px; color: var(--text-muted); font-size: 13px; }
.footer a { color: var(--primary); }

/* Ticket page */
.ticket {
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin: 40px auto;
  max-width: 620px;
  border: 1px solid var(--border);
}
.ticket-head {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; padding: 28px 24px; position: relative;
}
.ticket-head::after {
  content: ""; position: absolute; bottom: -14px; left: 0; right: 0; height: 28px;
  background: radial-gradient(circle at 14px center, transparent 14px, #fff 14.5px);
  background-size: 28px 28px;
}
.ticket-head h2 { margin: 0; font-size: 22px; }
.ticket-head .org { opacity: .85; font-size: 14px; margin-top: 4px; }
.ticket-body { padding: 30px 24px 20px; text-align: center; }
.ticket-body img.qr {
  width: 240px; height: 240px;
  padding: 12px;
  background: #fff;
  border: 6px solid var(--secondary);
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(212,175,55,.25);
}
.ticket-body .uid {
  margin-top: 14px; font-family: 'Courier New', monospace;
  letter-spacing: 2px; font-size: 15px; color: var(--text-muted);
}
.ticket-details {
  border-top: 1px dashed var(--border);
  padding: 22px 24px; display: grid; gap: 8px;
  grid-template-columns: repeat(2, 1fr);
  font-size: 14px;
}
.ticket-details .k { color: var(--text-muted); font-size: 12px; }
.ticket-details .v { font-weight: 700; }
@media (max-width: 600px) { .ticket-details { grid-template-columns: 1fr; } }
.print-only { display: none; }
@media print {
  .topbar, .footer, .no-print { display: none !important; }
  body { background: #fff; }
  .ticket { box-shadow: none; border: 0; }
}

/* Admin layout */
.admin-grid {
  display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 65px);
}
.sidebar {
  background: #fff; border-inline-end: 1px solid var(--border);
  padding: 20px 16px;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 8px;
  color: var(--text); font-weight: 600; font-size: 14px;
  transition: background .15s;
}
.sidebar a:hover { background: #f5f7fb; }
.sidebar a.active { background: var(--primary); color: #fff; }
.sidebar a .ic { width: 18px; text-align: center; }
.main-pane { padding: 26px; }
@media (max-width: 820px) {
  .admin-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* Scanner */
.scanner-wrap {
  max-width: 520px; margin: 0 auto;
  background: #000; border-radius: var(--radius-lg);
  overflow: hidden; position: relative;
  aspect-ratio: 1 / 1;
}
.scanner-wrap video, .scanner-wrap canvas { width: 100%; height: 100%; object-fit: cover; }
.scanner-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, transparent 30%, transparent 70%, rgba(0,0,0,.55) 100%);
  pointer-events: none;
}
.scanner-frame {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 70%; aspect-ratio: 1; border: 3px solid var(--secondary);
  border-radius: 12px; box-shadow: 0 0 0 200px rgba(0,0,0,.3);
}
.scanner-frame::before, .scanner-frame::after,
.scanner-frame > span:first-child, .scanner-frame > span:last-child {
  content: ""; position: absolute; width: 28px; height: 28px;
  border: 4px solid var(--secondary);
}
.scanner-frame::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.scanner-frame::after { top: -3px; right: -3px; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.scanner-frame > span:first-child { bottom: -3px; left: -3px; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.scanner-frame > span:last-child { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }

.scan-result {
  margin-top: 20px; padding: 22px;
  border-radius: var(--radius-lg); text-align: center;
  background: #fff; box-shadow: var(--shadow-md);
}
.scan-result.ok { background: linear-gradient(180deg, #ecfdf5, #fff); border: 1.5px solid #86efac; }
.scan-result.dup { background: linear-gradient(180deg, #fffbeb, #fff); border: 1.5px solid #fde68a; }
.scan-result.err { background: linear-gradient(180deg, #fef2f2, #fff); border: 1.5px solid #fecaca; }
.scan-result .big { font-size: 28px; font-weight: 800; margin: 6px 0; }

/* Color picker squares */
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 50px; height: 38px; padding: 0; border-radius: 8px; cursor: pointer; border: 1.5px solid var(--border); }
