/* ═══════════════════════════════════════════════════════════════
   Marc Pouliot — App Immobilier PWA
   Design System Mobile-First — DARK MODE
   ═══════════════════════════════════════════════════════════════ */

/* ─── Google Fonts ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── CSS Variables — DARK THEME ─── */
:root {
  /* RE/MAX inspired palette — dark mode */
  --primary: #2a5a8c;
  --primary-dark: #0f2540;
  --primary-light: #4a8abf;
  --accent: #dc3545;
  --accent-light: #ff4757;
  --white: #ffffff;

  /* Dark backgrounds */
  --bg: #0c1220;
  --bg-surface: #131b2e;
  --bg-card: #1a2540;
  --bg-card-hover: #1f2d4a;
  --bg-elevated: #223050;

  /* Text on dark */
  --text: #e8ecf1;
  --text-secondary: #8b9ab5;
  --text-light: #5a6a82;

  /* Borders & shadows */
  --border: rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.03);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.45);
  --shadow-card: 0 2px 10px rgba(0,0,0,0.25);
  --shadow-glow: 0 0 20px rgba(42,90,140,0.15);

  /* Radii */
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;

  /* Motion */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 480px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--safe-area-top);
  padding-bottom: var(--safe-area-bottom);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
img { max-width: 100%; display: block; }

/* ─── App Shell ─── */
.app-shell {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
}

/* ─── Header Profile — Dark Gradient ─── */
.profile-header {
  background: linear-gradient(170deg, #0a1628 0%, #0f2242 40%, #152d52 70%, #0a1628 100%);
  padding: 44px 24px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.profile-header::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -40%;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(42,90,140,0.12) 0%, transparent 70%);
  border-radius: 50%;
}

.profile-header::after {
  content: '';
  position: absolute;
  bottom: -50%;
  left: -25%;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(220,53,69,0.06) 0%, transparent 70%);
  border-radius: 50%;
}

.lang-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.lang-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  transition: var(--transition);
  letter-spacing: 0.5px;
}

.lang-btn.active {
  background: rgba(255,255,255,0.12);
  color: var(--white);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Photo — PNG transparent (Marc Remax outline 15 Matrix.png) */
.profile-photo {
  width: 160px;
  height: 160px;
  border-radius: 0;
  border: none;
  object-fit: contain;
  margin: 0 auto 14px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
  overflow: visible;
}

.profile-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.3px;
  position: relative;
  z-index: 1;
}

.profile-title {
  font-size: 14px;
  color: rgba(255,255,255,0.65);
  margin-top: 4px;
  font-weight: 400;
  position: relative;
  z-index: 1;
}

.profile-location {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
  position: relative;
  z-index: 1;
}

.profile-brokerage {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 7px 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 22px;
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

.profile-brokerage img {
  width: 18px;
  height: 18px;
}

/* ─── Contact Buttons — BIGGER for big fingers ─── */
.contact-buttons {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 28px 20px 10px;
  margin-top: -16px;
  position: relative;
  z-index: 2;
}

.contact-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 76px;
}

.contact-btn-icon {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  font-size: 26px;
}

.contact-btn:active .contact-btn-icon {
  transform: scale(0.92);
  background: var(--bg-elevated);
}

.contact-btn-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ─── Social Links ─── */
.social-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 10px 24px 22px;
}

.social-link {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: var(--transition);
  font-size: 20px;
}

.social-link:active {
  transform: scale(0.9);
  background: var(--bg-card);
}

/* ─── Section Cards ─── */
.section-group {
  padding: 0 16px;
  margin-bottom: 14px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-light);
  padding: 6px 8px 10px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-link {
  display: flex;
  align-items: center;
  padding: 16px 18px;
  transition: var(--transition);
  gap: 14px;
  min-height: 64px;
}

.card-link:active {
  background: var(--bg-card-hover);
}

