/* =========================
   THEME (DARK default)
   ========================= */

:root{
  --bg:#0f172a;
  --panel:#111827;
  --panel-2:#0b1220;
  --card:rgba(255,255,255,0.03);
  --text:#e5e7eb;
  --muted:#9ca3af;
  --accent:#22c55e;
  --accent-2:#3b82f6;
  --danger:#ef4444;
  --border:rgba(255,255,255,0.10);
  --radius:14px;
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --focus:0 0 0 3px rgba(59,130,246,.35);
  color-scheme: dark;

  /* ===== SIDEBAR HOVER SETTINGS ===== */
  --sidebar-w: 260px;
  --sidebar-peek: 14px; /* ile ma wystawać do najechania */
}

html[data-theme="light"]{
  --bg:#f5f7fb;
  --panel:#ffffff;
  --panel-2:#f3f4f6;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#475569;
  --accent:#16a34a;
  --accent-2:#2563eb;
  --danger:#dc2626;
  --border:rgba(15,23,42,0.10);
  --shadow:0 10px 22px rgba(2,6,23,.10);
  --focus:0 0 0 3px rgba(37,99,235,.25);
  color-scheme: light;
}

/* =========================
   BASE
   ========================= */

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height:1.45;
  color:var(--text);
  background:var(--bg);
}

