/* ============================================================
   CAT Ticketsystem – Design System
   Modernes, responsives UI ohne Framework-Abhängigkeiten
   ============================================================ */

/* ── CSS-Variablen ─────────────────────────────────────────── */
:root {
    --color-primary:      #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light:#dbeafe;
    --color-secondary:    #64748b;
    --color-success:      #16a34a;
    --color-success-light:#dcfce7;
    --color-warning:      #d97706;
    --color-warning-light:#fef3c7;
    --color-danger:       #dc2626;
    --color-danger-light: #fee2e2;
    --color-info:         #0891b2;
    --color-info-light:   #cffafe;

    --bg-body:      #f1f5f9;
    --bg-surface:   #ffffff;
    --bg-sidebar:   #1e293b;
    --bg-sidebar-hover: #334155;
    --bg-sidebar-active: #2563eb;
    --bg-header:    #ffffff;

    --text-primary:   #0f172a;
    --text-secondary: #64748b;
    --text-muted:     #94a3b8;
    --text-inverse:   #f8fafc;
    --text-sidebar:   #cbd5e1;
    --text-sidebar-active: #ffffff;

    --border:       #e2e8f0;
    --border-focus: #2563eb;
    --radius:       0.5rem;
    --radius-sm:    0.25rem;
    --radius-lg:    0.75rem;
    --radius-xl:    1rem;
    --shadow-sm:    0 1px 2px rgba(0,0,0,.05);
    --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:    0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

    --sidebar-width: 260px;
    --header-height: 64px;
    --transition:   0.15s ease;
    --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-primary-dark); }

img { max-width: 100%; height: auto; }

h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.3; color: var(--text-primary); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

