/* ============================================================
   FunPark Web — design system
   Paleta: teal głęboki + bursztyn + ciemne tło sidebar
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* --- tokeny ------------------------------------------------ */
:root {
  --teal-900: #00352b;
  --teal-800: #00473d;
  --teal-700: #00574a;
  --teal-600: #00695c;
  --teal-500: #00796b;
  --teal-400: #26a69a;
  --teal-200: #b2dfdb;
  --teal-50:  #e0f2f1;

  --amber:    #ffb300;
  --amber-d:  #e65100;

  --bg:       #f4f6f5;
  --surface:  #ffffff;
  --border:   #dde4e2;
  --text:     #1a2421;
  --text-2:   #4a5955;
  --text-3:   #8a9d99;

  --sidebar-w: 220px;
  --radius:    8px;
  --shadow:    0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --font:      'Inter', system-ui, sans-serif;
  --mono:      'JetBrains Mono', monospace;

  --status-run:    #43a047;
  --status-stop:   #e53935;
  --status-maint:  #f59e0b;
  --status-other:  #78909c;
}

/* --- reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; }
img { display: block; max-width: 100%; }

/* --- layout ------------------------------------------------ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--teal-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--teal-800);
}
.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--amber);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .01em;
}
.sidebar-logo .logo-sub {
  font-size: .68rem;
  color: var(--teal-400);
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.nav-section {
  padding: 12px 14px 4px;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--teal-400);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: rgba(255,255,255,.72);
  font-size: .87rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  cursor: pointer;
}
.nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}
.nav-link.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--amber);
}
.nav-link .nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--teal-800);
  font-size: .78rem;
  color: rgba(255,255,255,.55);
}
.sidebar-footer .user-name {
  font-weight: 600;
  color: rgba(255,255,255,.9);
  font-size: .82rem;
}
.sidebar-footer .user-priv {
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--amber);
}
.btn-logout {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.7);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: .78rem;
  cursor: pointer;
  transition: background .15s;
  width: 100%;
  justify-content: center;
}
.btn-logout:hover { background: rgba(255,255,255,.14); color: #fff; }
.btn-help {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.7);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: .78rem;
  cursor: pointer;
  transition: background .15s;
  width: 100%;
  justify-content: center;
}
.btn-help:hover { background: rgba(255,255,255,.14); color: #fff; }
.btn-help.fcm-active { background: rgba(67,160,71,.25); border-color: rgba(67,160,71,.5); color: #a5d6a7; }
.btn-help.fcm-active:hover { background: rgba(67,160,71,.35); }

/* main content */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky; top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
  font-size: 1.3rem;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* --- karty ------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-title .icon { color: var(--teal-500); font-size: 1rem; }
.card-body { padding: 20px; }

/* --- stat tiles ------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-tile::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--teal-500);
}
.stat-tile.amber::before { background: var(--amber); }
.stat-tile.green::before { background: var(--status-run); }
.stat-tile.red::before   { background: var(--status-stop); }

.stat-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--mono);
  line-height: 1.15;
}
.stat-sub {
  font-size: .72rem;
  color: var(--text-3);
  margin-top: 3px;
}

/* --- tabela ------------------------------------------------ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
thead th {
  background: var(--teal-50);
  color: var(--teal-700);
  font-weight: 600;
  font-size: .73rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--teal-200);
  cursor: pointer;
  user-select: none;
}
thead th.center, td.center { text-align: center; }
thead th:hover { background: var(--teal-200); }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--teal-50); }
td { padding: 9px 12px; color: var(--text); vertical-align: middle; }
td .mono { font-family: var(--mono); font-size: .82rem; }

/* --- badge statusu ---------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.badge-run   { background: #e8f5e9; color: #2e7d32; }
.badge-stop  { background: #ffebee; color: #c62828; }
.badge-maint { background: #fff8e1; color: #e65100; }
.badge-other { background: #eceff1; color: #546e7a; }

/* occupancy bar */
.occ-bar { display: flex; align-items: center; gap: 8px; }
.occ-track {
  flex: 1; height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  min-width: 50px;
}
.occ-fill {
  height: 100%;
  background: var(--teal-500);
  border-radius: 3px;
  transition: width .4s ease;
}
.occ-zero-badge { display:inline-block; background:#FCEBEB; color:#A32D2D; border:0.5px solid #F09595; border-radius:20px; padding:3px 12px; font-size:.78rem; font-weight:600; white-space:nowrap; }
.occ-fill.high  { background: var(--status-run); }
.occ-fill.mid   { background: var(--amber); }
.occ-fill.low   { background: var(--teal-400); }
.occ-pct { font-family: var(--mono); font-size: .76rem; color: var(--text-2); min-width: 34px; }

/* --- formularze ------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.field input, .field select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: .84rem;
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus {
  border-color: var(--teal-500);
  background: #fff;
}

/* --- guziki ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--teal-500);
  color: #fff;
}
.btn-primary:hover { background: var(--teal-600); }
.btn-amber {
  background: var(--amber);
  color: #1a1a00;
}
.btn-amber:hover { background: #ffa000; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn-danger {
  background: #c62828;
  color: #fff;
}
.btn-danger:hover { background: #b71c1c; }
.btn-sm { padding: 4px 10px; font-size: .77rem; }

/* --- paginacja -------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.page-btn:hover { background: var(--teal-50); border-color: var(--teal-400); }
.page-btn.active {
  background: var(--teal-500);
  color: #fff;
  border-color: var(--teal-500);
}
.page-btn:disabled { opacity: .4; pointer-events: none; }
.page-info { font-size: .78rem; color: var(--text-3); margin-left: 4px; }

/* --- modal ------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-weight: 600; font-size: .94rem; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; color: var(--text-3);
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: .78rem; font-weight: 600; color: var(--text-2); }
.form-row input, .form-row select {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .86rem;
  outline: none;
  transition: border-color .15s;
}
.form-row input:focus, .form-row select:focus { border-color: var(--teal-500); }
.form-row .hint { font-size: .72rem; color: var(--text-3); }
.form-check { display: flex; align-items: center; gap: 8px; font-size: .86rem; }
.form-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--teal-500); }

/* --- toast ------------------------------------------------- */
#toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--teal-800);
  color: #fff;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  z-index: 500;
  transition: opacity .3s;
  pointer-events: none;
  opacity: 0;
}
#toast.show { opacity: 1; }
#toast.error { background: #c62828; }

