/* ============================================================
   Admin rozhraní bb-app - společný vzhled (_AdminLayout)
   Stránky přidávají jen vlastní rozvržení; barvy, tlačítka, karty,
   štítky, tabulky, formuláře a dialogy jsou tady.
   ============================================================ */

:root {
    --ld-text: #1f2328;
    --ld-muted: #6b7280;
    --ld-faint: #9ca3af;
    --ld-border: #e5e7eb;
    --ld-bg: #f6f7f9;
    --ld-hover: #f3f4f6;
    --ld-accent: #1976D2;
    --ld-accent-bg: #e8f1fb;
    --ld-success: #1a7f37;
    --ld-success-bg: #e6f4ea;
    --ld-warning: #9a6700;
    --ld-warning-bg: #fff4d6;
    --ld-danger: #c62828;
    --ld-danger-bg: #fdecea;
    --ld-purple: #6a1b9a;
    --ld-purple-bg: #f3e8fb;
    --ld-mono: 'Cascadia Mono', Consolas, 'Courier New', monospace;
}

* {
    box-sizing: border-box;
}

/* místo pro scrollbar vždy rezervované - stránka při přechodu krátká/dlouhá neuskočí */
html {
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    background: var(--ld-bg);
    color: var(--ld-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

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

.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Horní navigace ===== */
.topnav {
    background: white;
    border-bottom: 1px solid var(--ld-border);
}

.topnav-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 20px;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.impersonation-bar {
    background: var(--ld-warning-bg);
    color: var(--ld-warning);
    border-bottom: 1px solid var(--ld-border);
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.brand {
    font-weight: 700;
    font-size: 16px;
    margin-right: 18px;
    white-space: nowrap;
    color: var(--ld-text);
}

.brand img {
    height: 22px;
    width: auto;
    vertical-align: middle;
    margin: -3px 8px 0 0;
}

.brand span {
    color: var(--ld-accent);
    font-weight: 600;
}

.nav-link {
    color: var(--ld-muted);
    font-size: 14px;
    padding: 7px 11px;
    border-radius: 6px;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--ld-hover);
    color: var(--ld-text);
}

.nav-link.active {
    background: var(--ld-accent-bg);
    color: var(--ld-accent);
    font-weight: 600;
}

.nav-spacer {
    flex: 1;
}

/* ===== Nadpis stránky ===== */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.page-head h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ===== Tlačítka a odkazy ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--ld-border);
    background: white;
    color: var(--ld-text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: var(--ld-hover);
    border-color: #d1d5db;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--ld-accent);
    border-color: var(--ld-accent);
    color: white;
}

.btn-primary:hover {
    background: #1565c0;
    border-color: #1565c0;
}

.btn-danger {
    color: var(--ld-danger);
}

.btn-small {
    padding: 4px 10px;
    font-size: 13px;
}

.link {
    color: var(--ld-accent);
    cursor: pointer;
    font-size: 13px;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    white-space: nowrap;
}

.link:hover {
    text-decoration: underline;
}

.icon-btn {
    background: none;
    border: none;
    padding: 2px 6px;
    margin-left: 6px;
    border-radius: 4px;
    color: var(--ld-faint);
    cursor: pointer;
    font-size: 14px;
}

.icon-btn:hover {
    color: var(--ld-accent);
    background: var(--ld-accent-bg);
}

/* ===== Menu (tlačítko s data-menu="id") ===== */
.menu-wrap {
    position: relative;
}

.menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 220px;
    background: white;
    border: 1px solid var(--ld-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 6px;
    z-index: 50;
}

.menu.open {
    display: block;
}

.menu a, .menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ld-text);
    cursor: pointer;
}

.menu a:hover, .menu button:hover {
    background: var(--ld-hover);
}

.menu button.danger {
    color: var(--ld-danger);
}

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

