/* ============================================================
   Sports Meetup Platform — App Shell CSS
   Theme tokens follow the design doc theme preference values:
     dark_pitch (default) | light | amber
   ============================================================ */

/* ─────────────────────────────────────────────
   CSS Custom Properties (Design Tokens)
   ───────────────────────────────────────────── */
:root {
  --color-bg: #0f1f14;
  --color-surface: #1a2f1f;
  --color-surface-alt: #213826;
  --color-primary: #3dba5e;
  --color-primary-hover: #30a04e;
  --color-primary-text: #0f1f14;
  --color-text: #e8f5e9;
  --color-text-muted: #80b890;
  --color-border: #2d4a33;
  --color-error: #f44336;
  --color-warning: #ff9800;
  --color-success: #4caf50;
  --color-info: #2196f3;
  --color-danger: #e53935;
  --color-badge-public: #4caf50;
  --color-badge-invite-only: #ff9800;
  --color-badge-group: #2196f3;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --font-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --nav-height: 60px;
  --install-banner-height: 60px;
}

[data-theme="light"] {
  --color-bg: #f4f8f5;
  --color-surface: #ffffff;
  --color-surface-alt: #edf3ef;
  --color-primary: #1b7a3e;
  --color-primary-hover: #155e30;
  --color-primary-text: #ffffff;
  --color-text: #1a2f1f;
  --color-text-muted: #4a7a57;
  --color-border: #c8dccf;
  --color-error: #c62828;
  --color-success: #2e7d32;
}

[data-theme="amber"] {
  --color-bg: #1c1400;
  --color-surface: #2d2200;
  --color-surface-alt: #3a2c00;
  --color-primary: #ffb300;
  --color-primary-hover: #e6a100;
  --color-primary-text: #1c1400;
  --color-text: #fff8e1;
  --color-text-muted: #c8a850;
  --color-border: #4a3900;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

button { cursor: pointer; font-family: inherit; }

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

/* ─────────────────────────────────────────────
   Install Banner (R-026 — persistent, every page)
   ───────────────────────────────────────────── */
#install-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  color: var(--color-primary-text);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.install-banner-icon { font-size: 1.5rem; flex-shrink: 0; }

.install-banner-text { flex: 1; }
.install-banner-title { font-weight: 700; font-size: 0.9rem; }
.install-banner-subtitle { font-size: 0.78rem; opacity: 0.9; margin-top: 2px; }

.install-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }

#btn-install {
  background: var(--color-primary-text);
  color: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity 0.2s;
}
#btn-install:hover { opacity: 0.85; }

#btn-install-dismiss {
  background: transparent;
  border: 1.5px solid var(--color-primary-text);
  color: var(--color-primary-text);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.82rem;
  transition: opacity 0.2s;
}
#btn-install-dismiss:hover { opacity: 0.75; }

/* ─────────────────────────────────────────────
   iOS Install Modal
   ───────────────────────────────────────────── */
#ios-install-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ios-modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.3s ease;
}

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

.ios-modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.ios-modal-steps { font-size: 0.9rem; color: var(--color-text-muted); line-height: 1.7; margin-bottom: 20px; }
.ios-modal-steps strong { color: var(--color-text); }

#btn-ios-modal-close {
  width: 100%;
  padding: 12px;
  background: var(--color-primary);
  color: var(--color-primary-text);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
}

/* ─────────────────────────────────────────────
   Navigation
   ───────────────────────────────────────────── */
#app-nav {
  height: var(--nav-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.nav-right { display: flex; align-items: center; gap: 12px; }

/* ─────────────────────────────────────────────
   Notification Centre (in-app fallback)
   ───────────────────────────────────────────── */
.notif-wrapper { position: relative; }

#btn-notif-bell {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--color-text-muted);
  padding: 4px;
  position: relative;
  transition: color 0.2s;
}
#btn-notif-bell:hover { color: var(--color-text); }

#notif-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  background: var(--color-error);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}

#notif-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 320px;
  max-height: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
  z-index: 300;
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 700;
}

#btn-mark-all-read {
  background: transparent;
  border: none;
  color: var(--color-primary);
  font-size: 0.78rem;
  font-weight: 600;
}

#notif-list { padding: 8px 0; }

.notif-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s;
}
.notif-item:hover { background: var(--color-surface-alt); }
.notif-item.unread { border-left: 3px solid var(--color-primary); }
.notif-item.read { opacity: 0.7; }
.notif-title { font-weight: 600; font-size: 0.88rem; margin-bottom: 2px; }
.notif-body { font-size: 0.82rem; color: var(--color-text-muted); }
.notif-time { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 4px; }
.notif-empty { padding: 24px 16px; text-align: center; color: var(--color-text-muted); font-size: 0.88rem; }

#notif-fallback-hint {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--color-warning);
  color: #1c1400;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  width: 240px;
  box-shadow: var(--shadow-sm);
  z-index: 300;
}

/* ─────────────────────────────────────────────
   Main Content Area
   ───────────────────────────────────────────── */
#app-main {
  flex: 1;
  padding: 20px 16px;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

