/* ─────────────────────────────────────────────────────────────────────────────
   NABD Loyalty — Promoter Validation Portal
   Palette:
     Primary green  : #006633
     Gold accent    : #D9A441
     Background     : #F7F8FA
     Subtle text    : #666666
   ───────────────────────────────────────────────────────────────────────────── */

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

:root {
  --green:   #006633;
  --green-light: #00884a;
  --gold:    #D9A441;
  --gold-light: #f0c060;
  --bg:      #F7F8FA;
  --card:    #ffffff;
  --text:    #1a1a1a;
  --subtle:  #666666;
  --border:  #e4e7ec;
  --danger:  #d32f2f;
  --success: #2e7d32;
  --radius:  16px;
  --shadow:  0 4px 24px rgba(0,0,0,0.08);
}

html { font-size: 16px; }

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

/* ── Utility ── */
.hidden { display: none !important; }

/* ─────────────────────────── LOADING SCREEN ─────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
  gap: 20px;
}

#loading-screen .brand {
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
}

#loading-screen .brand span { color: var(--gold); }

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─────────────────────────── TOP BAR ────────────────────────────────────── */
header {
  background: var(--green);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-header {
  font-size: 1.35rem;
  font-weight: 900;
  color: #fff;
}

.brand-header span { color: var(--gold); }

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: 6px 14px 6px 6px;
  color: #fff;
  font-size: 0.9rem;
}

.user-chip i { font-size: 1.1rem; }

#btn-logout {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 7px 16px;
  border-radius: 24px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  transition: background 0.2s;
}

#btn-logout:hover { background: rgba(255,255,255,0.28); }

/* ─────────────────────────── MAIN CONTENT ───────────────────────────────── */
main {
  max-width: 640px;
  margin: 40px auto;
  padding: 0 16px 60px;
}

/* ─────────────────────────── AUTH CARD (LOGIN) ──────────────────────────── */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #004d26 0%, #00884a 60%, #D9A441 100%);
}

.auth-card {
  background: var(--card);
  border-radius: 24px;
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--green), var(--gold));
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(0,102,51,0.28);
}

.auth-logo h1 {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--green);
}

.auth-logo h1 span { color: var(--gold); }

.auth-logo p {
  color: var(--subtle);
  font-size: 0.95rem;
  margin-top: 4px;
}

.auth-card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  text-align: center;
}

/* ─────────────────────────── FORM ELEMENTS ──────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: #fafafa;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  direction: rtl;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0,102,51,0.1);
  background: #fff;
}

/* ─────────────────────────── BUTTONS ────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 6px;
}

.btn-primary:hover { background: var(--green-light); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-gold {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #fff;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 4px 16px rgba(217,164,65,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-gold:hover { opacity: 0.9; }
.btn-gold:active { transform: scale(0.98); }
.btn-gold:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--subtle);
  padding: 10px 22px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

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

/* ─────────────────────────── ALERT MESSAGES ─────────────────────────────── */
.alert {
  padding: 11px 15px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-top: 14px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.alert-error {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c6c6;
}

.alert-success {
  background: #e8f5e9;
  color: var(--success);
  border: 1px solid #c8e6c9;
}

/* ─────────────────────────── DASHBOARD ──────────────────────────────────── */
#dashboard-page { display: none; }

/* OTP Input ── 6 separate digit boxes */
.otp-input-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0 8px;
  direction: ltr;
}

.otp-box {
  width: 50px;
  height: 60px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  color: var(--green);
  background: #fafafa;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.otp-box:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(217,164,65,0.18);
  background: #fff;
}

.otp-box.filled {
  border-color: var(--green);
  background: rgba(0,102,51,0.04);
}

/* ─────────────────────────── CARD COMPONENTS ────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title i { color: var(--green); font-size: 1.2rem; }

.card-subtitle {
  font-size: 0.88rem;
  color: var(--subtle);
  margin-bottom: 22px;
}

/* ─────────────────────────── PROMO SELECT ───────────────────────────────── */
.promo-select-wrapper {
  position: relative;
}

.promo-select-wrapper select {
  appearance: none;
  padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23006633' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
}

/* ─────────────────────────── RESULT CARD ────────────────────────────────── */
#result-section { margin-top: 28px; }

.result-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 6px 32px rgba(0,102,51,0.1);
  border: 2px solid var(--green);
  overflow: hidden;
}

.result-header {
  background: linear-gradient(135deg, var(--green), var(--green-light));
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
}

.result-header .check-icon {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.result-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.result-header p {
  font-size: 0.88rem;
  opacity: 0.85;
  margin-top: 2px;
}

.result-body {
  padding: 24px;
}

/* User info row */
.user-info-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: 12px;
  margin-bottom: 20px;
}

.user-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--green);
  flex-shrink: 0;
}

.user-avatar-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.8rem;
  flex-shrink: 0;
}

.user-details h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.user-details p {
  font-size: 0.85rem;
  color: var(--subtle);
  margin-top: 3px;
}

/* Promo detail rows */
.detail-rows { display: flex; flex-direction: column; gap: 12px; }

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.93rem;
}

.detail-row .icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.icon-green  { background: rgba(0,102,51,0.1);   color: var(--green); }
.icon-gold   { background: rgba(217,164,65,0.15); color: var(--gold); }
.icon-blue   { background: rgba(33,150,243,0.1);  color: #1976d2; }
.icon-purple { background: rgba(103,58,183,0.1);  color: #6a1b9a; }

.detail-label {
  font-size: 0.78rem;
  color: var(--subtle);
  display: block;
}

.detail-value {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

/* Promo code chip */
.promo-code-chip {
  display: inline-block;
  background: rgba(217,164,65,0.12);
  border: 1.5px dashed var(--gold);
  color: var(--gold);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 2px;
  padding: 5px 18px;
  border-radius: 8px;
  margin-top: 6px;
  font-family: monospace;
}

/* Error result card */
.error-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 2px solid var(--danger);
  padding: 24px;
  text-align: center;
}

.error-card i {
  font-size: 3rem;
  color: var(--danger);
  margin-bottom: 12px;
}

.error-card h3 { color: var(--danger); font-size: 1.15rem; margin-bottom: 6px; }
.error-card p  { color: var(--subtle); font-size: 0.9rem; }

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Stats strip */
.stats-strip {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

.stat-box {
  flex: 1;
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-box .stat-num {
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--green);
  line-height: 1;
}

.stat-box .stat-label {
  font-size: 0.78rem;
  color: var(--subtle);
  margin-top: 4px;
}

/* Page title */
.page-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--subtle);
  margin-bottom: 28px;
}

/* Reset button row */
.action-row {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.action-row .btn-secondary { flex: 1; }
.action-row .btn-gold { flex: 2; }

/* ─────────────────────────── HISTORY LIST ───────────────────────────────── */
.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child { border-bottom: none; }

.history-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--green);
  flex-shrink: 0;
}

.history-avatar-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.history-info { flex: 1; min-width: 0; }

.history-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-promo {
  font-size: 0.8rem;
  color: var(--subtle);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-time {
  font-size: 0.78rem;
  color: var(--subtle);
  flex-shrink: 0;
  text-align: left;
}

/* ─────────────────────────── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 32px 22px 28px; }
  .otp-box   { width: 42px; height: 54px; font-size: 1.4rem; }
  .stats-strip { flex-direction: column; }
  header { padding: 0 14px; }
  .user-chip span { display: none; }
}
