/* ============================================
   CalcRapide.fr — Main Stylesheet
   Design: Modern Indigo + Emerald | Inter font
   ============================================ */

:root {
  --primary: #4F46E5;
  --primary-dark: #3730A3;
  --primary-light: #818CF8;
  --accent: #10B981;
  --accent-dark: #059669;
  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --text: #111827;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --border: #E5E7EB;
  --border-focus: #818CF8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(79,70,229,.15);
  --radius: 12px;
  --radius-lg: 20px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

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

img { max-width: 100%; height: auto; }

/* ===== HEADER ===== */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  white-space: nowrap;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.logo span { color: var(--primary); }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.main-nav a {
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all .2s;
}

.main-nav a:hover,
.main-nav a.active {
  background: #EEF2FF;
  color: var(--primary);
}

.header-cta {
  background: var(--primary);
  color: #fff !important;
  padding: 8px 16px !important;
  border-radius: 8px;
}
.header-cta:hover { background: var(--primary-dark) !important; color: #fff !important; }

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: .3s;
}

/* ===== HERO / MAIN CALCULATOR ===== */
.hero {
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #2563EB 100%);
  padding: 60px 20px 80px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto 40px;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  color: #fff;
  margin-bottom: 12px;
  letter-spacing: -.5px;
}

.hero p {
  font-size: 1.1rem;
  color: rgba(255,255,255,.8);
  max-width: 500px;
  margin: 0 auto;
}

/* ===== CALCULATOR WIDGET ===== */
.calc-wrapper {
  position: relative;
  z-index: 1;
  max-width: 340px;
  margin: 0 auto;
}

.calculator {
  background: #1E1B4B;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

.calc-screen {
  background: #0F0E1A;
  border-radius: 10px;
  padding: 16px 16px 12px;
  margin-bottom: 16px;
  text-align: right;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.calc-expression {
  font-size: .75rem;
  color: rgba(255,255,255,.4);
  min-height: 18px;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-display {
  font-size: 2.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'Courier New', monospace;
}

.calc-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.calc-btn {
  border: none;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  height: 56px;
  transition: all .15s;
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
}

.calc-btn:active { transform: scale(.95); }

.btn-num {
  background: #2D2B5E;
  color: #E8E8F0;
}
.btn-num:hover { background: #3D3B7A; }

.btn-op {
  background: #3730A3;
  color: #C7D2FE;
}
.btn-op:hover { background: #4338CA; }

.btn-func {
  background: #1F1D44;
  color: #9CA3AF;
  font-size: .85rem;
}
.btn-func:hover { background: #2D2B5E; }

.btn-equals {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff;
  grid-column: span 2;
}
.btn-equals:hover { background: linear-gradient(135deg, #059669, #047857); }

.btn-clear {
  background: #7C3AED;
  color: #fff;
}
.btn-clear:hover { background: #6D28D9; }

.btn-del {
  background: #DC2626;
  color: #fff;
}
.btn-del:hover { background: #B91C1C; }

.btn-zero { grid-column: span 2; }

/* History toggle */
.history-toggle {
  margin-top: 14px;
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.7);
  border-radius: 8px;
  padding: 8px;
  font-size: .8rem;
  cursor: pointer;
  transition: .2s;
  font-family: var(--font);
}
.history-toggle:hover { background: rgba(255,255,255,.15); }

.history-panel {
  display: none;
  margin-top: 8px;
  background: rgba(0,0,0,.3);
  border-radius: 8px;
  padding: 10px;
  max-height: 140px;
  overflow-y: auto;
}

.history-panel.open { display: block; }

.history-item {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: rgba(255,255,255,.6);
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.history-item:last-child { border: none; }
.history-item .result { color: #10B981; font-weight: 600; }

/* ===== SECTION COMMON ===== */
.section { padding: 60px 20px; }
.section-sm { padding: 40px 20px; }
.container { max-width: 1200px; margin: 0 auto; }

.section-header {
  text-align: center;
  margin-bottom: 40px;
}

.section-header h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -.3px;
}

.section-header p {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 560px;
  margin: 0 auto;
}

/* ===== CATEGORIES ===== */
.categories { background: #fff; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: all .25s;
  cursor: pointer;
  text-align: center;
}

.cat-card:hover {
  border-color: var(--primary-light);
  background: #EEF2FF;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.cat-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}

/* ===== TOOLS GRID ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.tool-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all .25s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tool-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.tool-card h3 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.tool-card p {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tool-card .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  width: fit-content;
}

.badge-popular { background: #FEF3C7; color: #92400E; }
.badge-new { background: #D1FAE5; color: #065F46; }
.badge-finance { background: #EDE9FE; color: #5B21B6; }

.tool-link {
  margin-top: auto;
  font-size: .85rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-link::after { content: '→'; transition: transform .2s; }
.tool-card:hover .tool-link::after { transform: translateX(4px); }

/* ===== COLOR UTILITIES ===== */
.bg-indigo { background: #EEF2FF; }
.bg-emerald { background: #D1FAE5; }
.bg-orange { background: #FEF3C7; }
.bg-rose { background: #FFE4E6; }
.bg-sky { background: #E0F2FE; }
.bg-violet { background: #EDE9FE; }
.bg-amber { background: #FFFBEB; }
.bg-teal { background: #CCFBF1; }

.c-indigo { color: #4F46E5; }
.c-emerald { color: #059669; }
.c-orange { color: #D97706; }
.c-rose { color: #E11D48; }
.c-sky { color: #0284C7; }
.c-violet { color: #7C3AED; }
.c-amber { color: #B45309; }
.c-teal { color: #0D9488; }

/* ===== CALCULATOR TOOL PAGE ===== */
.calc-page { padding: 40px 20px; }
.calc-page-inner {
  max-width: 820px;
  margin: 0 auto;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--text-light); }

.page-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 32px;
  color: #fff;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.page-hero-icon {
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,.15);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.page-hero h1 {
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  font-weight: 700;
  margin-bottom: 6px;
}

.page-hero p {
  font-size: .9rem;
  opacity: .8;
}

/* Tool form card */
.tool-form-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

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

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

.form-group input,
.form-group select {
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  transition: border-color .2s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--border-focus);
  background: #fff;
}

.form-hint {
  font-size: .75rem;
  color: var(--text-light);
}

.btn-calculate {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-calculate:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-reset {
  background: var(--bg);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: .2s;
  margin-left: 8px;
}
.btn-reset:hover { background: #fff; border-color: var(--primary-light); }

/* Result card */
.result-card {
  background: linear-gradient(135deg, #EEF2FF 0%, #E0F2FE 100%);
  border: 1.5px solid #C7D2FE;
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 20px;
  display: none;
}

.result-card.visible { display: block; }

.result-label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--primary);
  margin-bottom: 6px;
}

.result-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -.5px;
}

.result-sub {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.result-item {
  background: #fff;
  border-radius: 8px;
  padding: 14px;
}
.result-item .r-label { font-size: .75rem; color: var(--text-muted); }
.result-item .r-value { font-size: 1.1rem; font-weight: 700; color: var(--text); }

/* ===== ADSENSE SLOTS ===== */
.adsense-slot {
  background: #F3F4F6;
  border: 1px dashed #D1D5DB;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  color: var(--text-light);
  text-align: center;
  overflow: hidden;
}

.adsense-banner { height: 90px; margin: 20px 0; }
.adsense-rect { min-height: 250px; max-width: 336px; }
.adsense-leaderboard { height: 90px; max-width: 728px; margin: 0 auto; }

/* ===== CONTENT / SEO TEXT ===== */
.content-block {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 24px;
}

.content-block h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.content-block h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 18px 0 8px;
  color: var(--text);
}

.content-block p {
  font-size: .9rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.content-block ul, .content-block ol {
  padding-left: 20px;
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.formula-box {
  background: #1E1B4B;
  color: #C7D2FE;
  border-radius: 8px;
  padding: 14px 18px;
  font-family: 'Courier New', monospace;
  font-size: .9rem;
  margin: 12px 0;
}

/* ===== FAQ ===== */
.faq-list { display: flex; flex-direction: column; gap: 10px; }

.faq-item {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  background: none;
  border: none;
  padding: 16px 20px;
  text-align: left;
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: background .2s;
}
.faq-question:hover { background: var(--bg); }

.faq-chevron {
  flex-shrink: 0;
  transition: transform .3s;
  color: var(--primary);
}
.faq-item.open .faq-chevron { transform: rotate(180deg); }

.faq-answer {
  display: none;
  padding: 0 20px 16px;
  font-size: .875rem;
  line-height: 1.7;
  color: var(--text-muted);
}
.faq-item.open .faq-answer { display: block; }

/* ===== STATS BAR ===== */
.stats-bar {
  background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
  padding: 40px 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.stat-item { color: #fff; }
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  display: block;
  letter-spacing: -.5px;
}
.stat-label { font-size: .85rem; opacity: .75; }

/* ===== FOOTER ===== */
.site-footer {
  background: #111827;
  color: rgba(255,255,255,.7);
  padding: 48px 20px 24px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-brand .logo { color: #fff; margin-bottom: 12px; display: inline-flex; }
.footer-brand p { font-size: .85rem; line-height: 1.7; max-width: 260px; }

.footer-col h4 {
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.footer-links { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.footer-links a {
  color: rgba(255,255,255,.55);
  font-size: .85rem;
  transition: color .2s;
}
.footer-links a:hover { color: #fff; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: .8rem;
}

/* ===== RELATED TOOLS ===== */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.related-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: .2s;
}
.related-card:hover {
  border-color: var(--primary-light);
  background: #EEF2FF;
}

.related-card .r-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.related-card .r-text { font-size: .85rem; font-weight: 500; color: var(--text); }

/* ===== TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table th {
  background: #EEF2FF;
  color: var(--primary);
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid #C7D2FE;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tr:last-child td { border: none; }
.data-table tr:hover td { background: var(--bg); }

/* ===== NOTIFICATION / TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #111827;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  display: none;
  align-items: center;
  gap: 8px;
}
.toast.show { display: flex; animation: slideUp .3s ease; }

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

/* ===== PROGRESS BAR (for loan amortization etc.) ===== */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 20px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .6s ease;
}

/* ===== MOBILE NAV ===== */
@media (max-width: 768px) {
  .main-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    flex-direction: column;
    padding: 12px;
    box-shadow: var(--shadow-md);
    z-index: 99;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 10px 16px; width: 100%; }
  .hamburger { display: flex; }

  .hero { padding: 40px 16px 60px; }
  .calculator { padding: 16px; }
  .calc-display { font-size: 1.8rem; }
  .calc-btn { height: 48px; font-size: .95rem; }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
  }

  .footer-bottom { flex-direction: column; text-align: center; }

  .page-hero { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }

  .section { padding: 40px 16px; }
}

@media (max-width: 480px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .calc-keypad { gap: 6px; }
  .calc-btn { height: 44px; }
}