html:not([data-theme="light"]) body{
  background:
    radial-gradient(1200px 800px at 10% -10%, #1f2937 0%, transparent 60%),
    radial-gradient(1000px 900px at 110% 10%, #111827 0%, transparent 55%),
    var(--bg);
}
html[data-theme="light"] body{
  background:
    radial-gradient(1200px 800px at 10% -10%, rgba(37,99,235,0.10) 0%, transparent 60%),
    radial-gradient(1000px 900px at 110% 10%, rgba(22,163,74,0.10) 0%, transparent 55%),
    var(--bg);
}

a{ color:inherit; text-decoration:none; }
a:hover{ text-decoration:underline; }

.small{ color:var(--muted); font-size:13px; }
hr{ border:0; border-top:1px solid var(--border); margin:16px 0; }

/* =========================
   LAYOUT
   ========================= */

/* content zawsze pełna szerokość */
.container{
  max-width: 100%;
  margin: 0;
}

/* app: jedna kolumna (sidebar jest overlay i nie wpływa na układ) */
.app{
  min-height:100vh;
  display:grid;
  grid-template-columns: 1fr;
}

/* sidebar jako overlay: schowany, wysuwa się na hover */
.sidebar{
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border-right:1px solid var(--border);
  padding:16px;

  position: fixed;
  left: 0;
  top: 0;
  height:100vh;
  width: var(--sidebar-w);
  overflow:auto;
  z-index: 999;

  transform: translateX(calc(-1 * (var(--sidebar-w) - var(--sidebar-peek))));
  transition: transform .22s ease;
}

/* wysunięcie */
.sidebar:hover{
  transform: translateX(0);
}

/* (opcjonalne) łatwiejsze “trafienie” w krawędź */
.sidebar::after{
  content:"";
  position:absolute;
  top:0;
  right:-10px;
  width:10px;
  height:100%;
  background: transparent;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:12px;
  background:rgba(255,255,255,0.03);
  box-shadow: var(--shadow);
}
.brand .logo{
  width:36px;height:36px;border-radius:10px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 10px 18px rgba(0,0,0,.25);
}
.brand .title{
  display:flex; flex-direction:column;
}
.brand .title strong{ font-size:14px; }
.brand .title span{ font-size:12px; color:var(--muted); }

.nav{
  margin-top:14px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.nav a{
  padding:10px 10px;
  border-radius:12px;
  border:1px solid transparent;
  color:var(--text);
  display:flex;
  align-items:center;
  justify-content:space-between;
  background:transparent;
}
.nav a:hover{
  background:rgba(255,255,255,0.04);
  border-color:var(--border);
  text-decoration:none;
}
.nav a.active{
  background:rgba(59,130,246,0.12);
  border-color:rgba(59,130,246,0.25);
}

.main{
  padding:18px 18px 26px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  box-shadow: var(--shadow);
  margin-bottom:14px;
}

/* =========================
   CARDS
   ========================= */

.card{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  box-shadow: var(--shadow);
  padding:14px;
  margin: 12px 0;
}
html[data-theme="light"] .card{
  background: var(--card);
}

.card h2{
  margin:0 0 10px 0;
  font-size:18px;
}
.card h3{
  margin:10px 0 8px 0;
  font-size:15px;
  color:var(--muted);
  font-weight:600;
}

/* =========================
   BADGES
   ========================= */

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:3px 8px;
  border:1px solid var(--border);
  border-radius:999px;
  font-size:12px;
  color:var(--muted);
  background: rgba(255,255,255,0.03);
}

/* =========================
   BUTTONS
   ========================= */

.btn, button{
  appearance:none;
  border:1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 12px;
  cursor:pointer;
  font-weight:600;
  font-size: 13px;
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}
button:hover, .btn:hover{
  background: rgba(255,255,255,0.07);
  text-decoration:none;
}
button:active, .btn:active{ transform: translateY(1px); }

.btn.secondary{
  background: rgba(59,130,246,0.16);
  border-color: rgba(59,130,246,0.30);
}
.btn.secondary:hover{
  background: rgba(59,130,246,0.22);
}

.btn.ghost{
  background: transparent;
}
.btn.ghost:hover{
  background: rgba(255,255,255,0.06);
}

.btn.danger{
  background: rgba(239,68,68,0.14);
  border-color: rgba(239,68,68,0.30);
}
.btn.danger:hover{
  background: rgba(239,68,68,0.22);
}

.form-actions{
  display:flex;
  gap:8px;
  margin-top:10px;
  flex-wrap:wrap;
}

/* =========================
   FORMS
   ========================= */

input, select, textarea{
  width:100%;
  border:1px solid var(--border);
  border-radius: 12px;
  padding: 10px 11px;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  outline:none;
  font-size: 14px;
}
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea{
  background: #fff;
}

textarea{ min-height: 120px; resize: vertical; }

input:focus, select:focus, textarea:focus{
  box-shadow: var(--focus);
  border-color: rgba(59,130,246,0.35);
}

.form-row{
  display:flex;
  gap:10px;
}
.form-row > *{ flex:1; }

label{ color: var(--muted); font-size: 13px; }

/* =========================
   TABLES
   ========================= */

table{
  width:100%;
  border-collapse: collapse;
  overflow:hidden;
  border-radius: 14px;
  border:1px solid var(--border);
}

th, td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  text-align:left;
  vertical-align:top;
  font-size: 13px;
}

th{
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-weight:700;
}

tr:hover td{
  background: rgba(255,255,255,0.03);
}

table .btn{ padding:7px 10px; border-radius:10px; }

/* =========================
   MODAL
   ========================= */

.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.78);
  display:none;
  align-items:center;
  justify-content:center;
  z-index: 50;
  padding: 18px;
}

.modal-backdrop.is-open{
  display:flex;
}

.modal{
  width:100%;
  max-width: 620px;
  max-height: 90vh;
  overflow:auto;
  border-radius: 16px;
  border:1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}
html[data-theme="light"] .modal{
  background: #fff;
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 10px;
}
.modal-header h2{
  margin:0;
  font-size: 17px;
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 980px){
  /* mobile: sidebar wraca do normalnego układu */
  .app{ grid-template-columns: 1fr; }

  .sidebar{
    position: relative;
    transform: none;
    width: 100%;
    height:auto;
    border-right:none;
    border-bottom:1px solid var(--border);
    z-index: auto;
  }

  .main{ padding:14px; }
  .form-row{ flex-direction:column; }
}

.doc-tooltip {
  position: relative;
  cursor: help;
  font-size: 18px;
}

