/* topbar.css — top bar layout (náhrada za sidebar), strom kategórií,
   podlišta s akciami, dátová tabuľka tiketov a popup s detailom tiketu.
   Doplnok k style.css (ten zostáva pre karty/formuláre/tlačidlá v
   nastaveniach a ostatných stránkach). */

:root {
    --tb-brand: #1565c0;
    --tb-topbar-h: 84px;
    --tb-subtoolbar-h: 52px;
    --tb-tree-w: 240px;
}

.tb-topbar, .tb-nav a, .tb-nav-dropdown-toggle, .tb-user-menu-toggle, .tb-select,
.tb-table { font-family: var(--font-sans); }

html, body { height: 100%; }
body.is-embed { background: #fff; }

/* ---------------------------------------------------------------
   Top bar
--------------------------------------------------------------- */
.tb-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--tb-topbar-h);
    background: var(--tb-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.tb-topbar-left { display: flex; align-items: center; gap: 28px; min-width: 0; }

.tb-brand {
    display: flex; align-items: center; gap: 12px;
    font-weight: 700; font-size: 1.6rem; color: #fff;
    text-decoration: none; white-space: nowrap;
    letter-spacing: -0.01em;
    opacity: 1;
    transition: opacity var(--transition-fast, 0.12s ease);
}
.tb-brand:hover { opacity: 0.88; }
.tb-brand img { height: 60px; width: auto; display: block; }
.tb-brand svg { width: 48px; height: 48px; }

.tb-nav { display: flex; align-items: center; gap: 4px; }

.tb-nav a, .tb-nav-dropdown-toggle {
    position: relative;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.92rem;
    letter-spacing: 0.01em;
    color: rgba(255,255,255,0.8);
    white-space: nowrap;
    text-decoration: none;
    border: none;
    background: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.12s ease, color 0.12s ease;
}
.tb-nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.tb-nav a.active {
    background: rgba(255,255,255,0.16);
    color: #fff;
    font-weight: 600;
}
.tb-nav a.active::after {
    content: '';
    position: absolute;
    left: 16px; right: 16px; bottom: 3px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
}

.tb-topbar-right { display: flex; align-items: center; gap: 6px; position: relative; }

.tb-icon-btn {
    width: 36px; height: 36px;
    border: none; background: transparent; color: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.12s ease;
}
.tb-icon-btn:hover { background: rgba(255,255,255,0.15); }

/* ---------------------------------------------------------------
   Zvonček notifikácií
--------------------------------------------------------------- */
.tb-notif { position: relative; }
.tb-notif-toggle {
    position: relative;
    width: 38px; height: 38px;
    border: none; background: none; color: #fff; cursor: pointer;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s ease;
}
.tb-notif-toggle:hover { background: rgba(255,255,255,0.12); }
.tb-notif-badge {
    position: absolute; top: 3px; right: 2px;
    min-width: 17px; height: 17px; padding: 0 4px;
    background: #ef4444; color: #fff;
    font-size: 10px; font-weight: 700; line-height: 17px;
    border-radius: 999px; text-align: center;
    box-shadow: 0 0 0 2px var(--tb-brand);
}
.tb-notif-dropdown {
    position: absolute; top: 100%; right: 0;
    width: 340px; max-width: calc(100vw - 32px);
    background: #fff; color: #1a2233;
    border: 1px solid rgba(15,23,42,0.06);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15,23,42,0.18);
    margin-top: 10px; z-index: 60;
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
    overflow: hidden;
}
.tb-notif.open .tb-notif-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.tb-notif-head {
    padding: 12px 16px; font-size: 0.8rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; color: #94a3b8;
    border-bottom: 1px solid #eef1f6;
}
.tb-notif-empty { padding: 24px 16px; text-align: center; color: #94a3b8; font-size: 0.88rem; }
.tb-notif-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 16px; text-decoration: none; color: #1a2233;
    border-bottom: 1px solid #f4f6f9;
    max-height: 320px;
}
.tb-notif-item:last-child { border-bottom: none; }
.tb-notif-item:hover { background: #f4f6f9; }
.tb-notif-item.is-unread { background: #eff6ff; }
.tb-notif-item.is-unread:hover { background: #e3f0fc; }
.tb-notif-ico { font-size: 16px; line-height: 1.3; flex-shrink: 0; }
.tb-notif-body { display: flex; flex-direction: column; min-width: 0; }
.tb-notif-msg { font-size: 0.86rem; line-height: 1.4; color: #1a2233; }
.tb-notif-time { font-size: 0.74rem; color: #94a3b8; margin-top: 2px; }
.tb-notif-dropdown { max-height: 420px; overflow-y: auto; }

.tb-user-menu { position: relative; }
.tb-user-menu-toggle {
    display: flex; align-items: center; gap: 9px;
    padding: 6px 12px 6px 6px; border-radius: 24px;
    border: none; background: none; color: #fff; cursor: pointer;
    font-family: inherit; font-size: 0.88rem; font-weight: 500;
    transition: background 0.12s ease;
}
.tb-user-menu-toggle:hover { background: rgba(255,255,255,0.12); }
.tb-user-menu-toggle .chevron { width: 12px; height: 12px; opacity: 0.85; }

.tb-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: #fff;
    color: var(--tb-brand);
    font-weight: 700; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.35);
    flex-shrink: 0;
}

.tb-user-menu-dropdown {
    position: absolute; top: 100%; right: 0;
    background: #fff; color: #1a2233;
    border: 1px solid rgba(15,23,42,0.06);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15,23,42,0.16);
    padding: 8px; min-width: 200px; margin-top: 10px; z-index: 50;
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
}
.tb-user-menu.open .tb-user-menu-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.tb-user-menu-role { padding: 8px 12px 6px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: #94a3b8; font-weight: 700; }
.tb-user-menu-dropdown a {
    display: block; padding: 9px 12px; border-radius: 8px;
    color: #1a2233; font-size: 0.88rem; font-weight: 500; text-decoration: none;
    transition: background 0.1s ease;
}
.tb-user-menu-dropdown a:hover { background: #f4f6f9; }

/* ---------------------------------------------------------------
   Obsah
--------------------------------------------------------------- */
.tb-content {
    margin-top: var(--tb-topbar-h);
    padding: var(--space-3) var(--space-4);
    min-height: calc(100vh - var(--tb-topbar-h));
}
.tb-embed-content { padding: var(--space-2); }
.tb-footer { text-align: center; color: #94a3b8; font-size: 0.8rem; padding: var(--space-2) 0 var(--space-4); }

/* ---------------------------------------------------------------
   Strom kategórií + podlišta + tabuľka tiketov (na zoznamoch tiketov)
--------------------------------------------------------------- */
.tb-tickets-layout { display: flex; gap: 0; margin: calc(var(--space-3) * -1) calc(var(--space-4) * -1); min-height: calc(100vh - var(--tb-topbar-h)); }

.tb-tree {
    width: var(--tb-tree-w);
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--border-subtle);
    transition: width var(--transition);
    overflow: hidden;
}
.tb-tree.collapsed { width: 0; border-right: none; }
.tb-tree-inner { width: var(--tb-tree-w); padding: 16px 10px; }

.tb-tree-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 8px 12px;
    font-weight: 700; font-size: 0.78rem; text-transform: uppercase;
    color: var(--text-faint); letter-spacing: 0.04em;
}
.tb-tree-header-actions { display: flex; gap: 4px; }
.tb-tree-header-actions button, .tb-tree-header-actions a {
    border: none; background: none; color: var(--text-faint);
    width: 22px; height: 22px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; cursor: pointer; font-size: 1rem;
}
.tb-tree-header-actions button:hover, .tb-tree-header-actions a:hover { background: var(--bg); color: var(--text); }

.tb-tree ul { list-style: none; margin: 0; padding: 0; }
.tb-tree-item {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 8px; border-radius: 6px;
    font-size: 0.88rem; color: var(--text);
    cursor: pointer; user-select: none; text-decoration: none;
}
.tb-tree-item:hover { background: var(--bg); }
.tb-tree-item.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.tb-tree-count { margin-left: auto; color: var(--text-faint); font-size: 0.78rem; }

.tb-main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.tb-subtoolbar {
    min-height: var(--tb-subtoolbar-h);
    background: #fafbfc;
    border-bottom: 1px solid var(--border-subtle);
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-1) var(--space-2); gap: var(--space-1); flex-wrap: wrap;
}
.tb-subtoolbar-left, .tb-subtoolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-subtoolbar-left form { display: flex; align-items: center; gap: 8px; margin: 0; }

.tb-select {
    width: auto;
    min-height: 36px;
    padding: 7px 32px 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    background-color: #fff;
    font-size: 0.85rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.tb-select:hover { border-color: var(--text-faint); }
.tb-select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}

.tb-select-compact { width: 88px; flex-shrink: 0; }

/* Hromadné akcie nad vybranými tiketmi — viacero malých dropdownov vedľa
   seba (stav/priorita/priradenie/štítok) namiesto jedného veľkého
   rolovacieho selectu so všetkým pomiešaným. Každý dropdown nezávislý,
   dá sa nastaviť viacero naraz a aplikovať jedným klikom. */
.tb-bulk-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin: 0;
}
.tb-bulk-action-bar .tb-select { width: auto; min-width: 130px; }

.tb-pagination { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-muted); }
.tb-pagination a, .tb-pagination span.tb-page-btn {
    width: 28px; height: 28px; border-radius: 6px;
    border: 1px solid var(--border); background: #fff; color: var(--text);
    display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.tb-pagination .tb-page-disabled { opacity: 0.4; pointer-events: none; }
.tb-pagination a:hover { background: var(--bg); }

.tb-table-area { flex: 1; padding: 16px; overflow-x: auto; }

.tb-bulkbar {
    display: none; align-items: center; gap: var(--space-1); flex-wrap: wrap;
    background: var(--brand-light); border: 1px solid #bcdcfb;
    border-radius: var(--radius); padding: var(--space-1) var(--space-2); margin-bottom: var(--space-1); font-size: 0.85rem;
}
.tb-bulkbar.visible { display: flex; }

table.tb-table {
    width: 100%; border-collapse: collapse;
    background: #fff; border: 1px solid var(--border-subtle); border-radius: var(--radius-card);
    box-shadow: var(--shadow-card); overflow: hidden;
}
.tb-table th, .tb-table td {
    padding: 14px var(--space-2); text-align: left; border-bottom: 1px solid var(--border-subtle);
    font-size: 0.88rem; line-height: 1.4; white-space: nowrap;
}
.tb-table th {
    background: #fafbfc; color: var(--text-muted); font-weight: 600;
    padding-top: 12px; padding-bottom: 12px;
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-subtle);
}
.tb-table th a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 4px; }
.tb-table tbody tr { background: #fff; cursor: pointer; transition: background var(--transition-fast); }
.tb-table tbody tr:hover { background: var(--brand-light); }
.tb-table tbody tr:last-child td { border-bottom: none; }
.tb-table tbody tr.tb-row-overdue { background: var(--danger-bg); box-shadow: inset 3px 0 0 var(--danger); }
.tb-table tbody tr.tb-row-overdue:hover { background: #fde4e4; }

.tb-subject-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--text); }

