/* ============================================================
 * RadioBrain — Design System Futuriste
 * Dark mode / Glassmorphism / Neon accents / Space Grotesk
 * ============================================================ */

:root {
  /* Couleurs */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-elevated: rgba(255, 255, 255, 0.03);
  --bg-glass: rgba(255, 255, 255, 0.05);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-neon: rgba(0, 240, 255, 0.4);

  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b0;
  --text-tertiary: #606070;
  --text-dim: #404050;

  --accent-cyan: #00f0ff;
  --accent-violet: #b537f2;
  --accent-pink: #ff2d92;
  --accent-success: #00ff9c;
  --accent-warning: #ffb800;
  --accent-danger: #ff4757;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-violet) 100%);
  --gradient-glow: radial-gradient(circle at 30% 20%, rgba(0, 240, 255, 0.15), transparent 50%),
                   radial-gradient(circle at 80% 80%, rgba(181, 55, 242, 0.12), transparent 50%);

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Typography */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Shadows + Glows */
  --glow-cyan: 0 0 24px rgba(0, 240, 255, 0.35), 0 0 48px rgba(0, 240, 255, 0.15);
  --glow-violet: 0 0 24px rgba(181, 55, 242, 0.35);
  --glow-soft: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glow-elevated: 0 16px 48px rgba(0, 0, 0, 0.7);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--gradient-glow);
  pointer-events: none;
  z-index: 0;
  animation: ambientShift 20s ease-in-out infinite alternate;
}

@keyframes ambientShift {
  0% { transform: translate(0, 0) scale(1); opacity: 0.7; }
  100% { transform: translate(-3%, 4%) scale(1.05); opacity: 1; }
}

main, .app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-8);
  display: flex;
  flex-direction: column;
}

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: 32px; line-height: 1.15; }
h2 { font-size: 24px; line-height: 1.2; }
h3 { font-size: 18px; line-height: 1.3; }

.text-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.app-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--gradient-primary);
  display: grid;
  place-items: center;
  box-shadow: var(--glow-cyan);
  font-size: 16px;
  color: var(--bg-primary);
  font-weight: 800;
}

/* ── Mode Toggle (Consultation / Session) ───────────────── */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-5);
}

.mode-toggle button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.mode-toggle button.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--border-strong), 0 2px 12px rgba(0, 240, 255, 0.1);
}

/* ── Action Button (gros bouton CAS) ────────────────────── */
.action-btn-primary {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 11;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  color: var(--text-primary);
  cursor: pointer;
  overflow: hidden;
  transition: all 0.4s var(--ease-out);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  margin-bottom: var(--space-4);
}

.action-btn-primary::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: var(--gradient-primary);
  border-radius: var(--radius-xl);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.4s var(--ease-out);
  filter: blur(20px);
}

.action-btn-primary:active {
  transform: scale(0.97);
}

.action-btn-primary:hover::before,
.action-btn-primary:focus-visible::before {
  opacity: 0.5;
}

.action-btn-primary .icon {
  font-size: 56px;
  filter: drop-shadow(0 0 24px rgba(0, 240, 255, 0.4));
  transition: transform 0.4s var(--ease-spring);
}

.action-btn-primary:active .icon {
  transform: scale(0.9) rotate(-3deg);
}

.action-btn-primary .label {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.action-btn-primary .sublabel {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

/* ── Secondary buttons row ──────────────────────────────── */
.action-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.action-btn-secondary {
  position: relative;
  background: var(--bg-elevated);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  padding: var(--space-5) var(--space-4);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  transition: all 0.3s var(--ease-out);
  font-family: var(--font-display);
}

.action-btn-secondary:active {
  transform: scale(0.95);
}

.action-btn-secondary:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.action-btn-secondary .icon {
  font-size: 28px;
}

.action-btn-secondary .label {
  font-size: 14px;
  font-weight: 600;
}

/* ── Stats row ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.stat-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.stat-card:hover {
  border-color: var(--border-strong);
}

.stat-card .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

.stat-card .stat-value .accent {
  color: var(--accent-cyan);
}

.stat-card.streak .stat-value {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Forms (cas / idée / erreur) ────────────────────────── */
.form-page {
  padding-top: var(--space-3);
}

.form-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.btn-back {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s var(--ease-out);
}

.btn-back:active { transform: scale(0.9); }

.form-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.form-field {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
  font-weight: 500;
}

.form-input, .form-textarea {
  width: 100%;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition: all 0.2s var(--ease-out);
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 88px;
  font-family: var(--font-body);
}

/* ── Chips ──────────────────────────────────────────────── */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  user-select: none;
  white-space: nowrap;
}

.chip:active { transform: scale(0.95); }

.chip.selected {
  background: var(--gradient-primary);
  color: var(--bg-primary);
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.25);
}

