/* ===========================================================
   هوية مُستدام البصرية
   الألوان الأساسية:
   - أخضر (البيئة):    #83c142
   - برتقالي (الاقتصاد): #eca14c
   - تركواز (الثقافة):  #1abab8
   - سماوي (الاجتماع):  #1fbbed
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;900&display=swap');

:root {
  --green:     #83c142;
  --orange:    #eca14c;
  --turquoise: #1abab8;
  --sky:       #1fbbed;

  --green-light:     #cdecc3;
  --green-mid:       #A7E3B5;
  --green-dark:      #1E6838;

  --orange-light:    #FFD6B1;
  --orange-mid:      #FFB370;
  --orange-dark:     #C9642B;

  --turquoise-light: #BCE8E9;
  --turquoise-mid:   #66C7C9;
  --turquoise-dark:  #1B7A7E;

  --sky-light:       #D7ECFF;
  --sky-mid:         #7CBDF5;
  --sky-dark:        #2A5E9A;

  --text:    #1a2a3a;
  --muted:   #6b7a8a;
  --bg:      #f6fbf9;
  --white:   #ffffff;
  --border:  #e4ecf3;

  --radius:  18px;
  --shadow:  0 10px 30px rgba(26, 42, 58, 0.08);
  --shadow-lg: 0 20px 60px rgba(26, 42, 58, 0.12);

  --gradient-brand: linear-gradient(135deg,
    var(--green) 0%,
    var(--turquoise) 35%,
    var(--sky) 70%,
    var(--orange) 100%);
}

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

html, body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(circle at 10% 10%, rgba(131,193,66,0.08) 0, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(31,187,237,0.08) 0, transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(236,161,76,0.06) 0, transparent 40%),
    var(--bg);
}

/* ------------------ Layout ------------------ */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
}

.card {
  width: 100%;
  max-width: 640px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: var(--gradient-brand);
}

.card-wide { max-width: 920px; }

/* ------------------ Header ------------------ */
.brand {
  text-align: center;
  margin-bottom: 24px;
}

.brand img {
  width: 110px;
  height: auto;
  margin: 0 auto 12px;
  display: block;
}

.brand .tagline {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.5px;
  font-style: italic;
}

h1 {
  font-size: 28px;
  font-weight: 900;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}

h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--turquoise-dark);
  margin-bottom: 12px;
}

h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

p { color: #3a4858; }

.lead {
  font-size: 16px;
  text-align: center;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ------------------ Event Info ------------------ */
.event-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.info-card {
  background: linear-gradient(135deg, var(--white) 0%, var(--bg) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: transform .2s, box-shadow .2s;
}

.info-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.info-card .icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 18px;
}

.info-card.green   .icon { background: var(--green); }
.info-card.orange  .icon { background: var(--orange); }
.info-card.turq    .icon { background: var(--turquoise); }
.info-card.sky     .icon { background: var(--sky); }

.info-card .label {
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-bottom: 2px;
}

.info-card .value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

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

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

.form-group label .required {
  color: var(--orange-dark);
  font-weight: 700;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  background: var(--white);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
  direction: rtl;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--turquoise);
  box-shadow: 0 0 0 4px rgba(26, 186, 184, 0.12);
}

.form-group .hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ------------------ Phone input with country code ------------------ */
.phone-input-wrap {
  display: flex;
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--white);
  direction: ltr;
  transition: border-color .2s, box-shadow .2s;
}

.phone-input-wrap:focus-within {
  border-color: var(--turquoise);
  box-shadow: 0 0 0 4px rgba(26, 186, 184, 0.12);
}

.phone-prefix {
  padding: 12px 14px;
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  border-right: 2px solid var(--border);
  display: flex;
  align-items: center;
  white-space: nowrap;
  user-select: none;
}

.phone-input-wrap input {
  border: none !important;
  flex: 1;
  border-radius: 0 !important;
  background: transparent !important;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px;
  direction: ltr;
  text-align: left;
  letter-spacing: 1px;
  width: 100%;
  min-width: 0;
}

.phone-input-wrap input:focus {
  outline: none !important;
  box-shadow: none !important;
}

