/* ============================================================
   Fishing Buddy — Dark mode, mobile-first
   ============================================================ */
:root {
  --bg: #0b1418;
  --bg-elev: #11202a;
  --bg-elev-2: #16303d;
  --line: #1f3a48;
  --text: #e6f1f6;
  --muted: #8aa4b1;
  --accent: #29c39a;        /* fishing green */
  --accent-2: #2bb3ff;      /* water blue */
  --warn: #f3b341;
  --danger: #ff5d6c;
  --ok: #29c39a;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 64px;
  font-synthesis: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0));
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent-2); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.05rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: .25em 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0));
  background: linear-gradient(180deg, #0e1c23 0%, rgba(14,28,35,.92) 100%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 1.6rem; }
.brand-text h1 { display: inline-flex; align-items: center; gap: 8px; }
.subtitle { margin: 0; font-size: .78rem; color: var(--muted); }

.wip-badge {
  display: inline-block;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f5a623, #e76f51);
  color: #1a0e00;
  vertical-align: middle;
  box-shadow: 0 1px 4px rgba(245, 166, 35, .35);
}

.wip-banner {
  font-size: .82rem;
  color: var(--muted);
  background: rgba(245, 166, 35, .08);
  border: 1px dashed rgba(245, 166, 35, .35);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  line-height: 1.4;
}
.wip-banner b { color: #f5a623; }
.wip-banner a { color: var(--accent, #6ec1ff); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, var(--bg-elev), var(--bg-elev-2));
  color: var(--text); font-size: 1.25rem; cursor: pointer;
  display: grid; place-items: center;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, color .2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.04);
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 14px rgba(41, 195, 154, .25), inset 0 1px 0 rgba(255,255,255,.06);
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.spinning { animation: spin 1s linear infinite; pointer-events: none; opacity: .7; }
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ---------- Layout / Cards ---------- */
main#app { padding: 14px; display: block; }
.view { display: flex; flex-direction: column; gap: 14px; }
.view[hidden] { display: none; }   /* HTML `hidden` must beat CSS display */

/* ---------- Plan results ---------- */
.plan-list { display: grid; gap: 10px; }
.plan-item {
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.plan-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.plan-head h4 { margin: 0; font-size: 1rem; }
.plan-score {
  min-width: 64px; padding: 10px; border-radius: 12px;
  background: linear-gradient(180deg, #2fd6a9, #1f9d7a);
  color: #06221a; font-weight: 800; font-size: 1.25rem;
  text-align: center;
}
.plan-score small { font-size: .7rem; opacity: .8; margin-left: 1px; }
.plan-rows { display: flex; flex-direction: column; gap: 4px; }
.plan-row { font-size: .9rem; }
.plan-key { color: var(--muted); }
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card.warning { border-color: #4a3a1a; background: #221a0e; }
.card.warning h3 { color: var(--warn); }

/* ---------- Hero ---------- */
.hero { background: radial-gradient(120% 100% at 0% 0%, #15384a 0%, #0e2230 50%, var(--bg-elev) 100%); }
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero h2 { font-size: 1.5rem; }
.score {
  width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p,0)*1%), #243845 0);
  position: relative;
  box-shadow: inset 0 0 0 6px var(--bg-elev);
}
.score::after {
  content: ""; position: absolute; inset: 8px; border-radius: 50%;
  background: var(--bg-elev);
}
.score span, .score small { position: relative; z-index: 1; }
.score span { font-size: 1.5rem; font-weight: 700; }
.score small { font-size: .7rem; color: var(--muted); margin-left: 1px; }

/* ---------- Form ---------- */
.form-grid {
  display: grid; gap: 10px;
  grid-template-columns: 1fr 1fr;
}
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.form-grid label.full { grid-column: 1 / -1; }
input, select, textarea, button {
  font: inherit; color: var(--text);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 12px top 18px, right 7px top 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
textarea { resize: vertical; }
.btn {
  display: inline-block; text-align: center;
  border: 1px solid var(--line); background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; font-weight: 600;
  margin-top: 10px; margin-right: 6px;
  transition: transform .05s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(180deg, #2fd6a9, #1f9d7a); color: #06221a; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: #5a2330; }

/* ---------- Weather ---------- */
.weather-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
.wx {
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.wx span { color: var(--muted); font-size: .82rem; }
.wx b { font-size: 1.05rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; table-layout: fixed; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; word-wrap: break-word; }
.table th:nth-child(1), .table td:nth-child(1) { width: 38%; }
.table th:nth-child(2), .table td:nth-child(2) { width: 32%; }
.table th:nth-child(3), .table td:nth-child(3) { width: 30%; text-align: right; font-variant-numeric: tabular-nums; }
.table th { color: var(--muted); font-weight: 600; }
.table tr.closed td { color: var(--muted); }
.badge {
  display: inline-block; font-size: .72rem; padding: 2px 8px;
  border-radius: 999px; background: var(--bg-elev-2); border: 1px solid var(--line);
}
.badge.ok { background: #0f2e25; border-color: #1c5642; color: var(--ok); }
.badge.closed { background: #2a1a1d; border-color: #5a2330; color: var(--danger); }
.badge.nokill { background: #1c2940; border-color: #2a4978; color: var(--accent-2); }

/* ---------- Lists ---------- */
.revir-list, .diary-list { display: grid; gap: 10px; }
.revir-item, .diary-item {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.revir-item .row, .diary-item .row { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.revir-item h4, .diary-item h4 { margin: 0; font-size: 1rem; }

.countdown-list { display: grid; gap: 8px; }
.cd { display: flex; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-elev-2); }
.cd b { font-variant-numeric: tabular-nums; }

/* ---------- Recommendation / key-value rows (aligned grid) ---------- */
#recommendationBody .reco-row,
.plan-rows .plan-row {
  display: grid;
  grid-template-columns: minmax(140px, 38%) 1fr;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  align-items: baseline;
}
#recommendationBody .reco-row:last-child,
.plan-rows .plan-row:last-child { border-bottom: 0; }
#recommendationBody .reco-key,
.plan-rows .plan-key { color: var(--muted); }
.plan-rows .plan-row > span:last-child { text-align: right; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: #0c1a22; border-top: 1px solid var(--line);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: transparent; border: 0; color: var(--muted);
  font-size: .7rem; padding: 0; margin: 0;
  border-radius: 0;
}
.nav-btn span { font-size: 1.35rem; }
.nav-btn.active { color: var(--accent); }
.nav-btn:active { background: #0f2330; }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; padding: 0; background: transparent;
  width: min(440px, 92vw); margin: auto;
}
dialog.modal::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
dialog.modal form {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
dialog.modal label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  background: var(--bg-elev-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 14px; border-radius: 999px; z-index: 40;
  box-shadow: var(--shadow); font-size: .9rem;
}

/* ---------- Knot card (legacy, no longer used) ---------- */

/* ---------- Sun / Moon / Solunar ---------- */
.sun-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
.flood-row { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.solunar-list { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.solunar-list li {
  display: flex; gap: 8px; align-items: center;
  padding: 6px 10px; background: var(--bg-elev-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: .9rem;
}
.solunar-list b { font-variant-numeric: tabular-nums; }

/* ---------- Activity reasons pills ---------- */
.hero-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill {
  display: inline-block; font-size: .78rem;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(41, 195, 154, .12);
  border: 1px solid rgba(41, 195, 154, .35);
  color: var(--accent);
}

/* ---------- Gear checklist ---------- */
.gear-list { list-style: none; padding: 0; margin: 6px 0 12px; display: grid; gap: 6px; }
.gear-check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 6px 10px; background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.gear-check input { width: auto; margin-top: 3px; }
.gear-check input:checked + span { text-decoration: line-through; color: var(--muted); }
#gearContent h4 { margin-top: 12px; color: var(--accent); font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Larger screens (tablet & desktop) ---------- */
@media (min-width: 768px) {
  body { padding-bottom: 24px; }

  main#app {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px;
  }

  /* Top-mounted nav (sits naturally between topbar and main thanks to DOM order) */
  .bottom-nav {
    position: static;
    left: auto; right: auto; bottom: auto; top: auto;
    height: auto;
    max-width: 1180px;
    margin: 14px auto;
    padding: 6px;
    grid-template-columns: repeat(6, max-content);
    justify-content: center;
    gap: 6px;
    border-top: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-elev);
    box-shadow: var(--shadow);
  }
  .nav-btn {
    flex-direction: row;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: .9rem;
  }
  .nav-btn span { font-size: 1.1rem; }
  .nav-btn small { font-size: .9rem; }
  .nav-btn.active {
    background: rgba(41, 195, 154, .14);
    color: var(--accent);
  }

  /* Forms breathe on wide screens */
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .weather-grid { grid-template-columns: repeat(3, 1fr); }

  /* Hero gets more room */
  .hero h2 { font-size: 1.8rem; }
  .score { width: 110px; height: 110px; }
  .score span { font-size: 2rem; }

  /* Tables look nicer */
  .table { font-size: .95rem; }
  .table th, .table td { padding: 12px 14px; }

  /* Revíry as a grid */
  .revir-list { grid-template-columns: repeat(2, 1fr); }
  .diary-list { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  /* Two-column layout on Buddy view: hero spans, rest grids */
  [data-view="buddy"] {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }
  [data-view="buddy"] .hero { grid-column: 1 / -1; }
  [data-view="buddy"][hidden] { display: none !important; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .weather-grid { grid-template-columns: repeat(3, 1fr); }
  .sun-grid { grid-template-columns: repeat(4, 1fr); }
  .plan-list { grid-template-columns: repeat(2, 1fr); }
  .revir-list { grid-template-columns: repeat(3, 1fr); }
  .diary-list { grid-template-columns: repeat(3, 1fr); }
  /* Tables na desktope: prvý stĺpec užší, keeže máme viac miesta na popis */
  .table th:nth-child(1), .table td:nth-child(1) { width: 26%; }
  .table th:nth-child(2), .table td:nth-child(2) { width: 40%; }
  .table th:nth-child(3), .table td:nth-child(3) { width: 34%; }
}

@media (min-width: 1280px) {
  main#app, .bottom-nav { max-width: 1340px; }
  [data-view="buddy"] {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
  }
  [data-view="buddy"] .hero { grid-column: 1 / -1; }
  [data-view="buddy"] #recommendationCard,
  [data-view="buddy"] #alertsCard { grid-column: 1 / -1; }
  .plan-list { grid-template-columns: repeat(3, 1fr); }
  .revir-list { grid-template-columns: repeat(3, 1fr); }
  .diary-list { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1600px) {
  main#app, .bottom-nav { max-width: 1480px; }
}
