/* ============================================================
   Allocate PPM – globální design systém
   Tmavý režim je výchozí; světlý přes [data-theme="light"]
   ============================================================ */

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { max-width: 100%; }

/* ── Design tokeny – tmavý režim (výchozí) ───────────────── */
:root {
  /* Pozadí */
  --bg:      #0f1117;
  --bg2:     #161822;
  --bg3:     #1e2030;
  --bg4:     #252840;
  --bg5:     #2d3050;

  /* Rámečky */
  --border:  #2a2d45;
  --border2: #363a58;

  /* Text */
  --text1:   #e2e4f0;
  --text2:   #9499b8;
  --text3:   #636882;

  /* Akcent */
  --accent:  #6366f1;
  --accent2: #8b5cf6;
  --accent-hover: #4f52d1;

  /* Sémantické barvy */
  --cyan:    #06b6d4;
  --green:   #22c55e;
  --amber:   #f59e0b;
  --red:     #ef4444;

  /* Stavy projektů */
  --stav-new:   #a78bfa;
  --stav-doing: #fbbf24;
  --stav-ready: #22d3ee;
  --stav-done:  #34d399;

  /* Alokační barevná škála */
  --alloc-0:   #1a1d2e;
  --alloc-10:  #1a3a5c;
  --alloc-30:  #1e5c8e;
  --alloc-60:  #2563eb;
  --alloc-100: #6366f1;

  /* Layout */
  --header-h:   56px;
  --sidebar-w:  220px;
  --radius:     6px;
  --radius-lg:  10px;
  --radius-xl:  14px;

  /* Typografie */
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* Stíny */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
}

/* ── Design tokeny – světlý režim ────────────────────────── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:      #ffffff;
    --bg2:     #f7f8fa;
    --bg3:     #f0f1f5;
    --bg4:     #e4e6ee;
    --bg5:     #d8dae8;
    --border:  #e2e5ef;
    --border2: #c8cce0;
    --text1:   #111827;
    --text2:   #4b5263;
    --text3:   #9499b0;
    --accent-hover: #4f52d1;
    --cyan:    #0891b2;
    --amber:   #d97706;
    --alloc-0: #ebebf0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.15);
  }
}
:root[data-theme="light"] {
  --bg:      #ffffff;
  --bg2:     #f7f8fa;
  --bg3:     #f0f1f5;
  --bg4:     #e4e6ee;
  --bg5:     #d8dae8;
  --border:  #e2e5ef;
  --border2: #c8cce0;
  --text1:   #111827;
  --text2:   #4b5263;
  --text3:   #9499b0;
  --accent-hover: #4f52d1;
  --cyan:    #0891b2;
  --amber:   #d97706;
  --alloc-0: #ebebf0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.15);
}

/* ── Základní typografie ─────────────────────────────────── */
html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text1);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.app-header-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 20px;
}

/* Logo */
.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text1);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  flex-shrink: 0;
  margin-right: 8px;
}
.app-logo:hover { text-decoration: none; opacity: 0.85; }
.app-logo strong { font-weight: 700; }

/* Separator logo | nav */
.app-header-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 4px;
}

/* Hlavní navigace */
.app-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-link:hover, .nav-link:focus-visible {
  background: var(--bg3);
  color: var(--text1);
  text-decoration: none;
}
.nav-link.nav-active {
  color: var(--accent);
  background: rgba(99,102,241,0.1);
}

/* Dropdown navigace */
.nav-dd { position: relative; }

.nav-dd-trigger { /* dědí .nav-link */ }

.nav-dd-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 200;
}
.nav-dd.open .nav-dd-menu { display: block; }

.nav-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text2);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.nav-dd-item:hover {
  background: var(--bg3);
  color: var(--text1);
  text-decoration: none;
}
.nav-dd-item.nav-active { color: var(--accent); }

.nav-dd-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Header – pravá část */
.app-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Ikonové tlačítko (téma, nápověda) */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg4); color: var(--text1); }

/* User menu */
.user-menu-wrap { position: relative; }

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text1);
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
.user-menu-trigger:hover { background: var(--bg4); }

.user-name { font-weight: 500; }

