/* ═══════════════════════════════════════════════
   Firemní portál — globální styly
   ═══════════════════════════════════════════════ */

:root {
  --accent:      #534AB7;
  --accent-dark: #3D3490;
  --success:     #3B6D11;
  --success-bg:  #EAF3DE;
  --warning:     #BA7517;
  --warning-bg:  #FAEEDA;
  --danger:      #E24B4A;
  --danger-bg:   #FCEBEB;
  --info:        #185FA5;
  --info-bg:     #E6F1FB;

  --surface:   #ffffff;
  --surface2:  #F7F5F1;
  --border:    rgba(0,0,0,.09);
  --border2:   rgba(0,0,0,.16);
  --text:      #1A1A1A;
  --text2:     #555555;
  --text3:     #999999;
  --radius:    10px;
  --radius-lg: 14px;
  --sidebar-w: 220px;
  --topbar-h:  56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface2);
  line-height: 1.5;
}

/* ── LOGIN ─────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3D3490 0%, #534AB7 100%);
}
.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon { font-size: 48px; margin-bottom: 8px; }
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p { color: var(--text3); font-size: 13px; margin-top: 4px; }

/* ── LAYOUT ─────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}
.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-logo { font-weight: 700; font-size: 16px; color: var(--accent); }
.topbar-spacer { flex: 1; }
.topbar-user { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 8px; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  overflow-y: auto;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text3);
  padding: 10px 8px 4px;
  margin-top: 6px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  text-decoration: none;
  transition: background .12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-item:hover { background: var(--surface2); }
.sidebar-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar-item .si-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

/* Badge upozornění v sidebar položce */
.si-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-item.active .si-badge {
  background: rgba(255,255,255,.35);
  color: #fff;
}

.main-content {
  padding: 24px;
  overflow-y: auto;
  max-width: 1200px;
}

/* ── FORMS ──────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text2);
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── BUTTONS ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-ghost    { background: var(--surface2); color: var(--text2); border: 1px solid var(--border2); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }
.btn-full     { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── TABLE ──────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text3);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

/* ══════════════════════════════════════════════════
   MOBILNÍ RESPONZIVITA (≤ 768px)
   ══════════════════════════════════════════════════ */

/* ── Hamburger tlačítko — skryté na desktopu ─────── */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--text2);
  flex-shrink: 0;
}
.menu-toggle:hover { background: var(--surface2); }

/* ── Sidebar overlay (backdrop) ─────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}

@media (max-width: 768px) {

  /* ── Layout: sidebar schovaný, jen jeden sloupec ── */
  .app-layout {
    grid-template-columns: 1fr !important;
  }

  /* ── Sidebar: fixovaný drawer zleva ─────────────── */
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: 260px;
    height: calc(100vh - var(--topbar-h));
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* ── Overlay viditelný jen na mobilu ─────────────── */
  .sidebar-overlay {
    display: block;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s;
  }
  .sidebar-overlay.open {
    pointer-events: auto;
    opacity: 1;
  }

  /* ── Hamburger viditelný na mobilu ───────────────── */
  .menu-toggle {
    display: flex;
  }

  /* ── Hlavní obsah: plná šířka, menší padding ─────── */
  .main-content {
    padding: 14px;
    min-width: 0;
  }

  /* ── Formuláře: 1 sloupec ────────────────────────── */
  .form-row {
    grid-template-columns: 1fr !important;
  }

  /* ── Modal: vysouvá se zespodu (sheet) ───────────── */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal-box {
    padding: 20px 16px;
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    max-height: 92vh;
  }

  /* ── Tlačítka: větší touch target ───────────────── */
  .btn-sm {
    padding: 7px 12px;
    font-size: 12px;
  }

  /* ── Toast: celá šířka dole ──────────────────────── */
  #toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }
  .toast {
    max-width: 100%;
    text-align: center;
  }

  /* ── Page header: skládá se vertikálně ──────────── */
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .page-header > .btn,
  .page-header > div > .btn {
    justify-content: center;
  }

  /* ── Stat-row: max 2 sloupce ─────────────────────── */
  .stat-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .stat-cell {
    border-bottom: 1px solid var(--border);
  }

  /* ── Tab bar: menší písmo ────────────────────────── */
  .tab-btn {
    font-size: 11px;
    padding: 5px 10px;
  }

  /* ── Topbar: menší mezery ────────────────────────── */
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .topbar-logo {
    font-size: 14px;
  }
  .topbar-user span#topbar-name {
    display: none;
  }

  /* ── Detail label: zkrátit min-width ─────────────── */
  .detail-label {
    min-width: 100px;
  }

  /* ── Dashboard stat karty: 2 sloupce na mobilu ────── */
  .dash-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-stat-value { font-size: 26px; }
}

/* ── BADGES ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-ok      { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: var(--surface2);   color: var(--text2); border: 1px solid var(--border2); }

/* ID badge */
.id-badge {
  font-family: monospace;
  font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--text2);
  white-space: nowrap;
}