/* --- spinner ----------------------------------------------- */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--teal-500);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row td {
  text-align: center;
  padding: 32px;
  color: var(--text-3);
}

/* --- attraction status strip ------------------------------ */
.att-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.att-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px 6px 8px;
  font-size: .79rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.att-chip:hover { box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.chip-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse-dot 2.4s ease-in-out infinite;
}
.chip-dot.run   { background: var(--status-run); }
.chip-dot.stop  { background: var(--status-stop); animation: none; }
.chip-dot.maint { background: var(--status-maint); }
.chip-dot.other { background: var(--status-other); animation: none; }
@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 0 0 rgba(67,160,71,.5); }
  50%      { box-shadow: 0 0 0 5px rgba(67,160,71,0); }
}

/* --- tabs -------------------------------------------------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 8px 18px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--teal-600); }
.tab.active { color: var(--teal-600); border-bottom-color: var(--teal-500); }

/* --- sekcja summary --------------------------------------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
  background: var(--teal-50);
  border-radius: var(--radius);
  border: 1px solid var(--teal-200);
  margin-top: 16px;
}
.summary-item { display: flex; flex-direction: column; gap: 2px; }
.summary-item .s-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--teal-700); }
.summary-item .s-val { font-size: 1.1rem; font-weight: 700; font-family: var(--mono); color: var(--text); }

/* === RESPONSIVE =========================================== */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-220px);
    width: 220px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  .sidebar-overlay.show { display: block; }

  .main { margin-left: 0; }
  .hamburger { display: block; }
  .topbar { padding: 10px 16px; }
  .page-content { padding: 14px; }

  .filter-bar { padding: 12px; }
  .filter-bar .field { width: 100%; }
  .filter-bar input, .filter-bar select { width: 100%; }

  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.3rem; }

  table { font-size: .78rem; }
  td, th { padding: 7px 9px; }

  .att-strip { gap: 7px; }
  .att-chip { font-size: .74rem; padding: 5px 10px 5px 6px; }
}

@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* --- foto-nagłówek sidebar --- */
.sidebar-photo {
  position: relative;
  height: 120px;
  overflow: hidden;
}
.sidebar-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  display: block;
}
.sidebar-photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,53,43,.35) 0%,
    rgba(0,53,43,.75) 100%
  );
}
.sidebar-photo-text {
  position: absolute;
  bottom: 12px;
  left: 14px;
  right: 14px;
}
.sidebar-photo-text .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.sidebar-photo-text .logo-icon {
  width: 32px; height: 32px;
  background: var(--amber);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.sidebar-photo-text .logo-text {
  font-size: .82rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.sidebar-photo-text .logo-sub {
  font-size: .67rem;
  color: rgba(255,255,255,.8);
  font-weight: 400;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* usuń stary padding logo gdy jest zdjęcie */
.sidebar-logo { padding: 0; }

@media (max-width: 768px) {
  .sidebar-photo { height: 100px; }
}

/* --- przełącznik języka --- */
.lang-switcher {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.lang-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.18);
  background: transparent;
  color: rgba(255,255,255,.6);
  font-size: .76rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.lang-btn:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.lang-btn.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  border-color: var(--amber);
}
.lang-btn .lang-flag { font-size: .95rem; line-height: 1; }

/* przełącznik na ekranie logowania */
.lang-switcher-login {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.lang-switcher-login .lang-btn {
  border: 1.5px solid var(--border, #ddd);
  background: var(--bg, #f5f5f5);
  color: var(--text-2, #444);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: .82rem;
  font-weight: 500;
}
.lang-switcher-login .lang-btn:hover {
  background: var(--teal-50, #e0f2f1);
  border-color: var(--teal-500, #00897b);
  color: var(--teal-800, #00695c);
}
.lang-switcher-login .lang-btn.active {
  background: var(--teal-600, #00897b);
  border-color: var(--teal-600, #00897b);
  color: #fff;
  font-weight: 600;
}

/* --- menedżer kolumn --- */
.col-mgr-btn { margin-left: auto; }

.col-mgr-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  max-height: 340px;
  overflow-y: auto;
}
.col-mgr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: default;
  transition: background .1s, box-shadow .1s;
  user-select: none;
}
.col-mgr-item.dragging {
  opacity: .45;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.col-mgr-item.drag-over {
  border-color: var(--teal-500);
  background: var(--teal-50);
}
.col-mgr-handle {
  cursor: grab;
  color: var(--text-3);
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
  padding: 2px;
}
.col-mgr-handle:active { cursor: grabbing; }
.col-mgr-label {
  flex: 1;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
}
.col-mgr-eye {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background .12s;
  line-height: 1;
  flex-shrink: 0;
}
.col-mgr-eye:hover { background: var(--border); }
.col-mgr-eye.hidden-col { opacity: .45; }