.doc-tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  white-space: pre-line;
  font-size: 13px;
  min-width: 200px;
  max-width: 320px;
  z-index: 50;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  transition: opacity .15s ease;
}

.doc-tooltip:hover .doc-tooltip-text {
  visibility: visible;
  opacity: 1;
}

.docs-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.docs-header h2{
  margin:0;
}

.docs-filters{
  margin-top:14px;
}

.docs-filters select[name="company_id"] { 
  min-width: 320px; 
}

.docs-filters select[name="employee_id"] { 
  min-width: 320px; 
}

.emp-filters{
  margin-top:14px;
}

.filters-row{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
}

.filters-row select,
.filters-row input{
  height:44px;
  padding:10px 12px;
  border-radius:12px;
  width: 220px;
  max-width: 100%;
}

.filters-row input[name="y"]{
  width: 120px;
}
.is-expired {
  color: var(--danger);
  font-weight: 700;
}

.is-expired small {
  color: var(--danger);
}
.period-btn{
  height:44px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-radius:12px;
  width: 220px;
  max-width: 100%;
}

.period-arrow{
  opacity:.7;
  font-weight:700;
}

/* popover */
.period-popover{
  position: fixed;
  inset: 0;
  display:none;
  align-items:flex-start;
  justify-content:center;
  padding: 90px 18px 18px;
  background: rgba(15,23,42,0.35);
  z-index: 60;
}
.period-popover.is-open{ display:flex; }

