/* Long-Range BTR Tool Styles */

#btr-app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  box-sizing: border-box;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.btr-card,
.result-section {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

[data-theme="dark"] .btr-card,
[data-theme="dark"] .result-section {
  background: var(--card, #111111);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--foreground);
  margin: 0 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--border, #e5e7eb);
}

/* ── Form Bar (matches BirthDataFormBar exactly) ─────────────────────────── */
.btr-form-bar {
  background: var(--card, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 10;
}
[data-theme="dark"] .btr-form-bar { background: var(--card, #111111); }

.btr-form-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: .6rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.btr-form-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}

.btr-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
}

/* field width presets */
.btr-field-name    { flex: 1 1 110px; min-width: 90px; }
.btr-field-date    { flex: 0 0 auto; }
.btr-field-gender  { flex: 0 0 auto; }
.btr-field-star    { flex: 1 1 180px; min-width: 150px; }
.btr-field-utc     { flex: 0 0 78px; }
.btr-field-sunrise { flex: 0 0 78px; }
.btr-field-place   { flex: 1 1 200px; min-width: 150px; }
.btr-field-time    { flex: 0 0 auto; }

/* selects inside btr-field fill the field width */
.btr-field select.input { width: 100%; }

/* flex line break between rows */
.btr-break { display: block; flex: 0 0 100%; height: 0; }

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

/* ── Location Autocomplete ────────────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--card, #fff);
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
}

.ac-item {
  padding: .55rem .8rem;
  font-size: .88rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border, #f1f5f9);
  color: var(--foreground);
}
.ac-item:hover { background: var(--accent, #f0f9ff); }
.ac-item:last-child { border-bottom: none; }
.ac-error { color: #ef4444; }

.coord-hint { font-size: .78rem; color: var(--muted-foreground); margin-top: .3rem; display: block; }

/* ── Timestamps ───────────────────────────────────────────────────────────── */
.section-hint { font-size: .87rem; color: var(--muted-foreground); margin-bottom: .75rem; }
.section-hint code { background: var(--muted, #f1f5f9); padding: .1em .4em; border-radius: 4px; font-size: .85em; }

.paste-area-wrap { display: flex; gap: .75rem; align-items: flex-start; }
.paste-area-wrap textarea {
  flex: 1; padding: .65rem; font-size: .85rem; font-family: monospace;
  border: 1px solid var(--border); border-radius: 6px; resize: vertical;
  background: var(--background); color: var(--foreground);
}

.ts-count { font-size: .85rem; color: var(--muted-foreground); margin: .5rem 0; font-weight: 600; }

.ts-table-wrap { overflow-x: auto; margin-bottom: .75rem; }
.ts-edit-table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.ts-edit-table th {
  background: var(--muted, #f3f4f6); color: var(--foreground); padding: .45rem .7rem;
  text-align: left; font-size: .8rem; white-space: nowrap;
  border-bottom: 2px solid var(--border, #d1d5db);
}
.ts-edit-table td { padding: .4rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ts-edit-table tr.ts-alt td { background: var(--muted, #f8fafc); }
[data-theme="dark"] .ts-edit-table tr.ts-alt td { background: transparent; }
.ts-edit-table tr.ts-edit-mode td { background: #fffbeb; }
[data-theme="dark"] .ts-edit-table tr.ts-edit-mode td { background: #3b2800; }
.ts-note-view { max-width: 420px; white-space: normal; }

.ts-inp {
  border: 1px solid var(--border); border-radius: 5px; padding: .3rem .5rem;
  font-size: .83rem; background: var(--background); color: var(--foreground);
}
.ts-inp.ts-date { width: 120px; }
.ts-inp.ts-time { width: 80px; }
.ts-inp.wide    { width: 100%; min-width: 220px; }

.ts-actions { white-space: nowrap; }
.ts-btn {
  padding: .25rem .65rem; border-radius: 5px; font-size: .78rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; margin-right: .25rem;
}
.ts-edit   { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ts-edit:hover { background: #dbeafe; }
.ts-del    { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.ts-del:hover  { background: #ffe4e6; }
.ts-save   { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.ts-save:hover { background: #dcfce7; }
.ts-cancel { background: var(--muted); color: var(--muted-foreground); border-color: var(--border); }
.ts-cancel:hover { background: var(--accent); }

/* ── Run Bar ──────────────────────────────────────────────────────────────── */
.btr-run-bar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--card, #fff); border: 1px solid var(--border, #e2e8f0); border-radius: 8px;
  margin-bottom: 1.25rem;
}

.progress-bar-outer {
  flex: 1; height: 8px; background: var(--muted, #e2e8f0); border-radius: 4px; overflow: hidden;
}
.progress-bar-inner {
  height: 100%; background: var(--primary, #663399); border-radius: 4px; transition: width .3s;
}
#progress-text { font-size: .85rem; color: var(--muted-foreground); white-space: nowrap; }
.run-error { color: #ef4444; font-size: .88rem; }

#progress-wrap { display: flex; align-items: center; gap: .75rem; flex: 1; }

/* ── Print Controls ───────────────────────────────────────────────────────── */
.print-controls {
  display: flex; gap: .75rem; align-items: center;
  margin-bottom: 1.25rem;
  padding: .75rem 1rem;
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px;
}

/* ── Report Sections ──────────────────────────────────────────────────────── */
.section-title {
  font-size: 1.05rem; font-weight: 700; color: var(--foreground);
  margin: 0 0 .4rem; padding-bottom: .4rem; border-bottom: 2px solid var(--border, #e2e8f0);
}
.section-desc { font-size: .85rem; color: var(--muted-foreground); margin: 0 0 1rem; }

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

/* ── BRT Tables ───────────────────────────────────────────────────────────── */
.btr-table {
  border-collapse: collapse; width: 100%; font-size: .78rem;
}
.btr-table th {
  background: #1e3a5f; color: #fff; padding: .4rem .55rem;
  text-align: center; white-space: nowrap; font-weight: 600; font-size: .75rem;
}
[data-theme="dark"] .btr-table th { background: #0f2237; }
.btr-table td {
  padding: .35rem .55rem; border-bottom: 1px solid var(--border, #f1f5f9);
  text-align: center; white-space: nowrap;
}
.btr-table td.note-cell,
.btr-table td.planets-cell,
.btr-table td.notes-cell { text-align: left; white-space: normal; }

.btr-table tr.alt-row { background: var(--muted, #f8fafc); }
[data-theme="dark"] .btr-table tr.alt-row { background: transparent; }
.btr-table tr.best-row { background: #dcfce7; font-weight: 600; }
[data-theme="dark"] .btr-table tr.best-row { background: #052e16; color: #4ade80; }
.btr-table tr.hint-row { background: #fef9c3; }
[data-theme="dark"] .btr-table tr.hint-row { background: #422006; }
.btr-table tr.top-row  { background: #fef3c7; font-weight: 600; }
[data-theme="dark"] .btr-table tr.top-row  { background: #422006; }
.btr-table tr.err-row  { background: #fef2f2; }
[data-theme="dark"] .btr-table tr.err-row  { background: #2d0a0a; }
.err-cell { color: #ef4444; text-align: left; }

.gs-badge { font-weight: 700; color: #16a34a; }

/* ── Analysis ─────────────────────────────────────────────────────────────── */
.analysis-table { max-width: 900px; }

.bar-col { min-width: 200px; }
.freq-bar {
  background: var(--primary, #663399); color: #fff; font-size: .75rem; font-weight: 600;
  padding: .15rem .4rem; border-radius: 3px; min-width: 20px; white-space: nowrap;
  display: inline-block;
}
.top-row .freq-bar { opacity: .7; }

.deg-stats {
  font-size: .92rem; font-weight: 600; color: var(--foreground);
  margin-bottom: .75rem;
}

/* ── Verdict ──────────────────────────────────────────────────────────────── */
.verdict-section { border: 2px solid #16a34a; }
.verdict-section .section-title { border-bottom-color: #16a34a; }

.verdict-box {
  background: #dcfce7; border: 1px solid #86efac; border-radius: 8px;
  padding: 1.25rem 1.5rem; margin-bottom: 1rem; text-align: center;
}
[data-theme="dark"] .verdict-box { background: #052e16; border-color: #166534; }
.verdict-time {
  font-size: 2rem; font-weight: 800; color: #14532d; letter-spacing: .04em;
}
[data-theme="dark"] .verdict-time { color: #4ade80; }
.verdict-asc { font-size: 1rem; font-weight: 600; color: #166534; margin-top: .25rem; }
[data-theme="dark"] .verdict-asc { color: #4ade80; }

.verdict-breakdown { margin-bottom: 1rem; }

.top3-note {
  font-size: .85rem; color: var(--muted-foreground);
  padding: .6rem .8rem; background: var(--muted); border-radius: 6px;
}

/* ── Report Header (print only) ───────────────────────────────────────────── */
.report-header { display: none; }
.rh-title {
  font-size: 1.4rem; font-weight: 800; color: var(--foreground);
  margin-bottom: .6rem;
}
.rh-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem .75rem;
  font-size: .85rem; color: var(--foreground);
}

/* ════════════════════════════════════════════════
   PRINT STYLES
════════════════════════════════════════════════ */
@media print {
  @page { size: A3 landscape; margin: 1cm; }

  .no-print  { display: none !important; }
  .print-only { display: block !important; }

  #btr-app { padding: 0; max-width: 100%; }
  .print-controls { display: none !important; }

  .report-header {
    display: block !important;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid #1e3a5f;
  }

  .result-section {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: .75rem;
    padding: .75rem;
  }

  .btr-table { font-size: .65rem; }
  .btr-table th, .btr-table td { padding: .2rem .3rem; }

  .freq-bar { background: #333 !important; }

  .verdict-time { font-size: 1.5rem; }
  .verdict-box { padding: .75rem 1rem; }
}