.user-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
}
.user-badge--admin { background: var(--accent); }
.user-badge--all   { background: var(--cyan); }
.user-badge--host  { background: #64748b; }
.user-badge--user  { display: none; }

.user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 200;
}
.user-menu.open { display: block; }

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text2);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.user-menu-item:hover { background: var(--bg3); color: var(--text1); text-decoration: none; }
.user-menu-item--danger { color: #fca5a5; }
.user-menu-item--danger:hover { background: rgba(239,68,68,.1); color: #fca5a5; }

.user-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Tlačítka ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary   { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg3); color: var(--text1); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg4); }
.btn-ghost     { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text1); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

/* ── Formulářové prvky ───────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label, .form-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text1);
  font-size: 0.9rem;
  font-family: var(--font);
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
input::placeholder { color: var(--text3); }

/* ── Karty ───────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}
.card-sm { padding: 14px 18px; }
.card-title { font-size: 0.875rem; font-weight: 600; color: var(--text2); margin-bottom: 12px; }

/* ── Stav-badge ──────────────────────────────────────────── */
.stav-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.stav-new   { background: rgba(167,139,250,0.15); color: var(--stav-new); }
.stav-doing { background: rgba(251,191,36, 0.15); color: var(--stav-doing); }
.stav-ready { background: rgba(34, 211,238,0.15); color: var(--stav-ready); }
.stav-done  { background: rgba(52, 211,153,0.15); color: var(--stav-done); }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text3);
  font-size: 0.875rem;
}

/* ── Prázdný stav ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 60px 20px;
  color: var(--text3);
  font-size: 0.875rem;
  text-align: center;
}
.empty-state svg { opacity: 0.3; margin-bottom: 4px; }

/* ── Utility třídy ───────────────────────────────────────── */
.text-muted  { color: var(--text3); }
.text-accent { color: var(--accent); }
.text-sm     { font-size: 0.8rem; }
.text-xs     { font-size: 0.72rem; }
.font-mono   { font-family: var(--font-mono); }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.mt-1        { margin-top: 4px; }
.mt-2        { margin-top: 8px; }
.mt-4        { margin-top: 16px; }

/* ── Hlavní obsah stránky ────────────────────────────────── */
.page-wrap {
  padding: 28px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text1);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text3);
  margin-top: 4px;
}

/* ── Emp-link / proj-link (klikatelné jméno v tabulkách) ─── */
.emp-link, .proj-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.12s;
}
.emp-link:hover, .proj-link:hover { color: var(--accent); }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Křížek pro zavření dialogu (pravý horní roh) ── */
.modal-x {
    position: absolute; top: 12px; right: 12px;
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; border-radius: 6px; cursor: pointer;
    color: var(--text3); font-size: 1rem; line-height: 1; font-family: var(--font);
    transition: background 0.12s, color 0.12s;
}
.modal-x:hover { background: var(--bg3); color: var(--text1); }

/* Název organizace v záhlaví */
.app-org {
  font-size: 0.78rem;
  color: var(--text3);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  margin-right: 8px;
}

/* ── Správa (admin stránky: osoby, uživatelé, oddělení, projekty) ── */
.adm-page { padding: 24px 24px 60px; }
.adm-title { font-size: 1.4rem; font-weight: 800; color: var(--text1); letter-spacing: -0.02em; margin-bottom: 20px; }
.adm-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.adm-controls .adm-search { width: auto; min-width: 180px; max-width: 280px; padding: 7px 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text1); font-size: 0.85rem; font-family: var(--font); }
.adm-controls .adm-search:focus { outline: none; border-color: var(--accent); }
.adm-count { font-size: 0.8rem; color: var(--text3); }
.adm-btn-add { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 7px 16px; font-size: 0.82rem; font-weight: 600; font-family: var(--font); cursor: pointer; transition: opacity 0.12s; }
.adm-btn-add:hover { opacity: 0.85; }

.adm-table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg2); overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.adm-table thead th {
  position: sticky; top: 0; background: var(--bg3);
  color: var(--text3); font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
}
.adm-table thead th[data-col] { cursor: pointer; user-select: none; }
.adm-table thead th[data-col]:hover { color: var(--text2); }
.adm-table thead th.sort-active { color: var(--text1); }
.adm-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.adm-table tbody tr:last-child { border-bottom: none; }
.adm-table tbody tr:hover { background: rgba(99,102,241,0.04); }
.adm-table td { padding: 9px 12px; color: var(--text2); vertical-align: middle; white-space: nowrap; }
.adm-loading, .adm-table .adm-loading { padding: 40px; text-align: center; color: var(--text3); font-size: 0.9rem; white-space: normal; }
.adm-empty { color: var(--text3); font-style: italic; font-size: 0.75rem; }
.adm-date { font-size: 0.78rem; font-family: 'Consolas','SF Mono',monospace; color: var(--text2); }

