/* ═══════════════════════════════════════════════════════════════
   لمّة — App Shared Stylesheet
   RTL · IBM Plex Sans Arabic · Space Grotesk (numbers)
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');

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

/* ─────────────────────────────── ROOT VARIABLES */
:root {
  --bg:        #F8F6F3;
  --surface:   #FFFFFF;
  --text:      #0D0D0D;
  --text-2:    #4A4A4A;
  --text-3:    #9A9A9A;
  --wa:        #25D366;
  --wa-dark:   #128C7E;
  --wa-bg:     #F0FBF5;
  --border:    #ECEAE6;
  --border-2:  #D4D0CA;
  --danger:    #DC2626;
  --danger-bg: #FFF1F1;
  --shadow:    0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.10);
  --radius:    12px;
}

/* ─────────────────────────────── BASE */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}

/* ─────────────────────────────── APP LAYOUT */
.app-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Sticky top nav */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  background: rgba(248, 246, 243, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.app-header-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.app-header-logo span {
  color: var(--wa);
}

/* Back button sits on the left (LTR physical left = logical end in RTL) */
.app-header-back {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  padding: 6px 10px;
  border-radius: 8px;
  transition: background .15s, color .15s;
  background: none;
  border: none;
  cursor: pointer;
}

.app-header-back:hover {
  background: var(--border);
  color: var(--text);
}

/* Page content sits below fixed header */
.app-content {
  padding-top: 56px;
  min-height: 100vh;
}

/* Inner page padding */
.page-body {
  padding: 24px 0 48px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 24px;
}

/* ─────────────────────────────── BUTTONS */

/* Shared button base */
.btn-primary,
.btn-wa,
.btn-ghost,
.btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity .15s, transform .1s, background .15s, border-color .15s;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  white-space: nowrap;
}

.btn-primary:active,
.btn-wa:active,
.btn-ghost:active,
.btn-danger:active {
  transform: scale(0.98);
}

/* Filled dark */
.btn-primary {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* WhatsApp green */
.btn-wa {
  background: var(--wa);
  color: #fff;
  border-color: var(--wa);
}

.btn-wa:hover {
  background: var(--wa-dark);
  border-color: var(--wa-dark);
}

.btn-wa:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Ghost / outline */
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}

.btn-ghost:hover {
  border-color: var(--text-2);
  color: var(--text);
  background: var(--surface);
}

/* Danger / red outline */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

/* Small variant — auto width, shorter height */
.btn-sm {
  width: auto;
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  border-radius: 8px;
}

/* Inline link style button */
.btn-link {
  background: none;
  border: none;
  color: var(--wa-dark);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─────────────────────────────── FORMS */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.form-input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  font-size: 15px;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  direction: rtl;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}

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

.form-input:focus {
  border-color: var(--wa);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.12);
}

.form-input:disabled {
  background: var(--bg);
  color: var(--text-3);
  cursor: not-allowed;
}

.form-textarea {
  display: block;
  width: 100%;
  min-height: 80px;
  padding: 12px 16px;
  font-size: 15px;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  direction: rtl;
  outline: none;
  resize: vertical;
  line-height: 1.6;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-textarea::placeholder {
  color: var(--text-3);
}

.form-textarea:focus {
  border-color: var(--wa);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.12);
}

/* Field error message */
.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 6px;
  display: none;
}

.form-group.has-error .form-input,
.form-group.has-error .form-textarea {
  border-color: var(--danger);
}

.form-group.has-error .form-error {
  display: block;
}

/* Field hint */
.form-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
}

/* Phone input with country code */
.phone-input-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}

.phone-input-wrap:focus-within {
  border-color: var(--wa);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.12);
}

.phone-prefix {
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 15px;
  color: var(--text-2);
  background: var(--bg);
  border-left: 1px solid var(--border-2);
  flex-shrink: 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 0.02em;
}

.phone-input-wrap .form-input {
  border: none;
  border-radius: 0;
  box-shadow: none;
  flex: 1;
  min-width: 0;
}

.phone-input-wrap .form-input:focus {
  box-shadow: none;
}

/* ─────────────────────────────── CARDS */
.card {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-meta {
  font-size: 13px;
  color: var(--text-3);
}

/* Tappable card variant */
.card-tap {
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}

.card-tap:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-lg);
}

.card-tap:active {
  transform: scale(0.99);
}

/* ─────────────────────────────── STATUS CHIPS */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* حضور — green */
.chip-yes {
  background: var(--wa-bg);
  color: var(--wa-dark);
}

/* ربما — amber */
.chip-maybe {
  background: #FFFBEB;
  color: #92400E;
}

/* اعتذر — red muted */
.chip-no {
  background: #FFF1F1;
  color: #991B1B;
}

/* لم يرد / pending — grey */
.chip-pending {
  background: #F3F3F3;
  color: var(--text-3);
}

/* ─────────────────────────────── GUEST LIST ITEM */
.guest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.guest-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--wa-bg);
  color: var(--wa-dark);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}

.guest-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.guest-info-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guest-info-phone {
  font-size: 12px;
  color: var(--text-3);
  font-family: 'Space Grotesk', sans-serif;
  direction: ltr;
  text-align: right;
}

/* Status chip pushed to the logical start (right in RTL = margin-left: auto) */
.guest-status {
  margin-left: auto;
  flex-shrink: 0;
}

/* ─────────────────────────────── DEV OTP BANNER */
.dev-banner {
  background: #FEF9C3;
  border: 1px solid #FDE047;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: #713F12;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dev-banner-label {
  font-weight: 600;
  flex-shrink: 0;
}

.dev-banner-code {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: #78350F;
}

/* ─────────────────────────────── EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 4px;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.empty-state-desc {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.6;
  max-width: 260px;
}

/* ─────────────────────────────── RSVP SUMMARY BARS */
.rsvp-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.rsvp-count-box {
  text-align: center;
  padding: 16px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.rsvp-count-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}

/* Color-coded numbers */
.rsvp-count-box.yes   .rsvp-count-num { color: var(--wa-dark); }
.rsvp-count-box.maybe .rsvp-count-num { color: #D97706; }
.rsvp-count-box.no    .rsvp-count-num { color: var(--danger); }

.rsvp-count-label {
  font-size: 12px;
  color: var(--text-3);
}

/* ─────────────────────────────── DIVIDERS */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ─────────────────────────────── SECTION HEADING */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ─────────────────────────────── SERVER ERROR BANNER */
.error-banner {
  background: var(--danger-bg);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 16px;
  display: none;
}

.error-banner.visible {
  display: block;
}

/* ─────────────────────────────── LOADING SKELETON */
@keyframes shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    var(--bg) 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-text.full   { width: 100%; }

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─────────────────────────────── SPINNER */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.spinner.dark {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--text);
}

/* ─────────────────────────────── TOAST NOTIFICATION */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  width: calc(100% - 40px);
  max-width: 600px;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .22s, transform .22s;
  text-align: center;
  width: 100%;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: var(--wa-dark); }
.toast.error   { background: var(--danger); }

/* ─────────────────────────────── MOBILE-FIRST RESPONSIVE */

/* Base styles target mobile (320px+) */

@media (min-width: 480px) {
  .app-container {
    padding: 0 24px;
  }
}

/* Desktop centering — content stays narrow, max 640px */
@media (min-width: 640px) {
  .app-header {
    /* Extend header full-width but center inner content */
    padding: 0 calc(50% - 300px);
  }
}

@media (min-width: 768px) {
  .app-container {
    padding: 0 32px;
  }
}