.period-card{
  width: 520px;
  max-width: 100%;
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.period-top{
  display:flex;
  justify-content:flex-end;
}
.period-close{
  width:40px;
  height:40px;
  border-radius: 12px;
}

.period-quick{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  margin-top:8px;
}

.period-controls{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  margin-top:14px;
}

.period-actions{
  display:flex;
  justify-content:flex-end;
  margin-top:14px;
}
.period-date-range{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  margin-top:12px;
}

.period-date-col label{
  display:block;
  margin-bottom:6px;
}

.period-date-input{
  height:44px;
  border-radius:12px;
  padding:10px 12px;
}

@media (max-width: 560px){
  .period-date-range{ grid-template-columns: 1fr; }
}
.period-date-range input[type="month"]{
  height:44px;
  border-radius:12px;
}
.period-arrow{
  font-size: 20px;          /* było małe — to jest OK wizualnie */
  line-height: 1;
  font-weight: 800;
  padding: 0 6px;           /* większy obszar kliku */
  cursor: pointer;
  user-select: none;
  opacity: .8;
}

.period-arrow:hover{
  opacity: 1;
  transform: scale(1.15);   /* delikatny efekt */
}
/* =========================
   LOGIN – centrowanie okna
   ========================= */
.login-main{
  min-height: 100vh;
  display: flex;
  justify-content: center; /* poziom */
}

.login-main .container{
  margin: 0;
}
.login-main{
  background:
    radial-gradient(600px 400px at 50% -10%, rgba(59,130,246,.18), transparent 60%),
    radial-gradient(600px 400px at 50% 110%, rgba(34,197,94,.18), transparent 60%);
}
.chat-shell{
  display:grid;
  grid-template-columns: 320px 1fr;
  gap:12px;
}

@media (max-width: 900px){
  .chat-shell{ grid-template-columns: 1fr; }
}

.chat-list{ padding:12px; }
.chat-list-top{ display:flex; flex-direction:column; gap:8px; margin-bottom:10px; }
.chat-title{ font-weight:700; font-size:16px; }
.chat-search{
  width:100%;
  padding:10px 12px;
  border:1px solid #e5e7eb;
  border-radius:10px;
}

.chat-items{ display:flex; flex-direction:column; gap:6px; max-height:65vh; overflow:auto; padding-right:2px; }

.chat-item{
  width:100%;
  text-align:left;
  border:1px solid #e5e7eb;
  background:#fff;
  border-radius:12px;
  padding:10px;
  cursor:pointer;
  position:relative;
}
.chat-item.active{ outline:2px solid rgba(59,130,246,.25); border-color:#c7d2fe; }
.chat-item-top{ display:flex; justify-content:space-between; gap:10px; }
.chat-item-name{ font-weight:700; }
.chat-item-snippet{ margin-top:4px; opacity:.85; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-badge{
  position:absolute;
  right:10px;
  bottom:10px;
  min-width:18px;
  height:18px;
  padding:0 6px;
  border-radius:999px;
  background:#2563eb;
  color:#fff;
  font-size:12px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.chat-main{ padding:12px; display:flex; flex-direction:column; min-height:70vh; }
.chat-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  padding-bottom:10px;
  border-bottom:1px solid #e5e7eb;
}
.chat-head-title{ font-weight:800; font-size:16px; }
.chat-messages{
  flex:1;
  overflow:auto;
  padding:12px 6px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.chat-row{ display:flex; }
.chat-row.me{ justify-content:flex-end; }
.chat-row.them{ justify-content:flex-start; }

.chat-bubble{
  max-width: 72%;
  border-radius:16px;
  padding:10px 12px;
  border:1px solid #e5e7eb;
  background:#f9fafb;
}
.chat-row.me .chat-bubble{
  background:#e0f2fe;
  border-color:#bae6fd;
}
.chat-meta{ opacity:.7; margin-bottom:4px; }
.chat-body{ white-space:pre-wrap; word-break:break-word; }

.chat-input{
  display:flex;
  gap:8px;
  padding-top:10px;
  border-top:1px solid #e5e7eb;
}
.chat-text{
  flex:1;
  padding:10px 12px;
  border:1px solid #e5e7eb;
  border-radius:12px;
}
.chat-shell{display:grid;grid-template-columns:320px 1fr;gap:12px;}
@media (max-width:900px){.chat-shell{grid-template-columns:1fr;}}

.chat-list{padding:12px;}
.chat-list-top{display:flex;flex-direction:column;gap:8px;margin-bottom:10px;}
.chat-title{font-weight:700;font-size:16px;}
.chat-search{width:100%;padding:10px 12px;border:1px solid #e5e7eb;border-radius:10px;}

.chat-items{display:flex;flex-direction:column;gap:6px;max-height:65vh;overflow:auto;padding-right:2px;}

.chat-item{width:100%;text-align:left;border:1px solid #e5e7eb;background:#fff;border-radius:12px;padding:10px;cursor:pointer;position:relative;}
.chat-item.active{outline:2px solid rgba(59,130,246,.25);border-color:#c7d2fe;}
.chat-item-top{display:flex;justify-content:space-between;gap:10px;}
.chat-item-name{font-weight:700;}
.chat-item-snippet{margin-top:4px;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}

.chat-badge{position:absolute;right:10px;bottom:10px;min-width:18px;height:18px;padding:0 6px;border-radius:999px;background:#2563eb;color:#fff;font-size:12px;display:flex;align-items:center;justify-content:center;}

.chat-main{padding:12px;display:flex;flex-direction:column;min-height:70vh;}
.chat-head{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;padding-bottom:10px;border-bottom:1px solid #e5e7eb;}
.chat-head-title{font-weight:800;font-size:16px;}

.chat-messages{flex:1;overflow:auto;padding:12px 6px;display:flex;flex-direction:column;gap:10px;}
.chat-row{display:flex;}
.chat-row.me{justify-content:flex-end;}
.chat-row.them{justify-content:flex-start;}

.chat-bubble{max-width:72%;border-radius:16px;padding:10px 12px;border:1px solid #e5e7eb;background:#f9fafb;}
.chat-row.me .chat-bubble{background:#e0f2fe;border-color:#bae6fd;}
.chat-meta{opacity:.7;margin-bottom:4px;}
.chat-body{white-space:pre-wrap;word-break:break-word;}

.chat-input{display:flex;gap:8px;padding-top:10px;border-top:1px solid #e5e7eb;}
.chat-text{flex:1;padding:10px 12px;border:1px solid #e5e7eb;border-radius:12px;}