/* Akční tlačítka v řádku */
.adm-btn-edit, .adm-btn-del, .adm-btn-restore, .adm-btn-pwd, .adm-btn-color {
  display: inline-flex; align-items: center; gap: 4px; border: none; border-radius: 5px;
  padding: 4px 10px; margin-right: 4px; font-size: 0.72rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background 0.12s;
}
.adm-btn-edit    { background: rgba(99,102,241,0.1);  color: var(--accent); }
.adm-btn-edit:hover    { background: rgba(99,102,241,0.22); }
.adm-btn-del     { background: rgba(248,113,113,0.1); color: #f87171; }
.adm-btn-del:hover     { background: rgba(248,113,113,0.22); }
.adm-btn-warn    { background: rgba(251,191,36,0.1);  color: #fbbf24; }  /* smazat nelze – po kliknutí vysvětlí proč */
.adm-btn-warn:hover    { background: rgba(251,191,36,0.22); }
.adm-btn-restore { background: rgba(74,222,128,0.1);  color: #4ade80; }
.adm-btn-restore:hover { background: rgba(74,222,128,0.22); }
.adm-btn-pwd     { background: rgba(251,191,36,0.1);  color: #fbbf24; }
.adm-btn-pwd:hover     { background: rgba(251,191,36,0.22); }
.adm-btn-color   { background: rgba(6,182,212,0.1);   color: #06b6d4; }
.adm-btn-color:hover   { background: rgba(6,182,212,0.22); }
.adm-row-inactive td { text-decoration: line-through; color: var(--text3) !important; opacity: 0.6; }
.adm-row-inactive td button, .adm-row-inactive td a { text-decoration: none; }

/* Dialog */
.adm-modal-ov { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.adm-modal-ov[hidden] { display: none !important; }
.adm-modal { position: relative; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 28px; width: 440px; max-width: 100%; max-height: 90vh; overflow-y: auto; }
.adm-modal--wide { width: 640px; }
.adm-modal-title { font-size: 1rem; font-weight: 700; color: var(--text1); margin-bottom: 20px; }
.adm-field { margin-bottom: 14px; }
.adm-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
/* stejný vzhled jako globální input[type=text] – i pro select, date, url a textarea */
.adm-input { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text1); font-size: 0.9rem; font-family: var(--font); padding: 9px 12px; outline: none; }
.adm-input option { background: var(--bg3); color: var(--text1); }
textarea.adm-input { resize: vertical; min-height: 72px; }
.adm-hint { font-size: 0.72rem; color: var(--text3); margin-top: 4px; }
.adm-error { font-size: 0.82rem; color: #f87171; margin-top: 14px; min-height: 1.2em; }
.adm-modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.adm-btn-cancel, .adm-btn-save { border-radius: 6px; padding: 7px 16px; font-size: 0.82rem; font-weight: 600; font-family: var(--font); cursor: pointer; transition: opacity 0.12s, background 0.12s; }
.adm-btn-cancel { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.adm-btn-cancel:hover { background: var(--border); }
.adm-btn-save { background: var(--accent); color: #fff; border: none; }
.adm-btn-save:hover { opacity: 0.85; }
.adm-btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* Výběr barvy (osoby, projekty) */
.adm-color-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.adm-color-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--bg3); border: 1px solid var(--border); flex-shrink: 0; }
.adm-color-hex { font-size: 0.78rem; color: var(--text3); font-family: 'Consolas','SF Mono',monospace; flex: 1; }
.adm-color-clear { padding: 3px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 5px; font-size: 0.72rem; color: var(--text2); cursor: pointer; font-family: var(--font); }
.adm-color-clear:hover { background: var(--border); }
.adm-palette { display: grid; grid-template-columns: repeat(16,1fr); gap: 2px; }
.adm-swatch { width: 100%; aspect-ratio: 1; border-radius: 2px; cursor: pointer; border: 2px solid transparent; box-sizing: border-box; transition: transform .1s; }
.adm-swatch:hover { transform: scale(1.25); z-index: 1; position: relative; }
.adm-swatch.sel { border-color: #fff; box-shadow: 0 0 0 1px var(--accent); }