/* ------------------ Buttons ------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, background .2s;
  text-decoration: none;
  min-height: 50px;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--gradient-brand);
  color: var(--white);
  box-shadow: 0 8px 20px rgba(26, 186, 184, 0.25);
}

.btn-primary:hover { box-shadow: 0 12px 28px rgba(26, 186, 184, 0.35); }

.btn-secondary {
  background: var(--white);
  color: var(--muted);
  border: 2px solid var(--border);
}

.btn-secondary:hover { border-color: var(--orange); color: var(--orange-dark); }

.btn-block { width: 100%; }

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

@media (max-width: 480px) {
  .btn-group { flex-direction: column; }
}

/* ------------------ Status / Alerts ------------------ */
.alert {
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 500;
}

.alert-success { background: var(--green-light); color: var(--green-dark); border-right: 4px solid var(--green); }
.alert-error   { background: #ffe0e0; color: #a03030; border-right: 4px solid #d04040; }
.alert-info    { background: var(--sky-light); color: var(--sky-dark); border-right: 4px solid var(--sky); }
.alert-warning { background: var(--orange-light); color: var(--orange-dark); border-right: 4px solid var(--orange); }

.alert-hidden { display: none; }

/* ------------------ Ticket / Success ------------------ */
.success-icon {
  width: 80px;
  height: 80px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--white);
  font-size: 40px;
  animation: pop .4s ease-out;
}

@keyframes pop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.ticket {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px dashed var(--turquoise);
  position: relative;
  margin: 20px 0;
}

.ticket-header {
  background: var(--gradient-brand);
  color: var(--white);
  padding: 20px;
  text-align: center;
}

.ticket-header h3 { color: var(--white); margin: 0; }
.ticket-header .sub { font-size: 13px; opacity: 0.9; }

.ticket-body {
  padding: 28px 20px;
  text-align: center;
}

.ticket-body .name {
  font-size: 22px;
  font-weight: 900;
  margin: 12px 0 4px;
  color: var(--text);
}

.ticket-body .id {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.qr-wrap {
  background: var(--white);
  padding: 14px;
  border-radius: 12px;
  display: inline-block;
  border: 1px solid var(--border);
  margin: 8px auto;
}

.ticket-footer {
  border-top: 1px dashed var(--border);
  padding: 16px;
  display: flex;
  justify-content: space-around;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-footer .item {
  text-align: center;
  font-size: 13px;
}

.ticket-footer .item .l { color: var(--muted); display: block; font-size: 11px; }
.ticket-footer .item .v { color: var(--text); font-weight: 700; }

/* ------------------ Mode toggle (scanner) ------------------ */
.mode-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
  margin: 16px 0 6px;
  border: 1px solid var(--border);
  gap: 4px;
}

.mode-btn {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.mode-btn:hover { color: var(--text); }

.mode-btn.active {
  background: var(--white);
  color: var(--turquoise-dark);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.mode-hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ------------------ Settings card (admin) ------------------ */
.settings-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
  padding: 16px 20px;
  transition: box-shadow 0.2s;
}

.settings-card[open] {
  box-shadow: var(--shadow);
}

.settings-card summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  color: var(--turquoise-dark);
  user-select: none;
  list-style: none;
  padding: 4px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-card summary::-webkit-details-marker { display: none; }

.settings-card summary::after {
  content: '▼';
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.2s;
}

.settings-card[open] summary::after { transform: rotate(180deg); }

.settings-body {
  padding-top: 18px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.settings-section {
  font-size: 14px;
  color: var(--turquoise-dark);
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px dashed var(--border);
  font-weight: 700;
}

.settings-section:first-child { margin-top: 0; }

.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  background: var(--white);
  color: var(--text);
  direction: rtl;
  resize: vertical;
  min-height: 70px;
  transition: border-color .2s, box-shadow .2s;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--turquoise);
  box-shadow: 0 0 0 4px rgba(26, 186, 184, 0.12);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 14px;
}

.checkbox-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  transition: border-color 0.2s;
}

.checkbox-label:hover { border-color: var(--turquoise); }

.checkbox-label input[type="checkbox"] {
  width: 20px !important;
  height: 20px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--turquoise);
}