p { margin-bottom: 0.5rem; }
p:last-child { margin-bottom: 0; }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.875em;
}
pre {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Layout App Shell ──────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: calc(-1 * var(--sidebar-width)); bottom: 0;
    z-index: 100;
    transition: left 0.25s ease;
    overflow-y: auto;
    scrollbar-width: none;
}
.sidebar.sidebar-open {
    left: 0;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-logo {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-logo.sidebar-logo--img {
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem 1rem 0.9rem;
    text-align: center;
}
.sidebar-logo-icon {
    width: 36px; height: 36px;
    background: var(--color-primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-logo.sidebar-logo--img .sidebar-logo-icon {
    width: auto; height: auto;
    background: none;
    border-radius: 0;
}
.sidebar-logo-icon svg { width: 20px; height: 20px; color: #fff; }
.sidebar-logo-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-inverse);
    line-height: 1.2;
}
.sidebar-logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

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

.sidebar-section {
    padding: 0 0.75rem;
    margin-bottom: 0.25rem;
}
.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem 0.25rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-sidebar);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 1px;
    text-decoration: none;
}
.sidebar-link:hover { background: var(--bg-sidebar-hover); color: #fff; }
.sidebar-link.active { background: var(--bg-sidebar-active); color: #fff; }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }
.sidebar-link.active svg { opacity: 1; }
.sidebar-link-badge {
    margin-left: auto;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 100px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem;
    padding-bottom: 1.5rem;
    margin-bottom: 100px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sidebar-spacer {
    height: 100px;
    flex-shrink: 0;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    text-decoration: none;
}
.sidebar-user:hover { background: var(--bg-sidebar-hover); }
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: rgba(239,68,68,.15);
    color: #fca5a5;
    text-decoration: none;
    font-size: .8rem;
    font-weight: 600;
    transition: background var(--transition), color var(--transition);
    border: 1px solid rgba(239,68,68,.25);
}
.sidebar-logout svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-logout:hover {
    background: rgba(239,68,68,.30);
    color: #fff;
}
.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--color-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ── Main Content ──────────────────────────────────────────── */
.main-wrapper {
    margin-left: 0;
    transition: margin-left 0.25s ease;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.main-wrapper.sidebar-open {
    margin-left: var(--sidebar-width);
}

.topbar {
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
}
.menu-toggle:hover { background: var(--bg-body); }
.menu-toggle svg { width: 20px; height: 20px; }

.content { flex: 1; padding: 1.5rem; padding-bottom: 150px; }

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.page-title { font-size: 1.375rem; font-weight: 700; }
.page-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.125rem; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}
.card-body { padding: 1.25rem; }
.card-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Stat Cards ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon--blue   { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon--green  { background: var(--color-success-light); color: var(--color-success); }
.stat-icon--yellow { background: var(--color-warning-light); color: var(--color-warning); }
.stat-icon--red    { background: var(--color-danger-light);  color: var(--color-danger); }
.stat-icon--gray   { background: #f1f5f9; color: var(--text-secondary); }
.stat-value { font-size: 1.875rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.125rem; }
.stat-change {
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.25rem;
}
.stat-change--up   { color: var(--color-success); }
.stat-change--down { color: var(--color-danger); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    font-family: inherit;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: #fff; }

.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-body); color: var(--text-primary); }

.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.btn-success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn-success:hover:not(:disabled) { background: #15803d; border-color: #15803d; color: #fff; }

.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-body); color: var(--text-primary); }

.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.8rem; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

.btn-icon {
    padding: 0.4rem;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}
.form-label .required { color: var(--color-danger); margin-left: 2px; }

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: #f8fafc; color: var(--text-secondary); cursor: not-allowed; }

textarea.form-control {
    resize: vertical;
    min-height: 120px;
    font-family: var(--font-sans);
}
select.form-control { cursor: pointer; }

.form-hint { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.25rem; }
.form-error { font-size: 0.8rem; color: var(--color-danger); margin-top: 0.25rem; }

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}
.form-check input[type="checkbox"] {
    width: 1rem; height: 1rem;
    border: 1.5px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; flex-shrink: 0; }

/* Colorpicker */
input[type="color"].form-control {
    padding: 0.25rem;
    height: 38px;
    cursor: pointer;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; border-radius: var(--radius-lg); }

table { width: 100%; border-collapse: collapse; }

.table {
    width: 100%;
    font-size: 0.875rem;
}
.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: #f8fafc;
}
.table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f8fafc; }
.table--striped tbody tr:nth-child(even) td { background: #f8fafc; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 100px;
    white-space: nowrap;
    line-height: 1.4;
}
.badge--blue   { background: var(--color-primary-light); color: var(--color-primary); }
.badge--green  { background: var(--color-success-light); color: var(--color-success); }
.badge--yellow { background: var(--color-warning-light); color: var(--color-warning); }
.badge--red    { background: var(--color-danger-light);  color: var(--color-danger); }
.badge--gray   { background: #f1f5f9; color: var(--text-secondary); }
.badge--orange { background: #ffedd5; color: #c2410c; }
.badge--purple { background: #ede9fe; color: #7c3aed; }

/* Status-Dots */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot--blue   { background: var(--color-primary); }
.status-dot--green  { background: var(--color-success); }
.status-dot--yellow { background: var(--color-warning); }
.status-dot--red    { background: var(--color-danger);  }
.status-dot--gray   { background: var(--text-muted);    }

/* ── Flash Alerts ──────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border-width: 1px;
    border-style: solid;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.alert-close:hover { opacity: 1; }
.alert--success { background: var(--color-success-light); border-color: #86efac; color: #15803d; }
.alert--error   { background: var(--color-danger-light);  border-color: #fca5a5; color: #b91c1c; }
.alert--warning { background: var(--color-warning-light); border-color: #fcd34d; color: #b45309; }
.alert--info    { background: var(--color-info-light);    border-color: #67e8f9; color: #0e7490; }

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.pagination-info {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-right: auto;
}
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: all var(--transition);
    text-decoration: none;
}
.page-link:hover { background: var(--bg-body); color: var(--color-primary); border-color: var(--color-primary); }
.page-link.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.page-link.disabled { opacity: 0.4; pointer-events: none; }

/* ── Ticket Thread ─────────────────────────────────────────── */
.ticket-thread { display: flex; flex-direction: column; gap: 1rem; }

.message-item {
    display: flex;
    gap: 0.875rem;
}
.message-item--internal .message-bubble {
    background: #fffbeb;
    border-color: #fcd34d;
}
.message-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--color-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    margin-top: 2px;
}
.message-avatar--agent { background: #7c3aed; }
.message-avatar--system { background: var(--text-muted); }

.message-bubble {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-width: 0;
}
.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.message-author { font-size: 0.875rem; font-weight: 600; }
.message-time   { font-size: 0.75rem; color: var(--text-muted); }
.message-body   { padding: 0.875rem 1rem; font-size: 0.9rem; line-height: 1.65; word-break: break-word; }
.message-body p { margin: 0 0 0.45em; }
.message-body p:last-child { margin-bottom: 0; }
.message-body pre, .message-body code { font-family: monospace; font-size: 0.85em; background: #f1f5f9; border-radius: 4px; }
.message-body pre { padding: 0.6em 0.8em; overflow-x: auto; white-space: pre-wrap; }
.message-body code { padding: 1px 4px; }
.message-body .ql-syntax { background: #1e293b; color: #e2e8f0; padding: 0.75em 1em; border-radius: 6px; white-space: pre-wrap; font-family: monospace; font-size: 0.85em; }

.message-attachments {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text-primary);
    transition: all var(--transition);
}
.attachment-chip:hover { background: var(--color-primary-light); border-color: var(--color-primary); color: var(--color-primary); }
.attachment-chip svg { width: 14px; height: 14px; }

/* ── Ticket Info Sidebar ───────────────────────────────────── */
.ticket-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
}
.ticket-info-item:last-child { border-bottom: none; }
.ticket-info-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.ticket-info-value { font-size: 0.9rem; color: var(--text-primary); font-weight: 500; }

/* History Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
    display: flex;
    gap: 0.75rem;
    position: relative;
    padding-bottom: 0.875rem;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 22px;
    bottom: 0;
    width: 1px;
    background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--bg-body);
    border: 2px solid var(--border);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 1;
}
.timeline-dot--blue   { border-color: var(--color-primary); background: var(--color-primary-light); }
.timeline-dot--green  { border-color: var(--color-success); background: var(--color-success-light); }
.timeline-dot--yellow { border-color: var(--color-warning); background: var(--color-warning-light); }
.timeline-dot--red    { border-color: var(--color-danger);  background: var(--color-danger-light); }

.timeline-content { flex: 1; padding-top: 2px; min-width: 0; }
.timeline-text { font-size: 0.8125rem; color: var(--text-secondary); }
.timeline-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }

/* ── Auth Pages ────────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 1.5rem;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.auth-header {
    padding: 2rem 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.auth-logo {
    width: 56px; height: 56px;
    background: var(--color-primary);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.auth-logo svg { width: 28px; height: 28px; color: #fff; }
.auth-title { font-size: 1.375rem; font-weight: 700; }
.auth-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.25rem; }
.auth-body { padding: 1.5rem 2rem 2rem; }
.auth-footer { padding: 1rem 2rem; text-align: center; background: #f8fafc; border-top: 1px solid var(--border); font-size: 0.875rem; color: var(--text-secondary); }
.auth-footer a { color: var(--color-primary); font-weight: 500; }

/* ── Search & Filters ──────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}
.filter-bar .form-control { width: auto; min-width: 140px; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box svg {
    position: absolute;
    left: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-box .form-control { padding-left: 2rem; }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}
.empty-state-icon {
    width: 64px; height: 64px;
    background: var(--bg-body);
    border-radius: var(--radius-xl);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.empty-state-icon svg { width: 32px; height: 32px; color: var(--text-muted); }
.empty-state-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.375rem; }
.empty-state-text { font-size: 0.875rem; color: var(--text-secondary); max-width: 300px; margin: 0 auto 1rem; }

/* ── Dropdown ──────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
    display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
    font-family: inherit;
}
.dropdown-item:hover { background: var(--bg-body); }
.dropdown-item--danger { color: var(--color-danger); }
.dropdown-item--danger:hover { background: var(--color-danger-light); }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 0.25rem 0; }

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform var(--transition);
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title { font-size: 1.0625rem; font-weight: 600; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 0.25rem;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-body); }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs { border-bottom: 2px solid var(--border); display: flex; gap: 0; margin-bottom: 1.25rem; overflow-x: auto; }
.tab-link {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: all var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}
.tab-link:hover { color: var(--color-primary); }
.tab-link.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Utilities ─────────────────────────────────────────────── */
.flex           { display: flex; }
.flex-wrap      { flex-wrap: wrap; }
.items-center   { align-items: center; }
.items-start    { align-items: flex-start; }
.justify-between{ justify-content: space-between; }
.justify-end    { justify-content: flex-end; }
.gap-1          { gap: 0.25rem; }
.gap-2          { gap: 0.5rem; }
.gap-3          { gap: 0.75rem; }
.gap-4          { gap: 1rem; }
.gap-5          { gap: 1.25rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.ms-auto{ margin-left: auto; }
.me-auto{ margin-right: auto; }
.w-full { width: 100%; }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger    { color: var(--color-danger); }
.text-success   { color: var(--color-success); }
.text-center    { text-align: center; }
.font-semibold  { font-weight: 600; }
.font-bold      { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Two-column grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
.grid-sidebar { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: start; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Spinner ───────────────────────────────────────────────── */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}
.spinner--dark { border-color: rgba(37,99,235,.2); border-top-color: var(--color-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Admin special ─────────────────────────────────────────── */
.color-swatch {
    width: 20px; height: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0,0,0,.1);
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ── Toast notification ────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    background: var(--text-primary);
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: auto;
    max-width: 360px;
    animation: slideIn 0.2s ease;
}
.toast--success { background: #15803d; }
.toast--error   { background: #b91c1c; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .grid-sidebar { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 260px; }

    .sidebar {
        left: calc(-1 * var(--sidebar-width));
    }
    .sidebar.open {
        left: 0;
        box-shadow: var(--shadow-lg);
    }
    .main-wrapper { margin-left: 0; }
    .menu-toggle { display: flex; }
    .content { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; }
    .filter-bar { gap: 0.5rem; }
    .search-box { min-width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-body, .auth-header, .auth-footer { padding-left: 1.25rem; padding-right: 1.25rem; }
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .filter-bar, .btn, .pagination { display: none !important; }
    .main-wrapper { margin: 0; }
    .content { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

.sidebar-clock{margin:6px 10px 4px;border:1px solid rgba(148,163,184,.25);border-radius:6px;padding:5px 8px 6px;text-align:center;background:rgba(0,0,0,.15)}.sidebar-clock-label{display:block;font-size:.62rem;letter-spacing:.08em;text-transform:uppercase;color:rgba(148,163,184,.7);margin-bottom:2px}.sidebar-clock-time{display:block;font-size:.82rem;font-variant-numeric:tabular-nums;letter-spacing:.05em;color:#cbd5e1;font-weight:500}
