/* =========================================================
   DESIGN TOKENY
   ========================================================= */

:root {
    /* Barvy - neutrální báze */
    --ink: #171B21;
    --ink-soft: #5B6572;
    --ink-faint: #8A93A3;
    --canvas: #F6F7F9;
    --surface: #FFFFFF;
    --line: #E5E8ED;
    --line-strong: #D3D8E0;

    /* Akcentní barva (indigo) */
    --accent: #4338CA;
    --accent-hover: #362DA6;
    --accent-soft: #EEEDFB;
    --accent-soft-line: #D9D6F5;

    /* Stavové/SLA barvy */
    --success: #1D9A6C;
    --success-soft: #E3F6ED;
    --warning: #D97706;
    --warning-soft: #FDF1E1;
    --danger: #DC2626;
    --danger-soft: #FCE8E7;
    --info: #2563AA;
    --info-soft: #E6EEF8;
    --neutral: #8A93A3;
    --neutral-soft: #EEF0F3;

    /* Typografie */
    --font-display: "Sora", "Inter", system-ui, sans-serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

    /* Rádiusy a stíny */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(23, 27, 33, 0.06);
    --shadow-md: 0 4px 16px rgba(23, 27, 33, 0.08);
    --shadow-lg: 0 12px 32px rgba(23, 27, 33, 0.12);
}

/* =========================================================
   ZÁKLADNÍ NASTAVENÍ
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    background: var(--canvas);
    color: var(--ink);
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--ink);
    letter-spacing: -0.01em;
}

a {
    color: var(--accent);
}

.content {
    padding: 28px 32px;
    max-width: 1320px;
    margin: 0 auto;
}

/* Viditelný focus - přístupnost */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* =========================================================
   TOPBAR
   ========================================================= */

.topbar {
    position: sticky;
    top: 0;
    z-index: 2000;
    background: var(--ink);
    color: #ffffff;
    padding: 12px 28px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    transition: box-shadow 0.2s ease;
    max-width: 100vw;
    display: flex;
    align-items: center;
}

.topbar.scrolled {
    box-shadow: var(--shadow-lg);
}

.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar .logo {
    font-family: var(--font-display);
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--accent);
    border-radius: 6px;
    font-size: 12px;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    font-size: 17px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.topbar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    margin-left: 24px;
    min-width: 0;
}

.topbar .left {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.topbar .left a {
    color: rgba(255,255,255,0.82);
    margin-right: 2px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.topbar .left a:hover {
    background: rgba(255,255,255,0.10);
    color: #ffffff;
}

.topbar .right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.user-label {
    color: rgba(255,255,255,0.75);
    font-size: 13px;
    font-weight: 500;
}

.top-btn {
    padding: 7px 14px;
    background: rgba(255,255,255,0.10);
    color: #ffffff !important;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: 0.15s ease;
    white-space: nowrap;
}

.top-btn:hover {
    background: rgba(255,255,255,0.18);
}

.top-btn.logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
}

.top-btn.logout:hover {
    background: var(--danger);
    border-color: var(--danger);
}

/* --- MOBIL: hamburger menu místo řádku odkazů --- */
@media (max-width: 860px) {
    .topbar {
        padding: 10px 16px;
        flex-direction: column;
        align-items: stretch;
    }

    .menu-toggle {
        display: flex;
    }

    .topbar-nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
        margin-top: 14px;
        gap: 4px;
    }

    .topbar-nav.open {
        display: flex;
    }

    .topbar .left {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .topbar .left a {
        padding: 10px 12px;
    }

    .topbar .right {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(255,255,255,0.12);
    }

    .user-label {
        display: block;
        padding: 4px 12px;
    }

    .top-btn {
        text-align: center;
    }
}

/* =========================================================
   TABULKY - základ
   ========================================================= */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 14px;
}

table th, table td {
    border: 1px solid var(--line);
    padding: 10px 12px;
}

/* =========================================================
   TLAČÍTKA
   ========================================================= */

