/* ============================================================
   OnlineCalculatorApp.net — main.css
   Midnight Indigo theme | Light + Dark mode via CSS custom props
   ============================================================ */

/* ── CSS Custom Properties ── */
:root {
  /* Nav */
  --nav-bg:          #1e293b;
  --nav-accent:      #38bdf8;

  /* Hero */
  --hero-from:       #6366f1;
  --hero-to:         #0ea5e9;

  /* Page */
  --bg:              #f8fafc;
  --surface:         #ffffff;
  --border:          #e2e8f0;

  /* Text */
  --text:            #0f172a;
  --text-muted:      #475569;
  --text-subtle:     #94a3b8;

  /* Accent / brand */
  --accent:          #6366f1;
  --accent-hover:    #4f46e5;
  --accent-sky:      #38bdf8;

  /* Result highlight */
  --result-bg:       #f0fdf4;
  --result-text:     #15803d;
  --result-border:   #bbf7d0;

  /* Crypto card */
  --crypto-bg:       #dcfce7;
  --crypto-accent:   #86efac;

  /* Ad slots */
  --ad-bg:           #ffffff;

  /* Misc */
  --radius:          0.5rem;
  --radius-lg:       0.75rem;
  --shadow:          0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:       0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:       0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);

  /* Typography */
  --font:            -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --fw-normal:       400;
  --fw-medium:       500;
  --fw-bold:         700;
  --fw-extrabold:    800;
}

[data-theme="dark"] {
  --nav-bg:          #0f172a;
  --nav-accent:      #38bdf8;

  --hero-from:       #4f46e5;
  --hero-to:         #0284c7;

  --bg:              #0f172a;
  --surface:         #1e293b;
  --border:          #334155;

  --text:            #f1f5f9;
  --text-muted:      #94a3b8;
  --text-subtle:     #64748b;

  --result-bg:       #14532d;
  --result-text:     #4ade80;
  --result-border:   #166534;

  --crypto-bg:       #14532d;
  --crypto-accent:   #4ade80;

  --ad-bg:           #ffffff; /* always white */
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-weight: var(--fw-normal);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

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

img { max-width: 100%; display: block; }

ul { list-style: none; }

/* ── Layout ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container--narrow {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ── Navigation ── */
.nav {
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.05);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 60px;
}

.nav__logo {
  font-size: 1.15rem;
  font-weight: var(--fw-bold);
  color: var(--nav-accent);
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: -.01em;
}
.nav__logo:hover { text-decoration: none; opacity: .85; }

.nav__links {
  display: flex;
  align-items: center;
  gap: .15rem;
  flex: 1;
  justify-content: center;
}

.nav__links a,
.nav__dropdown-toggle {
  color: #cbd5e1;
  font-size: .875rem;
  font-weight: var(--fw-medium);
  padding: .4rem .65rem;
  border-radius: var(--radius);
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav__links a:hover,
.nav__dropdown-toggle:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  text-decoration: none;
}

/* Dropdown */
.nav__dropdown { position: relative; }

.nav__dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + .5rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--nav-bg);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}
.nav__dropdown:hover .nav__dropdown-menu,
.nav__dropdown-menu:hover { display: block; }

.nav__dropdown-menu a {
  display: block;
  padding: .55rem 1rem;
  font-size: .875rem;
  color: #cbd5e1;
}
.nav__dropdown-menu a:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  text-decoration: none;
}

/* Nav right */
.nav__right {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.nav__search {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  color: #f1f5f9;
  font-size: .85rem;
  padding: .35rem .9rem;
  width: 200px;
  outline: none;
  transition: background .15s, border-color .15s;
}
.nav__search::placeholder { color: #64748b; }
.nav__search:focus {
  background: rgba(255,255,255,.12);
  border-color: var(--accent-sky);
}

.nav__theme-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  color: #f1f5f9;
  font-size: 1rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.nav__theme-btn:hover { background: rgba(255,255,255,.15); }

/* Mobile nav toggle */
.nav__hamburger {
  display: none;
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 1.4rem;
  cursor: pointer;
  padding: .25rem;
}

/* Search results dropdown */
.search-results {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: none;
}
.search-results.open { display: block; }
.search-result-item {
  display: block;
  padding: .65rem 1rem;
  font-size: .875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg); text-decoration: none; }
.search-result-item__cat {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .1rem;
}

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  padding: 4rem 1.25rem;
  text-align: center;
  color: #fff;
}

.hero__title {
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: var(--fw-extrabold);
  line-height: 1.15;
  margin-bottom: .75rem;
  letter-spacing: -.02em;
}

.hero__sub {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  opacity: .9;
  margin-bottom: 2rem;
}

.hero__search {
  display: flex;
  max-width: 520px;
  margin: 0 auto;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
}
.hero__search input {
  flex: 1;
  border: none;
  padding: .85rem 1.4rem;
  font-size: 1rem;
  outline: none;
  color: #0f172a;
}
.hero__search button {
  background: #0f172a;
  color: #fff;
  border: none;
  padding: .85rem 1.5rem;
  font-size: .95rem;
  font-weight: var(--fw-bold);
  cursor: pointer;
  transition: opacity .15s;
}
.hero__search button:hover { opacity: .85; }

/* ── Ad Slots ── */
.ad-slot {
  background: var(--ad-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: .8rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  border: 1px dashed #e2e8f0;
  border-radius: var(--radius);
  margin: 1.5rem auto;
}

.ad-leaderboard {
  width: 100%;
  max-width: 728px;
  height: 90px;
}

.ad-rectangle {
  width: 300px;
  height: 250px;
  margin: 1.5rem auto;
}

@media (max-width: 768px) {
  .ad-leaderboard { max-width: 320px; height: 50px; }
}

/* ── Breadcrumb ── */
.breadcrumb {
  font-size: .85rem;
  color: var(--text-muted);
  padding: .9rem 0;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--accent); }
