/* OneTime App Styles
   Matches the design language from the landing page. */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:ital,wght@0,400;0,500;1,400&display=swap');

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

:root {
  --ink: #0a0f1a;
  --surface: #fafbfc;
  --accent: #1a56db;
  --accent-light: #e8f0fe;
  --muted: #5f6c7b;
  --border: #e2e6ea;
  --success: #059669;
  --success-light: #d1fae5;
  --warn: #d97706;
  --warn-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warm: #f8f6f3;
  --card-bg: #ffffff;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(10,15,26,0.08);
  --shadow-md: 0 4px 16px rgba(10,15,26,0.10);
  --shadow-lg: 0 12px 40px rgba(10,15,26,0.12);
}

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

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  color: var(--ink);
  background: var(--surface);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Auth Shell ───────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 768px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

.auth-brand {
  background: linear-gradient(145deg, #0a1628 0%, #1a3a6e 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 56px;
  color: white;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  top: -120px; right: -120px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(26,86,219,0.3) 0%, transparent 70%);
  pointer-events: none;
}

.auth-brand .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 48px;
}

.auth-brand .logo span { color: #60a5fa; }

.auth-brand h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.75px;
  margin-bottom: 20px;
  color: #ffffff;
}

.auth-brand p {
  font-size: 1rem;
  color: rgba(255,255,255,0.65);
  line-height: 1.7;
  max-width: 360px;
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: var(--surface);
}

.auth-form-wrap {
  width: 100%;
  max-width: 400px;
}

.auth-form-wrap .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 40px;
  display: none;
}

@media (max-width: 768px) {
  .auth-form-wrap .logo { display: block; }
}

.auth-form-wrap .logo span { color: var(--accent); }

.auth-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 36px;
}

/* ─── Forms ────────────────────────────────────────── */
.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.field input,
.field select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--card-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}

.field input::placeholder { color: var(--muted); opacity: 0.6; }

/* ─── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(26,86,219,0.3);
}

.btn-primary:hover {
  background: #1648c4;
  box-shadow: 0 4px 16px rgba(26,86,219,0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  background: var(--warm);
  border-color: var(--muted);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}

.btn-danger:hover { background: var(--danger-light); }

.btn-full { width: 100%; }

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

/* ─── App Shell ────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.app-nav .inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-nav .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.app-nav .logo span { color: var(--accent); }

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

.nav-user {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
}

.app-main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ─── Page Header ──────────────────────────────────── */
.page-header {
  margin-bottom: 36px;
}

.page-header h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.page-header p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ─── Stats Bar ────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

@media (max-width: 600px) { .stats-row { grid-template-columns: 1fr 1fr; } }

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

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

/* ─── Dashboard Layout ─────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .add-charge-panel { order: -1; }
}

/* ─── Cards ────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.card-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* ─── Charge List ──────────────────────────────────── */
.charge-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.charge-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.charge-item:hover {
  background: var(--card-bg);
  border-color: #c5cfda;
  box-shadow: var(--shadow-sm);
}

.charge-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: var(--accent);
}

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

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

.charge-date {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.charge-amount {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  white-space: nowrap;
}

.charge-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Pay Now button — shown on processing charges */
.btn-pay {
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn-pay:hover {
  background: #1648c4;
  box-shadow: 0 2px 8px rgba(26,86,219,0.35);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

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

/* ─── Status Badges ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.badge-pending {
  background: var(--warn-light);
  color: var(--warn);
}

.badge-paid {
  background: var(--success-light);
  color: var(--success);
}

.badge-processing {
  background: #eff6ff;
  color: #2563eb;
  animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.badge-failed {
  background: var(--danger-light);
  color: var(--danger);
}

/* ─── Add Charge Form ──────────────────────────────── */
.add-charge-panel .card { position: sticky; top: 80px; }

.form-section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: -0.2px;
}

/* ─── Empty State ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.empty-state p { font-size: 0.9rem; max-width: 320px; margin: 0 auto; }

/* ─── Toast notifications ──────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  max-width: 340px;
}

.toast-success { background: #0a2a1e; color: #6ee7b7; border-left: 3px solid var(--success); }
.toast-error { background: #2a0a0a; color: #fca5a5; border-left: 3px solid var(--danger); }
.toast-info { background: #0a1628; color: #93c5fd; border-left: 3px solid var(--accent); }

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

/* ─── Auth toggle link ─────────────────────────────── */
.auth-toggle {
  margin-top: 24px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
}

.auth-toggle a {
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
}

.auth-toggle a:hover { text-decoration: underline; }

/* ─── Error messages ───────────────────────────────── */
.error-msg {
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: none;
}

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

/* ─── Loading spinner ──────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ─── Divider ──────────────────────────────────────── */
.divider {
  text-align: center;
  position: relative;
  margin: 24px 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: var(--border);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

/* ─── Overdue indicator ────────────────────────────── */
.overdue .charge-date { color: var(--danger); font-weight: 500; }

/* ─── Charge list section headers ──────────────────── */
.charge-section-header {
  padding: 8px 16px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  list-style: none;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.charge-section-header:first-child { border-top: none; margin-top: 0; }

/* ─── Scheduler run button area ────────────────────── */
.scheduler-area {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.scheduler-area p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.5;
}

/* ─── Charge type toggle ────────────────────────────── */
.charge-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  font-family: 'DM Sans', sans-serif;
}

.type-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.type-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}

.type-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.type-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

.type-sub {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ─── Field helper text ─────────────────────────────── */
.field-hint {
  font-size: 0.75rem;
  margin-top: 4px;
  min-height: 16px;
  transition: color 0.15s;
}

.field-hint.hint-ok { color: var(--success); }
.field-hint.hint-err { color: var(--danger); }

.optional {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

/* ─── Prélèvement notice ────────────────────────────── */
.prelevement-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--warn-light);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.825rem;
  color: #92400e;
  margin-bottom: 16px;
  line-height: 1.5;
}

.notice-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

/* ─── Type-specific payment badges ──────────────────── */
.badge-auto-pay {
  background: var(--success-light);
  color: var(--success);
}

.badge-tracking {
  background: var(--warn-light);
  color: var(--warn);
}

/* ─── Responsive fine-tuning ───────────────────────── */
@media (max-width: 480px) {
  .app-main { padding: 24px 16px 64px; }
  .card { padding: 20px; }
  .stats-row { grid-template-columns: 1fr; }
  .charge-item { padding: 12px 14px; }
}