/* ── ALERTS ─────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 10px;
}
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #F09595; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #FAC775; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #A7D070; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid #85B7EB; }

/* ── PAGE HEADER ─────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.page-sub   { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* ── MODAL ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  overflow-y: auto;
}
.modal-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 26px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text3);
  line-height: 1;
}
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ── TOAST ──────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  background: var(--text);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: slide-in .2s ease;
  max-width: 320px;
}
@keyframes slide-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── TABS ──────────────────────────────────────── */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.tab-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  background: var(--surface2);
  color: var(--text2);
  transition: background .12s;
}
.tab-btn.active { background: var(--accent); color: #fff; }
.tab-btn:hover:not(.active) { background: #e9e5fe; }

/* ── DASHBOARD STAT ROW ─────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}
.stat-cell {
  padding: 14px 16px;
  border-right: 1px solid var(--border);
}
.stat-cell:last-child { border-right: none; }
.stat-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); margin-bottom: 3px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-sub   { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── DASHBOARD — nový design ────────────────────── */

/* Kompaktní upozornění nahoře */
.dash-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}
.dash-alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #F09595; }
.dash-alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #FAC775; }

/* Mřížka stat karet */
.dash-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.dash-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  transition: box-shadow .15s;
}
.dash-stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.dash-stat-icon  { font-size: 24px; margin-bottom: 6px; }
.dash-stat-value { font-size: 32px; font-weight: 800; line-height: 1; }
.dash-stat-label { font-size: 13px; font-weight: 600; color: var(--text2); margin-top: 4px; }
.dash-stat-sub   { font-size: 11px; color: var(--text3); }

/* Nadpis sekce s tlačítkem Zobrazit vše */
.dash-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
}
.dash-view-all {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background .12s;
}
.dash-view-all:hover { background: var(--surface2); }

/* ── DASHBOARD — souhrnný řádek Provozní ────────── */
.dash-ops-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 1.5px solid;
}
.dash-ops-summary--alert {
  background: var(--warning-bg);
  border-color: #FAC775;
}
.dash-ops-summary--ok {
  background: var(--success-bg);
  border-color: #A7D070;
}
.dash-ops-icon { font-size: 28px; flex-shrink: 0; }
.dash-ops-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.dash-ops-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.dash-ops-detail {
  font-size: 12px;
  color: var(--text2);
}

/* ── COMING SOON ────────────────────────────────── */
.coming-soon {
  text-align: center;
  padding: 60px 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border2);
}
.coming-soon-icon { font-size: 48px; margin-bottom: 12px; }

/* ── UTILS ──────────────────────────────────────── */
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-success { color: var(--success) !important; }
.fw-bold { font-weight: 700; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.gap-8 { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── DETAIL KARTA NÁŘADÍ ────────────────────────── */
.detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  min-width: 130px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text3);
}
tr:hover { background: var(--surface2); }

/* ══════════════════════════════════════════════════
   NOTIFIKACE — zvoneček + panel
   ══════════════════════════════════════════════════ */

.notif-wrap { position: relative; }

/* Tlačítko zvonečku */
.notif-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--text2);
  line-height: 1;
  transition: background .12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-btn:hover { background: var(--surface2); }

/* Animace zvonění při nové notifikaci */
.notif-btn--ring { animation: notif-ring .45s ease; }
@keyframes notif-ring {
  0%   { transform: rotate(0); }
  15%  { transform: rotate(20deg); }
  35%  { transform: rotate(-18deg); }
  55%  { transform: rotate(12deg); }
  75%  { transform: rotate(-8deg); }
  100% { transform: rotate(0); }
}

/* Červený počítadlo badge na zvonečku */
.notif-count {
  position: absolute;
  top: 1px;
  right: 1px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--surface);
  pointer-events: none;
}

/* Dropdown panel */
.notif-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 340px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.16);
  z-index: 300;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: notif-drop .15s ease;
}
.notif-panel.open { display: flex; }
@keyframes notif-drop {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hlavička panelu */
.notif-panel-header {
  display: flex;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
}
.notif-panel-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
}
.notif-panel-actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--accent);
  font-family: inherit;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
  transition: background .1s;
}
.notif-panel-actions button:hover { background: var(--surface2); }
.notif-panel-actions button.danger { color: var(--danger); }

/* Seznam notifikací */
.notif-list { max-height: 360px; overflow-y: auto; }

/* Prázdný stav */
.notif-empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* Jeden řádek notifikace */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: var(--info-bg); }
.notif-item.unread:hover { background: #cce3f5; }

.notif-item-icon   { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.notif-item-body   { flex: 1; min-width: 0; }
.notif-item-title  { font-size: 13px; font-weight: 600; color: var(--text); }
.notif-item-detail {
  font-size: 11px; color: var(--text2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-item-time   { font-size: 10px; color: var(--text3); flex-shrink: 0; white-space: nowrap; margin-top: 3px; }

/* Mobil — panel na celou šířku */
@media (max-width: 480px) {
  .notif-panel {
    position: fixed;
    top: var(--topbar-h);
    left: 8px;
    right: 8px;
    width: auto;
  }
}
