/* ============================================================
   HelpDesk – Hlavní styly
   Vyžaduje Bootstrap 5 (načítaný z CDN)
   ============================================================ */

/* ── Proměnné ────────────────────────────────────────────────*/
:root {
    --hd-primary:       #0d6efd;
    --hd-primary-dark:  #0a58ca;
    --hd-sidebar-bg:    #1e2a38;
    --hd-sidebar-text:  #c9d3df;
    --hd-sidebar-hover: #2c3e52;
    --hd-sidebar-active:#0d6efd;
    --hd-sidebar-width: 260px;
    --hd-topbar-height: 58px;
    --hd-body-bg:       #f0f2f5;
    --hd-card-shadow:   0 1px 4px rgba(0,0,0,.08);
    --hd-radius:        .5rem;
}

/* ── Reset a base ────────────────────────────────────────────*/
*,
*::before,
*::after { box-sizing: border-box; }

html { height: 100%; }

body {
    min-height: 100%;
    background: var(--hd-body-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .9375rem;
    color: #343a40;
}

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

/* ── Layout wrapper ──────────────────────────────────────────*/
.hd-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────*/
.hd-sidebar {
    width: var(--hd-sidebar-width);
    background: var(--hd-sidebar-bg);
    color: var(--hd-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1030;
    transition: transform .25s ease;
}

.hd-sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hd-sidebar-brand span { color: var(--hd-primary); }

.hd-sidebar-nav {
    flex: 1;
    padding: .5rem 0;
}

.hd-sidebar-nav .nav-section {
    padding: .75rem 1rem .25rem;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.35);
}

.hd-sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem 1.25rem;
    color: var(--hd-sidebar-text);
    border-radius: 0;
    font-size: .875rem;
    transition: background .15s, color .15s;
}
.hd-sidebar-nav .nav-link:hover {
    background: var(--hd-sidebar-hover);
    color: #fff;
    text-decoration: none;
}
.hd-sidebar-nav .nav-link.active {
    background: var(--hd-sidebar-active);
    color: #fff;
}
.hd-sidebar-nav .nav-link i {
    width: 18px;
    text-align: center;
    opacity: .85;
    flex-shrink: 0;
}
.hd-sidebar-nav .badge-pill {
    margin-left: auto;
    font-size: .7rem;
}

.hd-sidebar-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .8rem;
    color: rgba(255,255,255,.4);
}

/* ── Topbar ──────────────────────────────────────────────────*/
.hd-topbar {
    height: var(--hd-topbar-height);
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.hd-topbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .25rem .5rem;
    color: #6c757d;
    font-size: 1.25rem;
}

.hd-topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #343a40;
    flex: 1;
}

.hd-topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.hd-notif-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    color: #6c757d;
    font-size: 1.2rem;
    padding: .25rem;
}
.hd-notif-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: .6rem;
    padding: 2px 4px;
}

