/* Basic layout */
:root {
  --bg: #0b0f14;
  --panel: #121821;
  --text: #e6edf3;
  --muted: #a5b3c0;
  --accent: #5cc8ff;
  --accent2: #7ee787;
  --border: #223042;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
}

header, footer { padding: 16px 20px; }
header {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0));
  border-bottom: 1px solid var(--border);
}
.header-actions { position: absolute; top: 16px; right: 20px; display: flex; gap: 8px; }
footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
}
footer a { color: var(--accent); }

.controls {
  display: grid;
  gap: 10px;
  padding: 16px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.control-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
label { color: var(--muted); }
#acceptHeader { width: 220px; }
/* Reduce URL and Limit sizes */
#urlInput { width: min(390px, 45vw); }
#limitInput { width: 110px; }
input[type="url"], input[type="text"], input[type="number"] {
  width: min(780px, 90vw);
  padding: 8px 10px;
  background: #0e141b;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
}

select {
  padding: 8px 10px;
  background: #0e141b;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
}

button {
  padding: 8px 12px;
  background: #1a2430;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.button, .btn-primary { transition: background 0.15s ease, border-color 0.15s ease; }
.btn-primary { background: var(--accent); color: #00131d; border-color: #3aa4d6; }
.btn-primary:hover { background: #79d5ff; border-color: #5cc8ff; }
.btn-danger { background: #d73a49; border-color: #b92533; color: #fff; }
.btn-danger:hover { background: #e55361; border-color: #d73a49; }

#status { color: var(--muted); min-height: 1.5em; }
.muted-info { color: var(--muted); margin-left: 10px; }
.control-row > .muted-info:first-child { margin-left: 0; }
.pagination { justify-content: flex-start; }

.active-filters-row { align-items: center; justify-content: space-between; }
#activeFilters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px;
  background: #0e141b; color: var(--text); font-size: 12px;
}
.chip button { border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }

.advanced-filters { padding: 0 20px 16px; }
.advanced-filters summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
.advanced-grid {
  display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 10px; align-items: center;
}
/* Advanced filters: keep fields close to labels using tight paired columns */
#advPanel .advanced-grid {
  display: grid;
  grid-template-columns:
    auto minmax(140px, 240px)
    auto minmax(140px, 240px)
    auto minmax(140px, 240px);
  column-gap: 10px; /* match Request URL label→field spacing */
  row-gap: 12px;
  align-items: center;
}
/* Increase spacing before labels that begin a new pair to visually group pairs */
#advPanel .advanced-grid > label { margin-left: 24px; }
#advPanel .advanced-grid > label:nth-child(6n+1) { margin-left: 0; }

/* Accept header row: label and input side-by-side with Request URL spacing */
#advancedControls .advanced-grid { display: flex; align-items: center; gap: 10px; }
.advanced-grid input, .advanced-grid select { width: 100%; }

main { display: grid; gap: 20px; padding: 20px; }
.table-section, .chart-section, .facts-section, .facts-list-section, .search-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

/* Align Search and Facts panels with main content spacing */
.search-section { margin: 20px; }
.facts-section { margin: 20px; }
.search-section.controls { border-bottom: none; }

.table-wrapper { overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { text-align: left; color: var(--muted); cursor: pointer; }
tr:hover td { background: rgba(255,255,255,0.02); }

.chart-section canvas { max-width: 100%; }

.table-pagination { justify-content: flex-end; }
.table-pagination #tablePageInfo { min-width: 140px; text-align: center; color: var(--muted); }

.facts-section .fact-card { display: grid; gap: 10px; }
.fact-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: #0e141b; }
.fact-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fact-refresh { display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }
.facts-section .fact-controls input[type="number"],
.facts-section .fact-controls input[type="text"] { width: auto; min-width: 0; }
.facts-section .fact-controls #factMaxLen { width: 220px; }
.facts-section .fact-controls #factIntervalSec { width: 90px; }

.actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 10px; }

/* Toasts */
#toastContainer { position: fixed; left: 50%; top: 35%; transform: translate(-50%, -50%); display: grid; gap: 8px; z-index: 9999; }

/* Modal */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: grid; place-items: center; z-index: 9998; }
.modal-content { background: #0e141b; border: 1px solid var(--border); color: var(--text); padding: 16px; border-radius: 8px; width: min(560px, 90vw); box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
.modal-content h3 { margin: 0 0 10px 0; }
.shortcut-list { margin: 0 0 12px 18px; padding: 0; display: grid; gap: 6px; }
.modal-actions { display: flex; justify-content: flex-end; }

/* Narrow filter inputs to keep labels/fields on one row when possible */
.filters label { white-space: nowrap; margin-right: 0; }
/* Add group separation between pairs in filters row to mimic Request URL spacing for pairs */
.filters input + label { margin-left: 24px; }
#breedFilter { width: clamp(160px, 22vw, 260px); }
#countryFilter { width: clamp(160px, 22vw, 260px); }
#globalSearch { width: clamp(280px, 55vw, 520px); }

/* Add a bit of extra space around the Load Defaults row */
.reset-row { margin-top: 24px; margin-bottom: 8px; }
.toast { background: #0e141b; border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.3); min-width: 280px; max-width: 420px; }
.toast p { margin: 0 0 8px 0; color: var(--text); }
.toast .toast-actions { display: flex; gap: 8px; justify-content: flex-end; }
.toast .toast-actions button { padding: 6px 10px; }
.toast .primary { background: var(--accent); color: #00131d; border-color: #3aa4d6; }