.tb-status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px 4px 8px; border-radius: 999px;
    font-weight: 600; font-size: 0.78rem; white-space: nowrap;
}
.tb-status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tb-status-new { background: #eff6ff; color: #1d4ed8; }
.tb-status-new .tb-status-dot { background: #2563eb; }
.tb-status-open { background: #fff7ed; color: #c2570c; }
.tb-status-open .tb-status-dot { background: #f59e0b; }
.tb-status-waiting_customer { background: #e0f2fe; color: #0369a1; }
.tb-status-waiting_customer .tb-status-dot { background: #0ea5e9; }
.tb-status-resolved { background: #ecfdf3; color: #15803d; }
.tb-status-resolved .tb-status-dot { background: #16a34a; }
.tb-status-closed { background: #f1f5f9; color: #475569; }
.tb-status-closed .tb-status-dot { background: #6b7280; }

.tb-priority {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px 4px 8px; border-radius: 999px;
    font-size: 0.78rem; font-weight: 600; white-space: nowrap;
}
.tb-priority-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tb-priority-low { background: #f1f5f9; color: #64748b; }
.tb-priority-low .tb-priority-dot { background: #94a3b8; }
.tb-priority-medium { background: #fef3e2; color: #d97706; }
.tb-priority-medium .tb-priority-dot { background: #f59e0b; }
.tb-priority-high { background: #ffeede; color: #ea580c; }
.tb-priority-high .tb-priority-dot { background: #ea580c; }
.tb-priority-critical { background: #fee2e2; color: #dc2626; }
.tb-priority-critical .tb-priority-dot { background: #dc2626; }

.tb-type-icon { color: var(--text-faint); display: inline-flex; vertical-align: middle; }

.tb-table .tag-pill { font-size: 0.7rem; padding: 2px 8px; font-weight: 600; }

.tb-empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
    font-size: 0.92rem;
}
.tb-empty-state::before {
    content: '';
    display: block;
    width: 40px; height: 40px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='7' width='18' height='13' rx='2'%3E%3C/rect%3E%3Cpath d='M3 7l2.5-4h13L21 7'%3E%3C/path%3E%3Cline x1='3' y1='12' x2='21' y2='12'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

/* ---------------------------------------------------------------
   Popup s detailom tiketu (iframe)
--------------------------------------------------------------- */
.tb-modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 200;
    align-items: center; justify-content: center;
    padding: 24px;
}
.tb-modal-overlay.open { display: flex; }

.tb-modal {
    position: relative;
    background: #fff;
    border-radius: var(--radius-card);
    width: 1320px; height: 880px;
    max-width: calc(100vw - 48px); max-height: calc(100vh - 48px);
    min-width: 420px; min-height: 320px;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.tb-modal.maximized { width: calc(100vw - 32px) !important; height: calc(100vh - 32px) !important; }
.tb-modal.resizing { user-select: none; }
.tb-modal.resizing iframe { pointer-events: none; }

.tb-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tb-modal-title { font-weight: 700; font-size: 0.95rem; }
.tb-modal-header-actions { display: flex; align-items: center; gap: 4px; }
.tb-modal-header-actions .tb-icon-btn { color: var(--text-muted); }
.tb-modal-header-actions .tb-icon-btn:hover { background: var(--bg); }

.tb-modal-body { flex: 1; min-height: 0; }
.tb-modal-body iframe { width: 100%; height: 100%; border: none; display: block; }

.tb-modal-resize-handle {
    position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
    cursor: nwse-resize; z-index: 5; color: var(--text-faint);
    display: flex; align-items: flex-end; justify-content: flex-end; padding: 2px;
}
.tb-modal-resize-handle:hover { color: var(--text-muted); }
.tb-modal.maximized .tb-modal-resize-handle { display: none; }

/* ---------------------------------------------------------------
   Settings hub — bočný panel s nastaveniami (samostatná stránka,
   nie rolovacie menu v top bare)
--------------------------------------------------------------- */
.tb-settings-layout { display: flex; gap: var(--space-4); align-items: flex-start; }

.tb-settings-nav {
    width: 220px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: var(--space-1);
    position: sticky;
    top: 80px;
}

.tb-settings-nav-title {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
}
.tb-settings-nav-title:hover { background: var(--bg); }
.tb-settings-nav-title.active { background: var(--brand-light); color: var(--brand-dark); }

.tb-settings-nav-group {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-faint);
    padding: 10px 10px 4px;
}

.tb-settings-nav-item {
    display: block;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
}
.tb-settings-nav-item:hover { background: var(--bg); }
.tb-settings-nav-item.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }

.tb-settings-content { flex: 1; min-width: 0; }

@media (max-width: 880px) {
    .tb-settings-layout { flex-direction: column; }
    .tb-settings-nav { width: 100%; position: static; }
}

/* ---------------------------------------------------------------
   Responzivita
--------------------------------------------------------------- */
@media (max-width: 980px) {
    .tb-nav { display: none; }
    .tb-tree {
        position: fixed; top: var(--tb-topbar-h); left: 0; bottom: 0; z-index: 90;
        transform: translateX(-100%); width: var(--tb-tree-w);
    }
    .tb-tree.mobile-open { transform: translateX(0); box-shadow: 2px 0 8px rgba(0,0,0,0.15); }
    .tb-tree.collapsed { width: var(--tb-tree-w); }

    .tb-table thead { display: none; }
    .tb-table, .tb-table tbody, .tb-table tr, .tb-table td { display: block; width: 100%; }
    .tb-table tr { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; padding: 4px 0; }
    .tb-table td { border: none; white-space: normal; padding: 5px 14px; }
    .tb-table td[data-label]::before {
        content: attr(data-label); display: block; font-size: 0.68rem; font-weight: 700;
        text-transform: uppercase; color: var(--text-faint); margin-bottom: 2px;
    }
    .tb-table td.tb-cell-checkbox::before { content: none; }
}
