/*
Nazwa pliku: styles.css
Docelowa sciezka: /home/raider/trasy-raider-pl/styles.css
Opis: Style statycznej aplikacji web do planowania tras VanKing.
Powiazania: /home/raider/trasy-raider-pl/index.html, /home/raider/trasy-raider-pl/app.js
*/

/* ============================================================
   BAZA
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #17202a;
  --muted: #657284;
  --line: #d8e0e8;
  --line-strong: #b8c5d1;
  --accent: #1f6f4a;
  --accent-soft: #e7f4ed;
  --warning: #a66f00;
  --warning-soft: #fff5d6;
  --danger: #a33a2b;
  --danger-soft: #fdebe7;
  --taxi: #255c99;
  --taxi-soft: #e8f1fb;
  --shadow: 0 8px 20px rgba(24, 39, 56, 0.08);
  --radius: 8px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #8ea1b3;
  background: #f9fbfd;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(31, 111, 74, 0.24);
  outline-offset: 2px;
}

button[aria-pressed="true"],
.route-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

h1,
h2,
h3,
p {
  margin: 0;
}

strong {
  font-weight: 700;
}

.app-shell {
  width: min(1880px, 100%);
  margin: 0 auto;
  padding: 18px;
}

/* ============================================================
   LOGOWANIE
   ============================================================ */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg);
}

.auth-gate[hidden] {
  display: none;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  font-size: 22px;
}

.auth-panel p {
  color: var(--muted);
}

.auth-actions {
  display: grid;
}

.auth-actions button {
  min-height: 42px;
  font-weight: 700;
}

.auth-message {
  min-height: 22px;
  overflow-wrap: anywhere;
}

/* ============================================================
   GORNY PANEL
   ============================================================ */

.topbar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(360px, 1.55fr);
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.title-block {
  min-width: 0;
}

.title-block h1 {
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.title-block p,
.panel-header p,
.summary-card span,
.meta,
.subtle {
  color: var(--muted);
}

.route-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  min-width: 0;
}

.route-tab {
  min-height: 42px;
  padding: 8px 10px;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}

.control-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(4, minmax(120px, 150px));
  gap: 10px;
  min-width: 0;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
}

.actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  min-width: 0;
}

.actions button {
  min-height: 40px;
  padding: 8px 10px;
  font-weight: 700;
  white-space: normal;
}

/* ============================================================
   PODSUMOWANIE
   ============================================================ */

.summary-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(145px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.summary-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.summary-card span {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

/* ============================================================
   UKLAD ROBOCZY
   ============================================================ */

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 0.92fr) minmax(520px, 1.08fr);
  gap: 14px;
  align-items: start;
}

.client-panel,
.plan-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-header h2 {
  font-size: 18px;
  line-height: 1.2;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.legend-item,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
}

.legend-item.key,
.tag.key {
  background: var(--warning-soft);
  color: var(--warning);
}

.legend-item.missing,
.tag.missing {
  background: var(--danger-soft);
  color: var(--danger);
}

.legend-item.taxi,
.tag.taxi {
  background: var(--taxi-soft);
  color: var(--taxi);
}

.tag.route {
  background: #eef2f6;
  color: #425165;
}

.tag.driver {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============================================================
   LISTA KLIENTOW
   ============================================================ */

.client-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: calc(100vh - 285px);
  min-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.client-button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 74px;
  padding: 10px;
  text-align: left;
  background: #ffffff;
}

.client-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.client-check {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  color: transparent;
  font-weight: 900;
}

.client-button[aria-pressed="true"] .client-check {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.client-content {
  min-width: 0;
}

.client-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: baseline;
  min-width: 0;
}

.client-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.client-code {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.client-address,
.client-note {
  margin-top: 4px;
  color: #314154;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.client-note {
  color: var(--muted);
}

.client-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel-soft);
}

/* ============================================================
   PLAN
   ============================================================ */

.plan-grid {
  display: grid;
  gap: 12px;
}

.driver-plan {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #ffffff;
}

.driver-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #eef2f6;
  border-bottom: 1px solid var(--line);
}

.driver-header h3 {
  min-width: 0;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.map-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--taxi);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.map-link:hover {
  background: var(--taxi-soft);
}

.plan-table {
  width: 100%;
  overflow-x: auto;
}

.plan-row {
  display: grid;
  grid-template-columns: 66px 66px minmax(165px, 1fr) minmax(190px, 1.15fr) 62px;
  gap: 8px;
  align-items: start;
  min-width: 620px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.plan-row:last-child {
  border-bottom: 0;
}

.plan-row.header {
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.plan-row > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.plan-time {
  font-weight: 800;
}

.plan-client strong {
  display: block;
  line-height: 1.25;
}

.plan-client span,
.plan-address span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.plan-footer {
  padding: 10px 12px;
  color: var(--muted);
  background: var(--panel-soft);
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.notice {
  padding: 10px 12px;
  color: var(--danger);
  background: var(--danger-soft);
  border-top: 1px solid #f0b8ad;
  font-size: 13px;
  font-weight: 700;
}

/* ============================================================
   DRUK I RESPONSYWNOSC
   ============================================================ */

@media (max-width: 1180px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .client-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .client-panel,
  .plan-panel {
    padding: 12px;
  }

  .control-grid,
  .actions,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .driver-header {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .legend {
    justify-content: flex-start;
  }

  .map-link {
    width: 100%;
    justify-content: center;
    white-space: normal;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .topbar,
  .client-panel,
  .summary-strip {
    display: none;
  }

  .workspace {
    display: block;
  }

  .plan-panel {
    border: 0;
    box-shadow: none;
  }

  .plan-row {
    break-inside: avoid;
  }
}