.checkbox-label span {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* ------------------ Filter chips (admin) ------------------ */
.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip:hover { border-color: var(--turquoise); color: var(--text); }

.chip.active {
  background: var(--turquoise);
  color: var(--white);
  border-color: var(--turquoise);
}

.chip .count {
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.chip.active .count { background: rgba(255, 255, 255, 0.25); }

/* ------------------ Row actions (admin table) ------------------ */
.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
  padding: 0;
}

.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.icon-btn.icon-checkin:hover  { border-color: var(--green);     color: var(--green-dark); }
.icon-btn.icon-uncheck:hover  { border-color: var(--orange);    color: var(--orange-dark); }
.icon-btn.icon-ticket:hover   { border-color: var(--turquoise); color: var(--turquoise-dark); }
.icon-btn.icon-delete:hover   { border-color: #d04040;          color: #a03030; }

.icon-btn.icon-checkin { color: var(--green-dark); }
.icon-btn.icon-uncheck { color: var(--orange-dark); }

/* ------------------ Scanner page ------------------ */
.scanner-box {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 1 / 1;
  max-width: 480px;
  margin: 0 auto;
}

#qr-reader { width: 100%; }
#qr-reader video { width: 100% !important; height: auto !important; }

.scanner-status {
  margin-top: 20px;
  padding: 18px;
  border-radius: 14px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}

.status-idle    { background: var(--bg); color: var(--muted); }
.status-success { background: var(--green-light); color: var(--green-dark); }
.status-error   { background: #ffe0e0; color: #a03030; }
.status-warning { background: var(--orange-light); color: var(--orange-dark); }

/* ------------------ Confirmation panel (after scan) ------------------ */
.confirm-panel {
  margin-top: 16px;
  padding: 24px 20px;
  background: var(--white);
  border-radius: 16px;
  border: 2px solid var(--turquoise);
  box-shadow: 0 10px 30px rgba(26, 186, 184, 0.18);
  text-align: center;
  animation: slideUp .25s ease-out;
}

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

.confirm-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: var(--white);
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.confirm-panel h3 {
  font-size: 22px;
  margin-bottom: 10px;
  color: var(--text);
}

.confirm-meta {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.confirm-companions {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

.confirm-id {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #b0b8c0;
  margin-bottom: 18px;
  letter-spacing: 1px;
}

.confirm-panel.checked-in {
  border-color: var(--orange);
  box-shadow: 0 10px 30px rgba(236, 161, 76, 0.18);
}

.confirm-panel.declined {
  border-color: #d04040;
  box-shadow: 0 10px 30px rgba(208, 64, 64, 0.18);
}

.confirm-panel.checked-in .confirm-avatar {
  background: var(--orange);
}

.confirm-panel.declined .confirm-avatar {
  background: #d04040;
}

/* ------------------ Admin table ------------------ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}

.stat .num { font-size: 32px; font-weight: 900; line-height: 1; }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 4px; }

.stat.total   .num { color: var(--turquoise-dark); }
.stat.coming  .num { color: var(--green-dark); }
.stat.checked .num { color: var(--sky-dark); }
.stat.absent  .num { color: var(--orange-dark); }

.table-wrap {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 12px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg);
  font-weight: 700;
  color: var(--turquoise-dark);
  font-size: 13px;
  position: sticky;
  top: 0;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(26, 186, 184, 0.04); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-coming   { background: var(--green-light);   color: var(--green-dark); }
.badge-checked  { background: var(--sky-light);     color: var(--sky-dark); }
.badge-declined { background: #ffe0e0;              color: #a03030; }

.table-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.search-input {
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  width: 240px;
  max-width: 100%;
}

/* ------------------ Loading ------------------ */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--turquoise);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.hidden { display: none !important; }

/* ------------------ Print (for ticket printing) ------------------ */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  body { background: var(--white); }
  .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  .ticket { page-break-inside: avoid; }
  #qrCode img,
  #qrCode canvas,
  #qrCode table {
    display: block !important;
    margin: 0 auto !important;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
  }
  .ticket-header { background: var(--turquoise-dark) !important; }
}

/* QR container display */
#qrCode img,
#qrCode canvas {
  display: block;
  margin: 0 auto;
}
#qrCode table {
  margin: 0 auto;
  border-collapse: collapse;
}
#qrCode table td {
  padding: 0 !important;
  border: none !important;
  width: 4px;
  height: 4px;
}

/* ------------------ Mobile ------------------ */
@media (max-width: 480px) {
  .card { padding: 28px 18px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  .brand img { width: 90px; }
}

/* ------------------ Footer ------------------ */
.footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 13px;
}

.footer .brand-strip {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 8px;
}
.footer .dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.footer .dot.g { background: var(--green); }
.footer .dot.o { background: var(--orange); }
.footer .dot.t { background: var(--turquoise); }
.footer .dot.s { background: var(--sky); }
