/* ============================================================
   main.css — Kontrola Wyposażenia, SEAYOU / alldayholiday.pl
   ============================================================ */

/* ---- Design tokens ---- */
:root {
  --navy:     #16203a;
  --navy-2:   #243456;
  --gold:     #c2a25a;
  --gold-d:   #a8862f;
  --gold-l:   #d8bf86;
  --gold-soft:#e7d6a6;
  --gold-bg:  #faf5e7;
  --ink:      #23262d;
  --ink-soft: #5a6172;
  --ink-mute: #9298a4;
  --line:     #ece7dc;
  --line-2:   #f3efe6;
  --ok:       #2f8a5b;
  --ok-bg:    #e7f3ec;
  --miss:     #c2503f;
  --miss-bg:  #fbece9;
  --warn:     #b6803a;
  --warn-bg:  #fbf2e0;
  --bg:       #f0ede6;
  --panel:    #ffffff;
  --urgent:   #c2503f;
  --high:     #b6803a;
  --normal:   #2f8a5b;
  --low:      #9298a4;
  --shadow:   0 0 60px -20px rgba(0,0,0,.18);
}

/* dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:    #1a1f2e;
    --panel: #242b3d;
    --ink:   #e8eaf0;
    --ink-soft:#a0a8bb;
    --ink-mute:#6a7490;
    --line:  #2e3652;
    --line-2:#283049;
    --gold-bg:#2a2415;
    --ok-bg: #1a2e24;
    --miss-bg:#2e1a18;
    --warn-bg:#2e2012;
  }
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: var(--gold-d); }

/* ---- Utility ---- */
.hidden  { display: none !important; }
.mt-16   { margin-top: 16px; }
.flex    { display: flex; }
.gap-8   { gap: 8px; }
.flex-1  { flex: 1; }
.text-mute { color: var(--ink-mute); }

/* ---- Buttons ---- */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--gold); color: #fff;
  border: none; border-radius: 12px;
  padding: 13px 20px; font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 16px -6px rgba(168,134,47,.5);
  transition: background .15s, transform .1s;
}
.btn-primary:hover  { background: var(--gold-d); }
.btn-primary:active { transform: scale(.98); }
.btn-primary.ok     { background: var(--ok); box-shadow: 0 6px 16px -6px rgba(47,138,91,.5); }
.btn-primary.danger { background: var(--miss); box-shadow: 0 6px 16px -6px rgba(194,80,63,.4); }
.btn-full { width: 100%; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 9px;
  font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--line); color: var(--ink-soft);
  transition: all .14s;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-d); }
.btn-ghost.danger:hover { border-color: var(--miss); color: var(--miss); }

.btn-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line); color: var(--ink-mute);
  transition: all .14s; flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--gold); color: var(--gold-d); }
.btn-icon.danger:hover { border-color: var(--miss); color: var(--miss); }

/* ---- Inputs ---- */
.field-label { display: block; font-size: 11px; font-weight: 600; color: var(--ink-mute); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.field-input {
  width: 100%; padding: 11px 14px; border-radius: 11px;
  border: 1.5px solid var(--line); background: var(--bg);
  color: var(--ink); font-size: 14px; outline: none;
  transition: border-color .15s;
}
.field-input:focus { border-color: var(--gold); background: var(--panel); }
.field-input::placeholder { color: var(--ink-mute); }

.input-wrap { position: relative; }
.input-wrap .field-input { padding-right: 44px; }
.input-icon-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-mute); padding: 4px; }

/* ---- Alerts ---- */
.alert {
  padding: 11px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 500; margin-bottom: 14px;
}
.alert-error   { background: var(--miss-bg); color: var(--miss); border: 1px solid var(--miss); }
.alert-success { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok); }
.alert-warn    { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }

/* ---- Badge / Priority ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
}
.badge.urgent { background: var(--miss-bg); color: var(--miss); }
.badge.high   { background: var(--warn-bg); color: var(--warn); }
.badge.normal { background: var(--ok-bg);   color: var(--ok);   }
.badge.low    { background: var(--line-2);  color: var(--ink-mute); }
.badge.open        { background: var(--miss-bg); color: var(--miss); }
.badge.in_progress { background: var(--warn-bg); color: var(--warn); }
.badge.done        { background: var(--ok-bg);   color: var(--ok);   }
.badge.closed      { background: var(--line-2);  color: var(--ink-mute); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh;
  background: linear-gradient(155deg, var(--navy) 0%, var(--navy-2) 100%);
}

.login-wrap { width: 100%; max-width: 380px; padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 16px; }

.login-card {
  width: 100%; background: var(--panel);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.login-header {
  background: linear-gradient(155deg, var(--navy) 0%, var(--navy-2) 100%);
  padding: 28px 28px 24px; text-align: center;
}
.login-logo { height: 28px; margin-bottom: 18px; }
.login-header h1 { margin: 0 0 6px; font-size: 20px; font-weight: 700; color: #fff; }
.login-header p  { margin: 0; font-size: 13px; color: rgba(255,255,255,.6); }

.login-body { padding: 24px; }

.login-footer { font-size: 12px; color: rgba(255,255,255,.4); text-align: center; }

/* ============================================================
   APP LAYOUT (cleaner view)
   ============================================================ */
.app-shell {
  max-width: 460px; margin: 0 auto; min-height: 100vh;
  background: var(--panel); display: flex; flex-direction: column;
  box-shadow: var(--shadow); position: relative;
}

/* ---- App Header ---- */
.app-hdr {
  background: linear-gradient(155deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff; padding: 18px 20px 20px;
  position: sticky; top: 0; z-index: 20;
}
.app-hdr-top { display: flex; align-items: center; justify-content: space-between; }
.app-hdr-logo { height: 24px; }
.app-hdr-right { display: flex; align-items: center; gap: 10px; }
.app-hdr-date { font-size: 11.5px; color: rgba(255,255,255,.6); font-weight: 500; }
.logout-btn { color: rgba(255,255,255,.6); padding: 4px; display: flex; align-items: center; }
.logout-btn:hover { color: #fff; }
.app-hdr h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 14px 0 13px; }
.team-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: rgba(255,255,255,.1); border-radius: 20px; font-size: 12px; color: rgba(255,255,255,.8); }

.apt-field {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; padding: 9px 13px; position: relative;
}
.apt-field label { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-l); font-weight: 600; margin-bottom: 2px; }
.apt-input {
  background: none; border: none; color: #fff; font-size: 16px; font-weight: 600; padding: 1px 0; outline: none; width: 100%;
}
.apt-input::placeholder { color: rgba(255,255,255,.4); font-weight: 500; }

.apt-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 50; max-height: 240px; overflow-y: auto;
}
.apt-dropdown-group { padding: 6px 0; }
.apt-dropdown-group-label { padding: 6px 14px 4px; font-size: 10px; font-weight: 700; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .1em; }
.apt-dropdown-item { padding: 9px 14px; font-size: 14px; color: var(--ink); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.apt-dropdown-item:hover { background: var(--gold-bg); color: var(--gold-d); }
.apt-dropdown-item small { color: var(--ink-mute); font-size: 11px; }

/* ---- Progress bar ---- */
.progress-wrap {
  position: sticky; top: 0; z-index: 10; background: var(--panel);
  padding: 14px 20px 12px; border-bottom: 1px solid var(--line);
}
.pbar { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; }
.pbar-fill {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--gold-d), var(--gold));
  transition: width .35s cubic-bezier(.4,0,.2,1);
}
.pstats { display: flex; gap: 14px; margin-top: 9px; font-size: 12px; font-weight: 600; }
.ps { display: flex; align-items: center; gap: 5px; }
.ps::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.ps.done { color: var(--ink-soft); } .ps.done::before { background: var(--gold); }
.ps.miss { color: var(--miss); } .ps.miss::before { background: var(--miss); }
.ps.def  { color: var(--warn); } .ps.def::before  { background: var(--warn); }

