/* styles.css - wspolny styl aplikacji. Nowoczesny, responsywny, mobile-first. */

:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-soft: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.12);
  --shadow-sm: 0 1px 3px rgba(2, 6, 23, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-alt);
  -webkit-font-smoothing: antialiased;
}

/* ---------- EKRAN LOGOWANIA ---------- */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a8a 0%, var(--bg) 55%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  animation: rise 0.4s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand { text-align: center; margin-bottom: 26px; }

.brand__logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.brand__name { font-size: 22px; font-weight: 700; margin: 0; }
.brand__subtitle { color: var(--text-soft); font-size: 14px; margin: 4px 0 0; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.input-wrap { position: relative; }

input[type="text"],
input[type="password"],
input[type="time"],
select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.toggle-pass {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 6px;
}
.toggle-pass:hover { background: var(--surface-alt); color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s, transform 0.05s;
  font-family: inherit;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.99); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn--ghost { background: var(--surface); color: var(--primary); border: 1.5px solid var(--border); }
.btn--ghost:hover { background: var(--surface-alt); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #b91c1c; }
.btn--sm { width: auto; padding: 8px 12px; font-size: 13px; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; display: none; }
.alert.show { display: block; }
.alert--error { background: var(--danger-soft); color: #991b1b; }
.alert--success { background: var(--success-soft); color: #166534; }
.alert--warning { background: var(--warning-soft); color: #92400e; }

.muted { color: var(--text-soft); font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 16px; }

/* ---------- PANELE ---------- */
.app-body { min-height: 100vh; background: var(--surface-alt); }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.topbar__logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff; display: grid; place-items: center; font-weight: 800;
}

.topbar__user { display: flex; align-items: center; gap: 14px; }
.topbar__user .who { text-align: right; line-height: 1.2; }
.topbar__user .who strong { display: block; font-size: 14px; }
.topbar__user .who span { font-size: 12px; color: var(--text-soft); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge--user { background: var(--primary-soft); color: var(--primary-dark); }
.badge--manager { background: #ede9fe; color: #6d28d9; }
.badge--admin { background: #fce7f3; color: #be185d; }
.badge--active { background: var(--success-soft); color: #166534; }
.badge--blocked { background: var(--danger-soft); color: #991b1b; }

.container { max-width: 1040px; margin: 0 auto; padding: 24px 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card .card__desc { color: var(--text-soft); font-size: 14px; margin: 0 0 18px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.info-item { background: var(--surface-alt); border-radius: var(--radius-sm); padding: 12px 14px; }
.info-item .label { font-size: 12px; color: var(--text-soft); }
.info-item .value { font-size: 15px; font-weight: 600; margin-top: 2px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar .search { flex: 1; min-width: 220px; }
.toolbar .search input { width: 100%; }

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-alt); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-soft); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.55); display: none; place-items: center; padding: 20px; z-index: 50; }
.modal-backdrop.show { display: grid; }
.modal {
  width: 100%; max-width: 460px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px; animation: rise 0.25s ease; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 18px; }

.pass-reveal {
  display: flex; align-items: center; gap: 8px;
  background: var(--warning-soft); border: 1px dashed var(--warning);
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 12px 0;
  font-family: "Consolas", "SF Mono", monospace; font-size: 15px; word-break: break-all;
}

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.5); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen { min-height: 100vh; display: grid; place-items: center; color: var(--text-soft); }
.hint { font-size: 12px; color: var(--text-soft); margin-top: 6px; }

/* ---------- Tydzien / dyspozycyjnosc / grafik ---------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.week-label { font-weight: 700; font-size: 16px; text-align: center; flex: 1; }

.dispo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.dispo-day {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 12px;
  cursor: pointer; text-align: center; user-select: none; transition: all 0.12s; background: var(--surface);
}
.dispo-day:hover { border-color: var(--primary); }
.dispo-day.on { background: var(--success-soft); border-color: var(--success); }
.dispo-day .d-name { font-weight: 600; font-size: 14px; }
.dispo-day .d-date { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.dispo-day .d-state { font-size: 12px; margin-top: 8px; font-weight: 600; }
.dispo-day.on .d-state { color: #166534; }
.dispo-day:not(.on) .d-state { color: var(--text-soft); }

.schedule-day { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.schedule-day h4 { margin: 0 0 8px; font-size: 14px; }
.shift {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; background: var(--surface-alt); border-radius: 8px; margin-bottom: 6px; font-size: 14px;
}
.shift:last-child { margin-bottom: 0; }
.shift .shift-time { font-weight: 700; color: var(--primary-dark); white-space: nowrap; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.tab-btn {
  border: none; background: none; padding: 10px 16px; font-size: 14px; font-weight: 600;
  color: var(--text-soft); cursor: pointer; border-radius: 8px 8px 0 0; border-bottom: 3px solid transparent; font-family: inherit;
}
.tab-btn:hover { color: var(--primary); background: var(--surface-alt); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.dispo-check { color: var(--success); font-weight: 700; }
.dispo-no { color: var(--text-soft); }

@media (max-width: 560px) {
  .auth-card { padding: 28px 22px; }
  .topbar__user .who { display: none; }
  .container { padding: 16px 14px; }
  .card { padding: 18px; }
  .week-label { font-size: 14px; }
}

/* ---------- Grafik: siatka jak w Excelu ---------- */
.sched-grid { min-width: 760px; }
.sched-grid th, .sched-grid td { vertical-align: top; text-align: center; padding: 8px 8px; }
.sched-grid th:first-child, .sched-grid td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.sched-grid th { background: var(--surface-alt); }
.sched-grid tr:hover td { background: #f8fafc; }
.sched-cell {
  position: relative;
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 6px 18px 6px 8px;
  margin-bottom: 6px;
  font-size: 12.5px;
  line-height: 1.35;
  text-align: left;
}
.sched-cell:last-child { margin-bottom: 0; }
.sched-cell .shift-time { color: var(--primary-dark); font-weight: 700; }
.sched-empty { color: var(--text-soft); }
.sched-del {
  position: absolute; top: 3px; right: 5px;
  background: none; border: none; cursor: pointer;
  color: var(--danger); font-size: 12px; line-height: 1; padding: 0;
}
.sched-del:hover { color: #b91c1c; }

/* ---------- Dyspozycyjnosc: tryby godzin ---------- */
.dispo-check-lbl { display:flex; align-items:center; gap:6px; justify-content:center; font-size:12px; font-weight:600; margin-top:8px; cursor:pointer; }
.dispo-check-lbl input { width:auto; }
.dispo-hours { display:flex; gap:6px; margin-top:8px; }
.dispo-hours input[type="time"], .dispo-hours select { padding:6px 8px; font-size:13px; }

/* ---------- Legenda restauracji w grafiku ---------- */
.rest-legend { display:flex; flex-wrap:wrap; gap:12px; margin-bottom:12px; }
.rest-leg { display:inline-flex; align-items:center; gap:6px; font-size:12.5px; color:var(--text-soft); }
.rest-swatch { width:14px; height:14px; border-radius:4px; border:1px solid rgba(0,0,0,0.1); display:inline-block; }

/* ---------- Naglowki grup (restauracje) w tabelach ---------- */
.group-row td {
  background: #eef2f7;
  font-size: 13px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.group-row td strong { font-size: 13px; letter-spacing: 0.02em; }
tr.group-row:hover td { background: #eef2f7; }

/* Zakladki restauracji w liscie uzytkownikow */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border, #d7dee8); background: #fff;
  font-size: 13px; font-weight: 600; color: #334155; line-height: 1;
}
.chip:hover { background: #f1f5f9; }
.chip--on { background: #1e293b; border-color: #1e293b; color: #fff; }
.chip__n { font-weight: 500; opacity: .7; font-size: 12px; }
.chip .rest-swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* Informacja o restauracji kierowcy */
.rest-banner {
  display: block; margin: 0 0 14px; padding: 10px 14px; border-radius: 10px;
  background: #eef6ff; border: 1px solid #cfe3fb; color: #1e3a5f; font-size: 14px;
}
.rest-banner--warn { background: #fff7ed; border-color: #fed7aa; color: #7c2d12; }

/* Karta "Co wymaga uwagi" */
.alert-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: 10px; margin-bottom: 8px;
  font-size: 14px; line-height: 1.45; border: 1px solid transparent;
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item--warn { background: #fff7ed; border-color: #fed7aa; color: #7c2d12; }
.alert-item--ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-item__ico {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: rgba(255,255,255,.75);
}
.alert-item .muted { color: inherit; opacity: .75; }

/* Sekcje w "Co wymaga uwagi" - podzial na restauracje */
.alert-sec { margin-bottom: 16px; }
.alert-sec:last-child { margin-bottom: 0; }
.alert-sec__title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: #475569; margin: 0 0 8px;
  padding-bottom: 6px; border-bottom: 1px solid #e2e8f0;
}
.alert-sec__title .rest-swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* Raport po wygenerowaniu grafiku */
.rep-head { font-weight: 700; margin-bottom: 10px; }
.rep-foot { margin-top: 10px; font-size: 13px; opacity: .85; }
.rep-rest {
  background: rgba(255,255,255,.6); border-radius: 8px;
  padding: 9px 12px; margin: 6px 0; font-size: 13px; line-height: 1.5;
}
.rep-title { font-weight: 700; margin-bottom: 3px; }
.rep-ok::before { content: "\2713 "; }
.rep-warn::before { content: "\2022 "; }
.rep-warn { opacity: .9; }

/* Edytowana zmiana */
.shift--editing {
  background: #fff7ed !important;
  border: 1px solid #fb923c !important;
  box-shadow: 0 0 0 3px rgba(251,146,60,.15);
}

/* ============================================================
   WYGLĄD — warstwa porządkująca (dopracowanie interfejsu)
   ============================================================ */

:root {
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, .07), 0 10px 24px -6px rgba(15, 23, 42, .12);
}

body { font-size: 15px; line-height: 1.55; letter-spacing: -0.006em; }

/* Szersza treść — grafik potrzebuje miejsca */
.container { max-width: 1240px; padding: 28px 24px 60px; }

/* Górny pasek */
.topbar {
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  position: sticky; top: 0; z-index: 30;
}

/* Karty */
.card {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 24px 26px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.card .card__desc { font-size: 13.5px; margin: 0 0 18px; }

/* Zakładki */
.tabs { gap: 4px; margin-bottom: 22px; }
.tab-btn {
  border-radius: 10px; font-weight: 600; font-size: 14px;
  padding: 9px 16px; border: 1px solid transparent; background: transparent;
  color: var(--text-soft); transition: background .15s, color .15s;
}
.tab-btn:hover { background: #eef2f7; color: var(--text); }
.tab-btn.active { background: var(--text); color: #fff; border-color: var(--text); }

/* Formularze */
input[type="text"], input[type="password"], input[type="time"], input[type="file"], select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field label { font-size: 12.5px; letter-spacing: .01em; color: #475569; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }

/* Przyciski */
.btn {
  border-radius: var(--radius-sm); font-weight: 600; font-size: 14.5px;
  box-shadow: var(--shadow-sm); transition: background .15s, box-shadow .15s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn--ghost { border-color: var(--border); box-shadow: none; color: #334155; }
.btn--ghost:hover { background: #f1f5f9; border-color: #cbd5e1; }
.btn--sm { padding: 7px 13px; font-size: 13px; }

/* Tabele */
.table-wrap { border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
th {
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  padding: 11px 14px; background: #f8fafc; color: #64748b;
  position: sticky; top: 0; z-index: 2;
}
td { padding: 11px 14px; font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }

/* Odznaki */
.badge { padding: 3px 11px; font-size: 11.5px; letter-spacing: .01em; }

/* Nawigacja tygodnia */
.week-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.week-label { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }

/* Siatka grafiku */
.sched-grid th, .sched-grid td { text-align: center; }
.sched-grid td:first-child, .sched-grid th:first-child {
  text-align: left; position: sticky; left: 0; background: #fff; z-index: 1;
}
.sched-grid th:first-child { background: #f8fafc; z-index: 3; }
.sched-cell {
  border-radius: 8px; padding: 7px 9px; font-size: 12.5px; line-height: 1.35;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .05);
}

/* Zmiany i listy */
.shift {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--surface-alt); border: 1px solid var(--border);
  margin-bottom: 7px; font-size: 14px;
}
.shift:last-child { margin-bottom: 0; }
.shift-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary-dark); }

/* Dyspozycyjność kierowcy */
.dispo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.dispo-day {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 10px; text-align: center; background: var(--surface);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.dispo-day:hover { border-color: #cbd5e1; }
.dispo-day.on {
  background: var(--primary-soft); border-color: #93c5fd;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .18);
}
.dispo-day .d-name { font-weight: 700; font-size: 13px; }
.dispo-day .d-date { font-size: 12px; color: var(--text-soft); margin-bottom: 8px; }

/* Komunikaty */
.alert { border-radius: var(--radius-sm); font-size: 14px; padding: 12px 15px; }
.hint { font-size: 12.5px; color: var(--text-soft); margin: 6px 0 0; }

/* Nagłówek grupy w tabeli */
.group-row td {
  background: #f1f5f9 !important; padding: 9px 14px;
  border-top: 1px solid var(--border);
}

/* Modale */
.modal { border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 18px; font-size: 18px; }

/* Telefon */
@media (max-width: 640px) {
  .container { padding: 18px 14px 44px; }
  .card { padding: 18px 16px; }
  .form-row { flex-direction: column; align-items: stretch; }
  .form-row .field { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .week-nav { flex-wrap: wrap; }
}

/* Wydruk */
@media print {
  .topbar, .tabs, .btn, .week-nav, .toolbar { display: none !important; }
  .card { box-shadow: none; border: none; padding: 0; }
}