.breadcrumb span { color: var(--text-subtle); }

/* ── Category Grid (homepage) ── */
.section { padding: 3rem 0; }
.section__title {
  font-size: 1.5rem;
  font-weight: var(--fw-bold);
  margin-bottom: 1.5rem;
  color: var(--text);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1rem;
  text-align: center;
  transition: box-shadow .15s, transform .15s, border-color .15s;
  text-decoration: none;
  display: block;
}
.category-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--accent);
  text-decoration: none;
}
.category-card__emoji { font-size: 2rem; margin-bottom: .5rem; }
.category-card__name {
  font-size: .95rem;
  font-weight: var(--fw-bold);
  color: var(--text);
  margin-bottom: .25rem;
}
.category-card__count {
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Calculator Grid (category page) ── */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: box-shadow .15s, border-color .15s;
  text-decoration: none;
  display: block;
}
.calc-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  text-decoration: none;
}
.calc-card__title {
  font-size: 1rem;
  font-weight: var(--fw-bold);
  color: var(--text);
  margin-bottom: .4rem;
}
.calc-card__desc {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Calculator Page ── */
.page-title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: var(--fw-extrabold);
  color: var(--text);
  margin-bottom: .5rem;
  letter-spacing: -.02em;
}

.page-desc {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  max-width: 640px;
}

/* Input grid */
.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.field { display: flex; flex-direction: column; gap: .35rem; }

.field label {
  font-size: .875rem;
  font-weight: var(--fw-medium);
  color: var(--text);
}

.field input,
.field select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  font-family: var(--font);
  padding: .6rem .85rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.field input[type="range"] {
  padding: .35rem 0;
  accent-color: var(--accent);
  border: none;
  background: none;
  box-shadow: none;
}

/* Calculate button */
.btn-calculate {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: var(--fw-bold);
  font-family: var(--font);
  padding: .75rem 2rem;
  cursor: pointer;
  transition: background .15s, transform .1s;
  margin-bottom: 1.5rem;
}
.btn-calculate:hover { background: var(--accent-hover); }
.btn-calculate:active { transform: scale(.98); }

/* Results card */
.results-card {
  background: var(--result-bg);
  border: 1px solid var(--result-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  display: none;
}
.results-card.visible { display: block; }

.results-card__title {
  font-size: 1rem;
  font-weight: var(--fw-bold);
  color: var(--result-text);
  margin-bottom: 1rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.result-item__label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: .2rem;
}
.result-item__value {
  font-size: 1.3rem;
  font-weight: var(--fw-bold);
  color: var(--result-text);
}

/* Amortization / extended output */
.extras { margin-top: 1.5rem; }

.extras__title {
  font-size: 1.1rem;
  font-weight: var(--fw-bold);
  color: var(--text);
  margin-bottom: .75rem;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: .6rem .75rem;
  text-align: left;
  font-weight: var(--fw-bold);
  color: var(--text);
  white-space: nowrap;
}
tbody td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
tbody tr:hover td { background: var(--bg); }

/* ── Crypto Security Banner ── */
.crypto-warning {
  background: #fefce8;
  border: 2px solid #fbbf24;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: .75rem;
  align-items: flex-start;
}
[data-theme="dark"] .crypto-warning {
  background: #451a03;
  border-color: #d97706;
}
.crypto-warning__icon { font-size: 1.2rem; flex-shrink: 0; margin-top: .1rem; }
.crypto-warning__text { font-size: .9rem; color: #92400e; line-height: 1.5; }
[data-theme="dark"] .crypto-warning__text { color: #fcd34d; }
.crypto-warning__text strong { display: block; margin-bottom: .25rem; font-size: .95rem; }

/* Crypto card */
.crypto-card {
  background: var(--crypto-bg);
  border: 1px solid var(--crypto-accent);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.crypto-output {
  font-family: 'Courier New', monospace;
  font-size: .85rem;
  word-break: break-all;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  color: var(--text);
  margin-top: .5rem;
}
.copy-btn {
  font-size: .8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .3rem .75rem;
  cursor: pointer;
  margin-top: .5rem;
  font-family: var(--font);
}
.copy-btn:hover { background: var(--accent-hover); }

/* ── Footer ── */
.footer {
  background: var(--nav-bg);
  color: #94a3b8;
  padding: 3rem 0 1.5rem;
  margin-top: 4rem;
}
.footer__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
}
.footer__col-title {
  font-size: .875rem;
  font-weight: var(--fw-bold);
  color: #e2e8f0;
  margin-bottom: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.footer__col a {
  display: block;
  font-size: .85rem;
  color: #94a3b8;
  margin-bottom: .4rem;
  transition: color .15s;
}
.footer__col a:hover { color: #fff; text-decoration: none; }
.footer__bottom {
  border-top: 1px solid rgba(255,255,255,.07);
  padding-top: 1.25rem;
  text-align: center;
  font-size: .8rem;
  color: #64748b;
}

/* ── Utility ── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: var(--fw-bold);
  padding: .15rem .5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  letter-spacing: .03em;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .category-grid { grid-template-columns: repeat(4, 1fr); }
  .footer__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .nav__links { display: none; }
  .nav__links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    padding: .75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    z-index: 99;
  }
  .nav__hamburger { display: block; }
  .nav__search { width: 140px; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .input-grid { grid-template-columns: 1fr; }
  .footer__grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .footer__grid { grid-template-columns: 1fr; }
  .hero { padding: 2.5rem 1rem; }
}

/* ── Scrollbar (subtle) ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }
