/* ============================================================================
   tools.css - shared layout for the planner pages (buildings, SvS planner,
   march ratios, server timeline). Loaded after styles-v3.css; colours come
   from its tokens, so light mode just works.
   ========================================================================== */

/* ------------------------------------------------------------- Page header */
.tl-header {
  margin-bottom: var(--gap);
  padding: 1.2rem var(--pad);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.14), rgba(167, 139, 250, 0.1)), var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
body[data-theme="light"] .tl-header {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.08), rgba(124, 58, 237, 0.06)), var(--card-bg);
}
.tl-header h1 { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.3rem; }
.tl-header h1 img { width: 44px; height: 44px; object-fit: cover; border-radius: 12px; }
.tl-header h1 .tl-h-ico {
  display: inline-flex;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  height: 44px;
  font-size: 1.2rem;
  color: #04121f;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: 12px;
}
.tl-header p { margin: 0; font-size: 0.95rem; color: var(--text-light); }

/* ------------------------------------------------------------------ Layout */
.tl-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-items: start; }
.tl-layout > * { min-width: 0; }
@media (min-width: 900px) {
  .tl-layout { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  .tl-layout > .tl-controls { position: sticky; top: calc(var(--nav-h) + 12px); }
}
.tl-card {
  margin: 0 0 var(--gap);
  padding: var(--pad);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.tl-layout .tl-card { margin: 0; }
.tl-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); min-width: 0; }
.tl-card > h2, .tl-card > h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}
.tl-card > h2::before, .tl-card > h3::before {
  content: "";
  flex: 0 0 auto;
  width: 4px;
  height: 1.1em;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--primary), var(--accent));
}
.tl-lead { margin: -0.2rem 0 0.8rem; font-size: 0.85rem; line-height: 1.5; color: var(--text-light); }
.tl-note {
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-dim);
}
.tl-note i { margin-right: 0.3rem; }

/* ------------------------------------------------------------------ Fields */
.tl-fields { display: grid; gap: 0.6rem; }
.tl-fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tl-field { display: grid; gap: 0.25rem; min-width: 0; font-size: 0.8rem; font-weight: 600; color: var(--text-light); }
.tl-field input,
.tl-field select {
  width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 0;
  padding: 0 0.7rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tl-field input:focus, .tl-field select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.tl-field .tl-unit-wrap { position: relative; display: flex; }
.tl-field .tl-unit-wrap input { padding-right: 1.9rem; }
.tl-field .tl-unit {
  position: absolute;
  top: 50%;
  right: 0.65rem;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--text-dim);
  pointer-events: none;
}
.tl-hint { font-size: 0.75rem; font-weight: 500; color: var(--text-dim); }

/* Segmented toggle */
.tl-seg {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 0.8rem;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.tl-seg button {
  flex: 1 1 0;
  min-height: 36px;
  padding: 0 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-light);
  background: none;
  border: none;
  border-radius: var(--radius-pill);
  box-shadow: none;
  cursor: pointer;
}
.tl-seg button[aria-pressed="true"] {
  color: #04121f;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

/* ----------------------------------------------------------------- Buttons */
.tl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0 0.95rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: none;
  cursor: pointer;
}
.tl-btn:hover { border-color: var(--border-strong); }
.tl-btn.primary { color: #04121f; background: linear-gradient(135deg, var(--primary-light), var(--primary)); border-color: transparent; }
.tl-btn.small { min-height: 32px; padding: 0 0.65rem; font-size: 0.8rem; }
.tl-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ------------------------------------------------------------ Stat tiles */
.tl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 0.5rem; }
@media (max-width: 479px) { .tl-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tl-stat {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.15rem 0.6rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tl-stat img, .tl-stat .tl-stat-ico { grid-row: span 2; width: 34px; height: 34px; object-fit: contain; }
.tl-stat .tl-stat-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--primary);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.tl-stat-label { font-size: 0.75rem; font-weight: 600; color: var(--text-dim); }
.tl-stat-value { font-size: 1.1rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tl-stat-sub { grid-column: 2; font-size: 0.75rem; color: var(--text-dim); }
.tl-stat.big { grid-column: 1 / -1; }
.tl-stat.big .tl-stat-value { font-size: 1.5rem; }
.tl-stat.short .tl-stat-sub { color: var(--danger); font-weight: 700; }
.tl-stat.enough .tl-stat-sub { color: var(--ok); font-weight: 700; }

/* ------------------------------------------------------------------ Tables */
.tl-table-wrap { overflow-x: auto; margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad); }
.tl-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.tl-table th, .tl-table td { padding: 0.5rem 0.55rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.tl-table th:first-child, .tl-table td:first-child { text-align: left; }
.tl-table th { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); }
.tl-table tbody tr:hover { background: var(--surface); }
.tl-table tfoot td { font-weight: 800; color: var(--text); border-bottom: none; }
.tl-table .tl-bname { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--text); }
.tl-table .tl-bname img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; }

/* ------------------------------------------------------------------- Misc */
.tl-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-light);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}
.tl-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
}
.tl-badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.tl-badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.tl-link-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }
.tl-faq details { padding: 0.65rem 0; border-bottom: 1px solid var(--border); }
.tl-faq details:last-child { border-bottom: none; }
.tl-faq summary { font-weight: 700; cursor: pointer; }
.tl-faq p { margin: 0.5rem 0 0; font-size: 0.88rem; line-height: 1.55; color: var(--text-light); }
[hidden] { display: none !important; }