.chip.recent {
  border-color: var(--border-strong);
}

.chip.add-new {
  border-style: dashed;
  color: var(--text-tertiary);
}

/* ── Image upload zone ──────────────────────────────────── */
.image-upload {
  display: block;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  background: var(--bg-glass);
}

.image-upload:hover, .image-upload.active {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
  background: rgba(0, 240, 255, 0.04);
}

.image-upload .icon { font-size: 32px; margin-bottom: var(--space-2); }
.image-upload .label { font-size: 14px; font-weight: 500; }
.image-upload input[type=file] { display: none; }

.image-preview-row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  overflow-x: auto;
}

.image-preview {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-strong);
}

/* ── Submit button (sticky bottom) ──────────────────────── */
.form-submit-zone {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-4) 0 var(--space-3);
  background: linear-gradient(to top, var(--bg-primary) 60%, transparent);
  margin-top: var(--space-5);
  z-index: 10;
}

.btn-submit {
  width: 100%;
  background: var(--gradient-primary);
  color: var(--bg-primary);
  border: none;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: var(--glow-cyan);
  transition: all 0.2s var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.btn-submit:active { transform: scale(0.98); box-shadow: 0 0 12px rgba(0, 240, 255, 0.4); }

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ── Checkbox custom ────────────────────────────────────── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
}

.checkbox-row input[type=checkbox] { display: none; }

.checkbox-box {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  display: grid;
  place-items: center;
  transition: all 0.2s var(--ease-out);
  flex-shrink: 0;
}

.checkbox-row input:checked ~ .checkbox-box {
  background: var(--gradient-primary);
  border-color: transparent;
}

.checkbox-box::after {
  content: '✓';
  color: var(--bg-primary);
  font-weight: 800;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s;
}

.checkbox-row input:checked ~ .checkbox-box::after { opacity: 1; }

.checkbox-row .label {
  font-size: 14px;
  color: var(--text-primary);
}

.checkbox-row .sublabel {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ── Toast feedback ─────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--glow-elevated);
  transition: transform 0.5s var(--ease-spring);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--accent-success); }
.toast.error { border-color: var(--accent-danger); }

/* ── Daily Plan card ────────────────────────────────────── */
.daily-card {
  position: relative;
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.daily-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
}

.daily-card .badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: rgba(0, 240, 255, 0.1);
  color: var(--accent-cyan);
  padding: 4px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-3);
}

.daily-card .title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.daily-card .desc {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: var(--space-4);
}

.daily-card .actions {
  display: flex;
  gap: var(--space-2);
}

.btn-pill {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.btn-pill:active { transform: scale(0.97); }
.btn-pill.success { color: var(--accent-success); }
.btn-pill.warning { color: var(--accent-warning); }

/* ── Loading state ──────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--bg-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Safe area iOS ──────────────────────────────────────── */
@supports (padding: max(0px)) {
  main, .app-shell {
    padding-top: max(var(--space-5), env(safe-area-inset-top));
    padding-bottom: max(var(--space-8), env(safe-area-inset-bottom));
  }
}

/* ── Animations entrance ────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.5s var(--ease-out);
}

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

.fade-in-delay-1 { animation: fadeIn 0.5s var(--ease-out) 0.05s both; }
.fade-in-delay-2 { animation: fadeIn 0.5s var(--ease-out) 0.1s both; }
.fade-in-delay-3 { animation: fadeIn 0.5s var(--ease-out) 0.15s both; }

/* ── Utility ────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.hidden { display: none !important; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