/* ── Main content ────────────────────────────────────────────*/
.hd-main {
    margin-left: var(--hd-sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.hd-content {
    flex: 1;
    padding: 1.5rem;
}

/* ── Cards ───────────────────────────────────────────────────*/
.card {
    border: 1px solid rgba(0,0,0,.08);
    border-radius: var(--hd-radius);
    box-shadow: var(--hd-card-shadow);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,.08);
    font-weight: 600;
    padding: .875rem 1.25rem;
}

/* ── Stat cards ──────────────────────────────────────────────*/
.stat-card {
    border-radius: var(--hd-radius);
    padding: 1.25rem 1.5rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--hd-card-shadow);
}
.stat-card .stat-icon {
    font-size: 2rem;
    opacity: .8;
    flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { font-size: .8rem; opacity: .85; }
.stat-card.bg-primary  { background: linear-gradient(135deg, #0d6efd, #3d8bfd); }
.stat-card.bg-warning  { background: linear-gradient(135deg, #ffc107, #ffca2c); color: #343a40 !important; }
.stat-card.bg-success  { background: linear-gradient(135deg, #198754, #25a46e); }
.stat-card.bg-danger   { background: linear-gradient(135deg, #dc3545, #e35d6a); }
.stat-card.bg-info     { background: linear-gradient(135deg, #0dcaf0, #31d2f2); color: #343a40 !important; }

/* ── Tikety – seznam ─────────────────────────────────────────*/
.ticket-row td { vertical-align: middle; }
.ticket-row:hover { background: #f8f9ff; }

.ticket-subject {
    font-weight: 500;
    color: #1a1a2e;
}
.ticket-subject small {
    font-weight: 400;
    color: #6c757d;
}

/* ── Konverzace ──────────────────────────────────────────────*/
.message-bubble {
    max-width: 82%;
    padding: .75rem 1rem;
    border-radius: var(--hd-radius);
    margin-bottom: .75rem;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.message-bubble.from-tech {
    background: #e8f0fe;
    border-left: 3px solid var(--hd-primary);
    margin-right: auto;
}

.message-bubble.from-client {
    background: #fff;
    border: 1px solid #dee2e6;
    border-right: 3px solid #198754;
    margin-left: auto;
}

.message-bubble.internal {
    background: #fff8e7;
    border: 1px dashed #ffc107;
    margin-right: auto;
    opacity: .92;
}

.message-bubble .msg-meta {
    font-size: .75rem;
    color: #6c757d;
    margin-bottom: .3rem;
}

.message-thread {
    max-height: 480px;
    overflow-y: auto;
    padding: 1rem;
    background: #fafbfc;
    border: 1px solid #dee2e6;
    border-radius: var(--hd-radius);
}

/* ── Pracovní list ───────────────────────────────────────────*/
.wo-total-row {
    background: #f0f7ff;
    font-weight: 600;
}
.wo-price-col { text-align: right; white-space: nowrap; }

/* ── Stránkování ─────────────────────────────────────────────*/
.page-item.active .page-link {
    background-color: var(--hd-primary);
    border-color: var(--hd-primary);
}

/* ── Formuláře ───────────────────────────────────────────────*/
.form-label { font-weight: 500; font-size: .875rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--hd-primary);
    box-shadow: 0 0 0 .2rem rgba(13,110,253,.2);
}
.required-star { color: #dc3545; }

/* ── Badges / štítky ─────────────────────────────────────────*/
.badge { font-size: .72rem; font-weight: 600; }

/* ── Tabulky ─────────────────────────────────────────────────*/
.table-sm td, .table-sm th { padding: .45rem .6rem; }
.table-hover tbody tr:hover { background-color: rgba(13,110,253,.04); }

/* ── Login stránka ───────────────────────────────────────────*/
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--hd-sidebar-bg) 0%, #2c3e52 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: .75rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    padding: 2.5rem 2rem;
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-card .login-logo i {
    font-size: 3rem;
    color: var(--hd-primary);
}

.login-card h1 {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: .25rem;
}

.login-card .login-sub {
    text-align: center;
    color: #6c757d;
    font-size: .85rem;
    margin-bottom: 1.75rem;
}

/* ── Attachment preview ──────────────────────────────────────*/
.attach-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: .375rem;
    border: 1px solid #dee2e6;
    cursor: pointer;
    transition: transform .15s;
}
.attach-thumb:hover { transform: scale(1.05); }

.attach-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
    border-radius: .375rem;
    border: 1px solid #dee2e6;
    font-size: 1.75rem;
    color: #6c757d;
}

/* ── Timeline (historie) ─────────────────────────────────────*/
.hd-timeline {
    position: relative;
    padding-left: 1.5rem;
}
.hd-timeline::before {
    content: '';
    position: absolute;
    left: .5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dee2e6;
}
.hd-timeline-item {
    position: relative;
    margin-bottom: .75rem;
    padding-left: 1rem;
}
.hd-timeline-item::before {
    content: '';
    position: absolute;
    left: -.75rem;
    top: .4rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--hd-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--hd-primary);
}
.hd-timeline-meta { font-size: .75rem; color: #6c757d; }

/* ── Grafy – wrapper ─────────────────────────────────────────*/
.chart-container {
    position: relative;
    height: var(--chart-height, 280px);
}
.chart-container-sm { --chart-height: 200px; }

/* ── Kruhový graf – vlastní legenda ──────────────────────────*/
.doughnut-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    margin-top: 10px;
    padding: 0 4px;
}
.doughnut-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .8rem;
    white-space: nowrap;
}
.doughnut-legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    flex-shrink: 0;
}
.doughnut-legend-price {
    font-weight: 600;
    color: #212529;
}
.doughnut-legend-label {
    color: #6c757d;
}

/* ── Klientský layout – jiná barva ───────────────────────────*/
.hd-client .hd-sidebar { background: #12343b; }
.hd-client .hd-sidebar-nav .nav-link.active { background: #17a2b8; }
.hd-client .stat-card.bg-primary { background: linear-gradient(135deg, #17a2b8, #35b6ca); }

/* ── Světlý sidebar ──────────────────────────────────────────*/
.hd-sidebar-light {
    background: #ffffff;
    border-right: 1px solid #dee2e6;
    box-shadow: 2px 0 8px rgba(0,0,0,.06);
}
.hd-sidebar-light .hd-sidebar-brand {
    color: #1e2a38;
    border-bottom-color: #dee2e6;
    background: #f8f9fa;
}
.hd-sidebar-light .hd-sidebar-brand span {
    color: var(--hd-primary);
}
.hd-sidebar-light .hd-sidebar-nav .nav-section {
    color: rgba(0,0,0,.38);
}
.hd-sidebar-light .hd-sidebar-nav .nav-link {
    color: #343a40;
}
.hd-sidebar-light .hd-sidebar-nav .nav-link:hover {
    background: #e9ecef;
    color: #0d6efd;
}
.hd-sidebar-light .hd-sidebar-nav .nav-link.active {
    background: #e7f0ff;
    color: #0d6efd;
    font-weight: 600;
}
.hd-sidebar-light .hd-sidebar-nav .nav-link i {
    opacity: 1;
}
.hd-sidebar-light .hd-sidebar-footer {
    color: #6c757d;
    border-top-color: #dee2e6;
    background: #f8f9fa;
}

/* ── Responsive ──────────────────────────────────────────────*/
@media (max-width: 991.98px) {
    .hd-sidebar {
        transform: translateX(-100%);
    }
    .hd-sidebar.open {
        transform: translateX(0);
    }
    .hd-main {
        margin-left: 0;
    }
    .hd-topbar-toggle {
        display: block;
    }
    .hd-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 1029;
    }
    .hd-sidebar.open + .hd-main .hd-sidebar-overlay,
    .hd-sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .hd-content { padding: 1rem .75rem; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .message-bubble { max-width: 95%; }
}

/* ── Utility ─────────────────────────────────────────────────*/
.cursor-pointer { cursor: pointer; }
.text-muted-sm  { font-size: .8rem; color: #6c757d; }
.border-start-primary { border-left: 3px solid var(--hd-primary) !important; }
.gap-2 { gap: .5rem; }

/* ── Animace ─────────────────────────────────────────────────*/
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .3s ease; }