.btn {
    display: inline-block;
    padding: 8px 14px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 10px;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn-delete {
    display: inline-block;
    background: var(--danger);
    color: white;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    margin-top: 10px;
    border: none;
    cursor: pointer;
    transition: 0.15s ease;
}

.btn-delete:hover {
    background: #B91C1C;
}

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    cursor: pointer;
    margin-top: 10px;
    font-weight: 600;
    font-size: 13px;
    transition: 0.15s ease;
}

.btn-secondary:hover {
    background: var(--canvas);
    border-color: var(--ink-faint);
}

/* =========================================================
   LOGIN / REGISTRACE
   ========================================================= */

.login-box, .form-box {
    width: 340px;
    margin: 64px auto;
    background: var(--surface);
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.login-box h2, .form-box h2 {
    margin-top: 0;
    font-size: 20px;
}

.error {
    background: var(--danger-soft);
    color: #7A1F1F;
    padding: 10px 12px;
    border: 1px solid #F3B9B6;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13px;
}

/* =========================================================
   FORMULÁŘE (obecné)
   ========================================================= */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
    font-family: var(--font-body);
    font-size: 14px;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}

label {
    font-weight: 600;
    font-size: 13px;
    color: var(--ink-soft);
}

.ticket-form {
    width: 640px;
    background: var(--surface);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.ticket-form .form-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    gap: 6px;
}

.wide-input, .wide-textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
}

.wide-textarea {
    height: 180px;
    resize: vertical;
}

.btn-submit {
    padding: 10px 16px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: 0.15s ease;
}

.btn-submit:hover {
    background: #157A56;
}

/* =========================================================
   SEZNAM TICKETŮ - řádky, SLA rail, stavy
   ========================================================= */

.ticket-row {
    cursor: pointer;
    position: relative;
    transition: background 0.12s ease-in-out;
    border-left: 4px solid transparent;
}

.ticket-row:hover {
    background: var(--accent-soft) !important;
}

.ticket-row.status-open       { border-left-color: var(--success); }
.ticket-row.status-waiting_admin { border-left-color: var(--info); }
.ticket-row.status-waiting_user  { border-left-color: var(--warning); }
.ticket-row.status-closed     { border-left-color: var(--neutral); }

.ticket-row.assigned-to-me {
    background: var(--accent-soft) !important;
}

.ticket-row.assigned-to-me:hover {
    background: var(--accent-soft-line) !important;
}

.btn-new {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    margin-bottom: 20px;
    transition: 0.15s ease-in-out;
    box-shadow: var(--shadow-sm);
}

.btn-new:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

.btn-new:active {
    transform: scale(0.97);
}

/* Číslo ticketu jako mono "chip" */
.ticket-id, td.ticket-id-cell {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--ink-soft);
}

/* =========================================================
   NEPŘEČTENÉ TICKETY
   ========================================================= */

.unread td {
    font-weight: 700;
    background: var(--warning-soft) !important;
}

.ticket-title-unread::before {
    content: "● ";
    color: var(--danger);
    font-size: 15px;
    vertical-align: middle;
}

/* =========================================================
   TABULKA UŽIVATELŮ
   ========================================================= */

.users-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: 13px;
    table-layout: fixed;
    box-shadow: var(--shadow-sm);
}

.users-table th {
    background: var(--canvas);
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line);
}

.users-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    color: var(--ink);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.users-table tr:nth-child(even) {
    background: #FBFBFC;
}

.users-table tr {
    transition: background 0.15s ease-in-out;
}

.users-table tr:hover {
    background: var(--accent-soft);
}

/* Badge */
.badge {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    display: inline-block;
    color: white;
    letter-spacing: 0.02em;
}

.badge-pending  { background: var(--warning); }
.badge-active   { background: var(--success); }
.badge-disabled { background: var(--danger); }
.badge-unknown  { background: var(--neutral); }

/* Akční tlačítka v tabulkách */
.actions .btn, .actions button.btn {
    margin-right: 4px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: 0.15s ease-in-out;
    border: none;
    cursor: pointer;
}