/* ─────────────────────────────────────────────
   Pages
   ───────────────────────────────────────────── */
.page { animation: fadeIn 0.2s ease; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 { font-size: 1.4rem; font-weight: 800; }

h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 16px; }
h3 { font-size: 1rem; font-weight: 700; margin: 20px 0 10px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.subtitle { color: var(--color-text-muted); font-size: 0.9rem; margin-top: 4px; }

/* ─────────────────────────────────────────────
   Auth Page
   ───────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--nav-height) - 60px);
  padding: 24px 16px;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.auth-logo { font-size: 3rem; margin-bottom: 12px; }
.auth-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.auth-subtitle { color: var(--color-text-muted); font-size: 0.9rem; margin-bottom: 28px; }

.auth-buttons { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }

.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  transition: transform 0.15s, opacity 0.15s;
}
.btn-oauth:hover { transform: translateY(-1px); opacity: 0.9; }

.btn-google { background: #fff; color: #3c4043; border-color: #dadce0; }
.btn-facebook { background: #1877f2; color: #fff; }

.oauth-icon { font-weight: 800; font-size: 1.1rem; }
.auth-note { font-size: 0.78rem; color: var(--color-text-muted); }

/* ─────────────────────────────────────────────
   Card Grid (Home)
   ───────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.card-action {
  cursor: pointer;
  text-align: center;
}
.card-action:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.card-icon { font-size: 2rem; margin-bottom: 10px; }
.card-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.card-desc { font-size: 0.78rem; color: var(--color-text-muted); }

/* ─────────────────────────────────────────────
   Event Cards
   ───────────────────────────────────────────── */
.event-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  box-shadow: var(--shadow-sm);
}
.event-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.event-header { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.event-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; }
.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* Event Detail */
.event-detail-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.event-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.event-detail-meta strong { color: var(--color-text); }

.event-desc { font-size: 0.9rem; color: var(--color-text-muted); margin: 8px 0; line-height: 1.5; }

.event-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }

/* ─────────────────────────────────────────────
   Group Cards
   ───────────────────────────────────────────── */
.group-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.group-name { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.group-desc { font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 6px; }
.group-meta { font-size: 0.78rem; color: var(--color-text-muted); }

/* ─────────────────────────────────────────────
   Badges
   ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.badge-public { background: var(--color-badge-public); color: #fff; border-color: transparent; }
.badge-invite_only { background: var(--color-badge-invite-only); color: #fff; border-color: transparent; }
.badge-group { background: var(--color-badge-group); color: #fff; border-color: transparent; }
.badge-status { background: var(--color-surface-alt); }

/* ─────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid transparent;
  transition: transform 0.12s, opacity 0.2s, box-shadow 0.12s;
  text-align: center;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); opacity: 0.9; }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--color-primary); color: var(--color-primary-text); }
.btn-secondary { background: var(--color-surface-alt); color: var(--color-text); border-color: var(--color-border); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-full { width: 100%; }
.btn-back { margin-bottom: 16px; }

/* ─────────────────────────────────────────────
   Forms
   ───────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 18px; max-width: 480px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
}

.form-group textarea { resize: vertical; min-height: 80px; }

/* ─────────────────────────────────────────────
   Nav User Area
   ───────────────────────────────────────────── */
#nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}

.user-nickname { font-weight: 700; color: var(--color-primary); }

/* ─────────────────────────────────────────────
   Loading Spinner
   ───────────────────────────────────────────── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ─────────────────────────────────────────────
   Toast Notifications
   ───────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.25s ease;
  pointer-events: auto;
  max-width: 300px;
}

.toast-success { background: var(--color-success); color: #fff; }
.toast-error { background: var(--color-error); color: #fff; }
.toast-info { background: var(--color-info); color: #fff; }
.toast-warning { background: var(--color-warning); color: #1c1400; }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-fade-out {
  animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateX(120%); }
}

/* ─────────────────────────────────────────────
   Empty States & Errors
   ───────────────────────────────────────────── */
.empty-state {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  padding: 16px 0;
  text-align: center;
}

.error {
  color: var(--color-error);
  padding: 16px 0;
  font-size: 0.9rem;
}

/* ─────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
  #app-main { padding: 16px 12px; }
  .auth-card { padding: 28px 20px; }
  .event-detail-card { padding: 16px; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  #notif-panel { width: calc(100vw - 24px); right: -8px; }
  .install-banner-subtitle { display: none; }
}

/* ─────────────────────────────────────────────
   PWA Standalone mode adjustments
   ───────────────────────────────────────────── */
@media (display-mode: standalone) {
  /* Ensure content doesn't overlap status bar on iOS */
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* Install banner never shows in standalone mode — it's removed by JS,
     but we add a CSS safety net */
  #install-banner { display: none !important; }
}

/* ─────────────────────────────────────────────
   Settings Dashboard Layout
   ───────────────────────────────────────────── */
.theme-settings-card {
  margin-bottom: 24px;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 15px;
}
.dashboard-col {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.section-title-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
}
.section-title-wrapper h3 {
  font-size: 1.05rem;
  font-weight: 700;
}
.badge-count {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
}
.dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
