/* shared.css
   ==========
   Wspolne dla index.html (aplikacja klienta) i admin.html (panel administratora):
   zmienne motywu, reset bazowy, ekran logowania, przyciski, pola formularzy,
   naglowek aplikacji, powiadomienia "toast". Kazda zmiana tutaj wplywa na OBIE
   aplikacje - to celowe, to sa wspoldzielone elementy interfejsu.
*/

  :root {
    --bg: #12161B;
    --surface: #1B2128;
    --surface-2: #232A32;
    --border: #2E363F;
    --text: #EDEFF2;
    --text-dim: #8B94A0;
    --accent-amber: #F5A623;
    --accent-brand: #6B9E68;
    --accent-green: #34D399;
    --accent-red: #F2545B;
    --accent-blue: #4FA3D1;
    --radius: 14px;
  }

  /* Motyw jasny - wlaczany przez atrybut data-theme="light" na znaczniku html, patrz
     JS: applyTheme()/toggleTheme(). Kolory statusow (zielony/czerwony/
     amber/niebieski) sa celowo lekko przyciemnione wzgledem wersji
     ciemnej, zeby zachowac czytelny kontrast na jasnym tle. */
  html[data-theme="light"] {
    --bg: #F4F5F7;
    --surface: #FFFFFF;
    --surface-2: #EEF0F3;
    --border: #DCE0E5;
    --text: #1A1D21;
    --text-dim: #66707A;
    --accent-amber: #B8710F;
    --accent-brand: #4C7A49;
    --accent-green: #0E9A6C;
    --accent-red: #D93A42;
    --accent-blue: #2A7DAE;
  }

  * { box-sizing: border-box; }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

  /* --- Ekran logowania --- */
  #login-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
  }

  .theme-toggle-floating {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
  }

  .login-card { width: 100%; max-width: 380px; }

  .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; }
  .brand-mark { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .brand-mark img { width: 100%; height: 100%; object-fit: contain; }
  .brand-text { line-height: 1.2; }
  .brand-text .title { font-weight: 700; font-size: 17px; }
  .brand-text .subtitle { font-size: 12.5px; color: var(--text-dim); letter-spacing: 0.02em; }

  .field { margin-bottom: 16px; }
  .field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
  .field input, .field select {
    width: 100%;
    padding: 13px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
  }
  .field input:focus, .field select:focus { border-color: var(--accent-brand); }
  .form-buttons { display: flex; gap: 8px; margin-top: 14px; }

  .btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent-brand);
    color: #14181D;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    margin-top: 6px;
  }
  .btn-primary:active { opacity: 0.8; }
  .btn-primary:disabled { opacity: 0.5; cursor: default; }

  .error-msg { color: var(--accent-red); font-size: 13.5px; margin-top: 12px; display: none; }

  /* --- Ekran glowny --- */
  #app-screen { display: none; min-height: 100vh; min-height: 100dvh; }

  header.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 14px 18px;
    padding-top: max(14px, env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  header.topbar .brand { margin-bottom: 0; }
  header.topbar .brand-mark { width: 34px; height: 34px; }
  header.topbar .brand-text .title { font-size: 14.5px; }

  .icon-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 36px;
    height: 36px;
    border-radius: 9px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
  }
  .icon-btn:active { background: var(--surface-2); }

  .version-badge {
    position: relative;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 10.5px;
    font-family: 'IBM Plex Mono', monospace;
    padding: 3px 8px;
    border-radius: 20px;
    cursor: pointer;
    margin-left: 4px;
    align-self: center;
  }
  .version-badge:hover { background: var(--surface-2); color: var(--text); }

  .btn-secondary-small {
    font-size: 11.5px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); cursor: pointer;
  }
  .btn-secondary-small:hover { border-color: var(--accent-brand); }
  .btn-secondary-small.active-mode {
    background: var(--accent-brand); color: #fff; border-color: var(--accent-brand);
  }
  .toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 13px;
    display: none;
    z-index: 500;
    max-width: 90vw;
    text-align: center;
  }
  .toast.show { display: block; }
  .toast.error { border-color: rgba(242, 84, 91, 0.5); color: var(--accent-red); }


  /* --- Dodatkowe generyczne przyciski/elementy (przeniesione z admin.html) --- */
  .btn-secondary {
    padding: 10px 16px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
  }

  .btn-danger {
    padding: 8px 12px;
    background: rgba(242, 84, 91, 0.12);
    color: var(--accent-red);
    border: 1px solid rgba(242, 84, 91, 0.35);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
  }

  .badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(107, 158, 104, 0.18);
    color: var(--accent-brand);
  }
  .badge.on { background: rgba(52, 211, 153, 0.15); color: var(--accent-green); }
  .badge.off { background: var(--surface-2); color: var(--text-dim); }

  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th {
    text-align: left;
    font-size: 10.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 8px 8px;
    border-bottom: 1px solid var(--border);
  }
  td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
  tr:last-child td { border-bottom: none; }

  .checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
  }
  .checkbox-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12.5px;
    cursor: pointer;
  }
  .checkbox-chip input { margin: 0; }