/* ---- Search ---- */
.search-box {
  display: flex; align-items: center; gap: 9px; margin-top: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 9px 13px;
  color: var(--ink-mute);
}
.search-box input { flex: 1; background: none; border: none; outline: none; font-size: 14px; color: var(--ink); }
.search-box input::placeholder { color: var(--ink-mute); }
.search-clear { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.search-clear:hover { background: var(--line); }

/* ---- Checklist ---- */
.checklist { flex: 1; padding: 12px 16px 24px; }

.sec { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel); }
.sec-head { width: 100%; display: flex; align-items: center; gap: 13px; padding: 13px 15px; text-align: left; }
.sec-ic { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 11px; background: var(--gold-bg); color: var(--gold-d); display: flex; align-items: center; justify-content: center; }
.sec-tt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sec-tt b { font-size: 15px; font-weight: 600; }
.sec-tt small { font-size: 11.5px; color: var(--ink-mute); }
.sec-chev { color: var(--ink-mute); transition: transform .2s; }
.sec-chev.open { transform: rotate(180deg); }
.sec-body { border-top: 1px solid var(--line-2); }

/* ---- Item row ---- */
.row { padding: 9px 15px; border-bottom: 1px solid var(--line-2); }
.row:last-child { border-bottom: none; }
.row-main { display: flex; align-items: center; gap: 10px; }
.row-label { flex: 1; font-size: 14px; font-weight: 500; line-height: 1.3; }
.row.missing .row-label { color: var(--miss); font-weight: 600; }
.row-pills { display: flex; gap: 6px; }
.pill {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1.5px solid var(--line); display: flex; align-items: center; justify-content: center;
  color: var(--ink-mute); transition: all .14s;
}
.pill.ok.on  { background: var(--ok);   border-color: var(--ok);   color: #fff; }
.pill.miss.on{ background: var(--miss); border-color: var(--miss); color: #fff; }
.pill.warn.on{ background: var(--warn); border-color: var(--warn); color: #fff; }
.pill.ok:not(.on):hover   { border-color: var(--ok);   color: var(--ok);   }
.pill.miss:not(.on):hover { border-color: var(--miss); color: var(--miss); }
.pill.warn:not(.on):hover { border-color: var(--warn); color: var(--warn); }
.note-inp {
  width: 100%; margin-top: 9px; padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--miss); background: var(--miss-bg);
  font-size: 13px; color: var(--ink); outline: none;
}
.note-inp::placeholder { color: #b98079; }
.note-inp.defect { border-color: var(--gold); background: var(--warn-bg); }
.note-inp.defect::placeholder { color: #b09357; }

/* ---- Priority selector ---- */
.priority-bar { display: flex; gap: 6px; margin: 12px 0 4px; }
.pri-btn {
  flex: 1; padding: 8px 4px; border-radius: 9px;
  font-size: 11.5px; font-weight: 700; text-align: center;
  border: 1.5px solid var(--line); color: var(--ink-mute);
  transition: all .13s;
}
.pri-btn.active.urgent { background: var(--miss-bg); border-color: var(--miss); color: var(--miss); }
.pri-btn.active.high   { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.pri-btn.active.normal { background: var(--ok-bg);   border-color: var(--ok);   color: var(--ok);   }
.pri-btn.active.low    { background: var(--line-2);  border-color: var(--ink-mute); color: var(--ink-mute); }

/* ---- Empty state ---- */
.empty-state { text-align: center; color: var(--ink-mute); font-size: 14px; padding: 36px 20px; }
.empty-state svg { margin-bottom: 10px; opacity: .4; }

/* ---- Footer ---- */
.app-foot {
  position: sticky; bottom: 0; z-index: 15;
  padding: 12px 16px 16px;
  background: linear-gradient(0deg, var(--panel) 70%, transparent);
  border-top: 1px solid var(--line);
}

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(175deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform .25s;
}
.sidebar-logo { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo img { height: 22px; }
.sidebar-logo span { display: block; font-size: 10px; color: rgba(255,255,255,.4); margin-top: 6px; letter-spacing: .1em; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; font-size: 14px; font-weight: 500;
  color: rgba(255,255,255,.7); cursor: pointer;
  border-left: 3px solid transparent; transition: all .14s;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: var(--gold-l); border-left-color: var(--gold); background: rgba(194,162,90,.1); }
.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-section { padding: 14px 20px 4px; font-size: 9px; font-weight: 700; color: rgba(255,255,255,.3); letter-spacing: .15em; text-transform: uppercase; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot .logout { display: flex; align-items: center; gap: 8px; font-size: 13px; color: rgba(255,255,255,.5); cursor: pointer; }
.sidebar-foot .logout:hover { color: #fff; }

/* Mobile hamburger */
.hamburger { display: none; position: fixed; top: 14px; left: 14px; z-index: 200; background: var(--navy); color: #fff; border-radius: 10px; padding: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }

/* Main content */
.admin-main { flex: 1; margin-left: 240px; min-height: 100vh; background: var(--bg); }
.admin-topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 16px 24px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.admin-topbar h2 { margin: 0; font-size: 18px; font-weight: 700; }
.admin-topbar .sub { font-size: 12px; color: var(--ink-mute); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.page { padding: 24px; display: none; }
.page.active { display: block; }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 16px;
}
.stat-card .label { font-size: 11px; font-weight: 600; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card .sub   { font-size: 12px; color: var(--ink-mute); margin-top: 4px; }
.stat-card.danger .value { color: var(--miss); }
.stat-card.warn   .value { color: var(--warn); }
.stat-card.ok     .value { color: var(--ok);   }
.stat-card.gold   .value { color: var(--gold-d); }

/* ---- Section cards ---- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; margin-bottom: 20px;
}
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-body { padding: 0; }

/* ---- Tables ---- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 700; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .07em; background: var(--bg); border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 16px; font-size: 13.5px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--gold-bg); }
.tbl .actions { display: flex; gap: 6px; }
.tbl-wrap { overflow-x: auto; }

/* ---- Filters ---- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.filter-bar .field-input { width: auto; flex: 1; min-width: 140px; max-width: 220px; }
.filter-bar select { flex: 1; min-width: 130px; max-width: 180px; }
.filter-bar label { font-size: 11px; font-weight: 600; color: var(--ink-mute); align-self: center; }

/* ---- Charts ---- */
.chart-wrap { padding: 16px 20px; height: 200px; position: relative; }
canvas { max-width: 100%; }

/* ---- Top lists ---- */
.top-list { padding: 0 20px 16px; }
.top-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line-2); gap: 12px; }
.top-row:last-child { border-bottom: none; }
.top-row .name { font-size: 13.5px; font-weight: 500; flex: 1; }
.top-bar-wrap { flex: 0 0 120px; background: var(--bg); border-radius: 4px; overflow: hidden; height: 8px; }
.top-bar { height: 8px; background: var(--gold); border-radius: 4px; }
.top-cnt { font-size: 12px; font-weight: 700; color: var(--ink-mute); flex: 0 0 32px; text-align: right; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--panel); border-radius: 18px;
  padding: 24px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card p  { margin: 0 0 18px; color: var(--ink-soft); font-size: 14px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { color: var(--ink-mute); padding: 4px; }
.modal-close:hover { color: var(--miss); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn-primary { flex: 1; }
.modal-actions .btn-ghost   { flex: 1; justify-content: center; }

/* ---- Report detail ---- */
.report-item-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.report-item-row:last-child { border-bottom: none; }
.ri-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.ri-dot.missing { background: var(--miss); }
.ri-dot.defect  { background: var(--warn); }
.ri-dot.missing_defect { background: linear-gradient(135deg, var(--miss) 50%, var(--warn) 50%); }
.ri-body { flex: 1; }
.ri-name { font-size: 14px; font-weight: 500; }
.ri-note { font-size: 12px; color: var(--ink-mute); margin-top: 2px; }

/* ---- Notification toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 20px rgba(0,0,0,.3); z-index: 999;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.ok   { background: var(--ok); }
.toast.error{ background: var(--miss); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: flex; }
  .admin-main { margin-left: 0; padding-top: 56px; }
}
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 14px; }
  .filter-bar .field-input, .filter-bar select { min-width: 100%; max-width: 100%; flex: 1 1 100%; }
}
@media (max-width: 480px) {
  .app-shell { box-shadow: none; }
}