.btn-edit    { background: var(--accent); }
.btn-pass    { background: #6F42C1; }
.btn-approve { background: var(--success); }
.btn-disable { background: var(--warning); }
.btn-delete  { background: var(--danger); }

.actions .btn:hover, .actions button.btn:hover {
    filter: brightness(0.92);
}

.users-table th:nth-child(1), .users-table td:nth-child(1) { width: 60px; text-align: right; }
.users-table th:nth-child(2), .users-table td:nth-child(2) { width: 160px; }
.users-table th:nth-child(3), .users-table td:nth-child(3) { width: 240px; }
.users-table th:nth-child(4), .users-table td:nth-child(4) { width: 120px; text-align: center; }
.users-table th:nth-child(5), .users-table td:nth-child(5) { width: 140px; text-align: center; }
.users-table th:nth-child(6), .users-table td:nth-child(6) { width: 300px; text-align: center; }

/* =========================================================
   DETAIL TICKETU
   ========================================================= */

.page-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.sidebar {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.comment-box {
    background: var(--canvas);
    border: 1px solid var(--line);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.comment-box + .comment-box {
    border-top: none;
    padding-top: 14px;
}

.comment-author {
    font-weight: 700;
    margin-bottom: 2px;
    font-size: 13px;
    color: var(--ink);
}

.comment-date {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-faint);
    margin-bottom: 8px;
}

.comments-scroll {
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    margin-top: 16px;
    border: 1px solid var(--line);
    background: var(--canvas);
    border-radius: var(--radius-sm);
}

.sticky-header {
    position: sticky;
    top: 52px;
    z-index: 999;
    background: var(--canvas);
    padding-top: 5px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.sticky-header.scrolled {
    box-shadow: var(--shadow-sm);
}

.attachments-section {
    margin-bottom: 20px;
}

/* =========================================================
   DASHBOARD
   ========================================================= */

.stat-box {
    flex: 1;
    min-width: 260px;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: 0.15s ease-in-out;
    text-decoration: none;
    color: inherit;
    position: relative;
    height: 320px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.stat-box:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-box-content {
    overflow-y: auto;
    margin-top: 15px;
    padding-right: 5px;
}

.ticket-list {
    text-align: left;
    font-size: 13px;
    padding-left: 10px;
}

.ticket-list li {
    margin-bottom: 4px;
}

.ticket-list a {
    color: var(--accent);
    text-decoration: none;
}

.ticket-list a:hover {
    text-decoration: underline;
}

/* =========================================================
   FLASH ZPRÁVY
   ========================================================= */

.flash-messages {
    margin: 10px 0;
}

.flash-message {
    background: var(--warning-soft);
    border: 1px solid #F0CB8E;
    color: #7A4A05;
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 13px;
}

/* =========================================================
   RESPONZIVNÍ ÚPRAVY PRO MOBIL
   ========================================================= */

@media (max-width: 768px) {

    .content {
        padding: 16px;
    }

    /* Detail ticketu - dva sloupce vedle sebe nedávají na mobilu smysl */
    .page-grid {
        grid-template-columns: 1fr;
    }

    .ticket-header {
        flex-direction: column;
        align-items: stretch;
    }

    .ticket-header-left {
        max-width: 100%;
    }

    .ticket-header-right {
        text-align: left;
        margin-top: 10px;
    }

    /* Formuláře na celou šířku */
    .ticket-form,
    .edit-container,
    .login-box,
    .form-box {
        width: 100%;
        max-width: 100%;
        padding: 20px;
    }

    .login-container {
        margin-top: 24px;
        padding: 0 12px;
    }

    /* Filtr ticketů - položky pod sebou */
    .filter-form {
        flex-direction: column;
        gap: 14px;
    }

    /* Tabulky - kompaktnější, aby šlo aspoň částečně číst bez scrollu */
    table th, table td,
    .users-table th, .users-table td {
        padding: 8px;
        font-size: 12.5px;
    }

    /* Dashboard dlaždice - přes celou šířku, ALE pevná výška zůstává,
       jinak se seznam ticketů uvnitř nescrolluje a vypíše se celý (dlouhá stránka) */
    .stat-box {
        min-width: 100%;
        height: 280px;
    }

    /* Sidebar u detailu ticketu už není vedle obsahu, netřeba extra odsazení */
    .sidebar {
        margin-top: 0;
    }
}

@media (max-width: 480px) {
    .topbar .left a {
        padding: 8px 9px;
        font-size: 13px;
    }

    .btn-new, .btn-primary {
        width: 100%;
        text-align: center;
    }
}