.card-link + .card-link {
  border-top: 1px solid var(--border);
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

/* Dark mode icon backgrounds */
.card-icon.blue { background: rgba(42,90,140,0.2); }
.card-icon.green { background: rgba(52,168,83,0.15); }
.card-icon.purple { background: rgba(128,90,213,0.15); }
.card-icon.orange { background: rgba(255,152,0,0.15); }
.card-icon.red { background: rgba(220,53,69,0.15); }
.card-icon.teal { background: rgba(0,188,212,0.15); }
.card-icon.pink { background: rgba(233,30,99,0.12); }
.card-icon.indigo { background: rgba(63,81,181,0.15); }

.card-content {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card-arrow {
  color: var(--text-light);
  font-size: 16px;
  flex-shrink: 0;
}

/* ─── Tool Grid — BIGGER cards for big fingers ─── */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px;
  margin-bottom: 14px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 22px 16px;
  text-align: center;
  transition: var(--transition);
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tool-card:active {
  transform: scale(0.96);
  background: var(--bg-card-hover);
}

.tool-card-icon {
  font-size: 32px;
  margin-bottom: 10px;
}

.tool-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.tool-card-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ─── Footer ─── */
.app-footer {
  text-align: center;
  padding: 24px 16px 44px;
  color: var(--text-light);
  font-size: 12px;
}

.app-footer a {
  color: var(--primary-light);
  font-weight: 500;
}

/* ─── Calculator Page — Dark ─── */
.calc-page {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.calc-header {
  background: var(--bg-surface);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.calc-back {
  padding: 6px;
  color: var(--primary-light);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 500;
}

.calc-page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  text-align: center;
  margin-right: 60px;
}

.calc-body {
  padding: 22px 16px;
}

.calc-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.6;
}

/* ─── Form Elements — BIGGER inputs ─── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  transition: var(--transition);
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(74,138,191,0.15);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-segmented {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 3px;
}

.form-segmented button {
  flex: 1;
  padding: 12px 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}

.form-segmented button.active {
  background: var(--bg-card);
  color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.form-select {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%235a6a82'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ─── Buttons — BIGGER ─── */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: var(--white);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(42,90,140,0.3);
  min-height: 54px;
}

.btn-primary:active {
  transform: scale(0.98);
  filter: brightness(0.9);
}

.btn-secondary {
  width: 100%;
  padding: 16px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  transition: var(--transition);
  min-height: 54px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

/* ─── Results — Dark ─── */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 20px;
  box-shadow: var(--shadow-card);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}

.result-row + .result-row {
  border-top: 1px solid var(--border);
}

.result-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.result-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.result-highlight {
  background: linear-gradient(135deg, #0f2242 0%, var(--primary) 100%);
  color: var(--white);
  margin: -20px -20px 16px;
  padding: 22px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  text-align: center;
  border-bottom: 1px solid rgba(42,90,140,0.3);
}

.result-highlight-label {
  font-size: 14px;
  opacity: 0.75;
  margin-bottom: 6px;
}

.result-highlight-value {
  font-size: 30px;
  font-weight: 700;
}

/* ─── Amortization Table — Dark ─── */
.amort-toggle {
  width: 100%;
  padding: 14px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  color: var(--primary-light);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  transition: var(--transition);
}

.amort-table-wrap {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.amort-table-wrap.open {
  max-height: 2000px;
}

.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 12px;
}

.amort-table th {
  background: var(--bg-surface);
  padding: 10px 6px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  position: sticky;
  top: 0;
}

.amort-table th:first-child { text-align: center; }

.amort-table td {
  padding: 8px 6px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.amort-table td:first-child {
  text-align: center;
  color: var(--text-secondary);
}

/* ─── QR Code Section — Dark ─── */
.qr-section {
  text-align: center;
  padding: 36px 24px;
}

.qr-code {
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.qr-label {
  font-size: 15px;
  color: var(--text-secondary);
}

/* ─── Taux Section — Dark ─── */
.taux-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}

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

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

.taux-date {
  font-size: 12px;
  color: var(--text-light);
}

.taux-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
}

.taux-row + .taux-row {
  border-top: 1px solid var(--border);
}

.taux-term {
  font-size: 15px;
  color: var(--text-secondary);
}

.taux-rate {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-light);
}

/* ─── Loading & Animations ─── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.animate-in {
  animation: fadeIn 0.4s ease forwards;
}

.animate-in-delay-1 { animation-delay: 0.05s; opacity: 0; }
.animate-in-delay-2 { animation-delay: 0.1s; opacity: 0; }
.animate-in-delay-3 { animation-delay: 0.15s; opacity: 0; }
.animate-in-delay-4 { animation-delay: 0.2s; opacity: 0; }
.animate-in-delay-5 { animation-delay: 0.25s; opacity: 0; }

/* ─── Standalone PWA overrides ─── */
@media (display-mode: standalone) {
  .profile-header {
    padding-top: calc(24px + var(--safe-area-top));
  }
}

/* ─── Desktop — dark wrapper ─── */
@media (min-width: 481px) {
  body {
    background: #080e1a;
  }
  .app-shell {
    box-shadow: 0 0 60px rgba(0,0,0,0.5);
  }
}