/* ===== Štítky ===== */
.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.pill-success { background: var(--ld-success-bg); color: var(--ld-success); }
.pill-warning { background: var(--ld-warning-bg); color: var(--ld-warning); }
.pill-danger { background: var(--ld-danger-bg); color: var(--ld-danger); }
.pill-accent { background: var(--ld-accent-bg); color: var(--ld-accent); }
.pill-purple { background: var(--ld-purple-bg); color: var(--ld-purple); }
.pill-neutral { background: var(--ld-hover); color: var(--ld-muted); }

a.pill-accent:hover {
    background: #d4e6f8;
}

.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #d1d5db;
}

.dot.online {
    background: #2e9e4f;
}

/* ===== Karty ===== */
.card {
    background: white;
    border: 1px solid var(--ld-border);
    border-radius: 10px;
    padding: 18px 20px;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.card-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.card-meta {
    color: var(--ld-muted);
    font-size: 13px;
}

.empty {
    color: var(--ld-faint);
    font-size: 14px;
    padding: 8px 0;
}

/* ===== Řádky údajů (popisek vlevo, hodnota vpravo) ===== */
.kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 9px 0;
    border-top: 1px solid var(--ld-border);
    font-size: 14px;
}

.kv:first-child {
    border-top: none;
    padding-top: 0;
}

.kv-label {
    color: var(--ld-muted);
    white-space: nowrap;
}

.kv-value {
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
}

.mono {
    font-family: var(--ld-mono);
}

.sub {
    display: block;
    color: var(--ld-muted);
    font-size: 12px;
    margin-top: 2px;
}

/* ===== Tabulky ===== */
.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.tbl th {
    text-align: left;
    font-weight: 500;
    color: var(--ld-muted);
    font-size: 12px;
    padding: 0 8px 8px 0;
    border-bottom: 1px solid var(--ld-border);
}

.tbl td {
    padding: 10px 8px 10px 0;
    border-bottom: 1px solid var(--ld-border);
    vertical-align: top;
}

.tbl tr:last-child td {
    border-bottom: none;
}

.row-actions {
    text-align: right;
    white-space: nowrap;
}

/* ===== Přepínače (segmented) ===== */
.seg {
    display: inline-flex;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}

.seg button {
    background: white;
    border: none;
    border-left: 1px solid #d1d5db;
    padding: 7px 13px;
    font-size: 13px;
    font-family: inherit;
    color: var(--ld-text);
    cursor: pointer;
    white-space: nowrap;
}

.seg button:first-child {
    border-left: none;
}

.seg button:hover {
    background: var(--ld-hover);
}

.seg button.on {
    background: var(--ld-accent-bg);
    color: var(--ld-accent);
    font-weight: 600;
}

.seg button:disabled {
    color: var(--ld-faint);
    cursor: not-allowed;
    background: white;
}

/* ===== Formuláře ===== */
.form-group {
    margin-bottom: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ld-muted);
}

.form-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: var(--ld-accent);
    box-shadow: 0 0 0 3px var(--ld-accent-bg);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--ld-accent);
    vertical-align: middle;
    cursor: pointer;
}

input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

/* ===== Dialogy (.dlg zobrazit: style.display = 'flex' nebo třída active) ===== */
.dlg {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 60px 16px;
    overflow-y: auto;
}

.dlg.active {
    display: flex;
}

.dlg-box {
    background: white;
    border-radius: 12px;
    padding: 22px 24px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.dlg-box.wide {
    max-width: 680px;
}

.dlg-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.dlg-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.dlg-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--ld-muted);
}

.dlg-foot {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

.dlg-note {
    color: var(--ld-muted);
    font-size: 13px;
    margin-top: 8px;
}

/* ===== Hlášky, načítání ===== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: none;
    font-size: 14px;
}

.alert-error {
    background: var(--ld-danger-bg);
    color: var(--ld-danger);
}

.alert-success {
    background: var(--ld-success-bg);
    color: var(--ld-success);
}

.state-box {
    text-align: center;
    padding: 50px 20px;
    color: var(--ld-muted);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--ld-border);
    border-top: 3px solid var(--ld-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
