/* ========================================================================
   Ticket Gate – Design System
   ======================================================================== */

:root {
    --sidebar-width: 240px;
    --sidebar-collapsed: 0px;
    --topbar-height: 56px;
    --brand: #060c18;
    --brand-light: #0c1728;
    --brand-accent: #38bdf8;
    --brand-accent-hover: #0284c7;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #38bdf8;
    --radius: 0.625rem;
    --radius-lg: 0.875rem;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --transition: 150ms cubic-bezier(.4,0,.2,1);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--surface-alt);
    color: var(--text);
    margin: 0;
    font-size: .9rem;
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ── */
.tg-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--brand);
    color: #cbd5e1;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}
.tg-sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -.01em;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.tg-sidebar-brand .brand-icon {
    width: 32px;
    height: 32px;
    background: var(--brand-accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tg-sidebar-section {
    padding: .5rem .75rem;
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #475569;
    margin-top: .25rem;
}
.tg-sidebar-nav {
    list-style: none;
    padding: .25rem .625rem;
    margin: 0;
    flex: 1;
}
.tg-sidebar-nav li { margin-bottom: 1px; }
.tg-sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem .75rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius);
    font-size: .835rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}
.tg-sidebar-nav a:hover {
    color: #e2e8f0;
    background: rgba(255,255,255,.06);
}
.tg-sidebar-nav a.active {
    color: #fff;
    background: rgba(59, 130, 246, .2);
}
.tg-sidebar-nav a .nav-icon {
    width: 18px;
    height: 18px;
    opacity: .7;
    flex-shrink: 0;
}
.tg-sidebar-nav a.active .nav-icon,
.tg-sidebar-nav a:hover .nav-icon { opacity: 1; }
.tg-sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: .5rem .75rem;
}
.tg-sidebar-footer {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(255,255,255,.06);
    font-size: .8rem;
}
.tg-sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}
.tg-sidebar-footer .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
    flex-shrink: 0;
}
.tg-sidebar-footer .user-name {
    color: #e2e8f0;
    font-weight: 600;
    font-size: .8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tg-sidebar-footer .user-role {
    color: #64748b;
    font-size: .7rem;
}

/* ── Topbar (mobile) ── */
.tg-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--brand);
    color: #fff;
    z-index: 1041;
    padding: 0 1rem;
    align-items: center;
    gap: .75rem;
}
.tg-topbar .brand-text {
    font-weight: 700;
    font-size: 1rem;
}
.tg-menu-toggle {
    background: none;
    border: none;
    color: #fff;
    padding: .25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* ── Main content ── */
.tg-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 1.5rem 2rem 2rem;
    transition: margin-left var(--transition);
}

/* ── Overlay ── */
.tg-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1039;
}

/* ── Mobile ── */
@media (max-width: 991.98px) {
    .tg-sidebar {
        transform: translateX(-100%);
    }
    .tg-sidebar.open {
        transform: translateX(0);
    }
    .tg-overlay.open {
        display: block;
    }
    .tg-topbar {
        display: flex;
    }
    .tg-main {
        margin-left: 0;
        padding: calc(var(--topbar-height) + 1rem) 1rem 1.5rem;
    }
}

/* ── Page header ── */
.page-header {
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -.02em;
}
.page-header .page-subtitle {
    color: var(--text-muted);
    font-size: .85rem;
    margin-top: .25rem;
}
.page-header .page-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
}

/* ── Breadcrumbs ── */
.tg-breadcrumb {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: .75rem;
}
.tg-breadcrumb a {
    color: var(--brand-accent);
    text-decoration: none;
}
.tg-breadcrumb a:hover { text-decoration: underline; }
.tg-breadcrumb .sep { color: var(--text-light); }

/* ── Cards ── */
.tg-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.tg-card .card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1.25rem;
    font-weight: 600;
    font-size: .875rem;
    color: var(--text);
}
.tg-card .card-body {
    padding: 1.25rem;
}

/* ── Stat cards ── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
    transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
}
.stat-card .stat-label {
    font-size: .75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-top: .25rem;
}
.stat-card.stat-success .stat-value { color: var(--success); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-info .stat-value { color: var(--info); }
.stat-card.stat-danger .stat-value { color: var(--danger); }
.stat-card.stat-primary { border-left: 3px solid var(--brand-accent); }
.stat-card.stat-success { border-left: 3px solid var(--success); }

/* ── Tables ── */
.tg-table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.tg-table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
}
.tg-table thead th {
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    padding: .625rem 1rem;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    white-space: nowrap;
}
.tg-table tbody td {
    padding: .625rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: .85rem;
    vertical-align: middle;
}
.tg-table tbody tr:last-child td { border-bottom: none; }
.tg-table tbody tr:hover { background: var(--surface-hover); }
.tg-table .actions-cell {
    white-space: nowrap;
    text-align: right;
}

/* ── Buttons ── */
.btn { border-radius: var(--radius); font-weight: 500; font-size: .85rem; transition: all var(--transition); }
.btn-xs { padding: .25rem .5rem; font-size: .75rem; }

.btn-primary { background: var(--brand-accent); border-color: var(--brand-accent); }
.btn-primary:hover { background: var(--brand-accent-hover); border-color: var(--brand-accent-hover); }

.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-hover); border-color: #cbd5e1; }

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .65rem;
    font-size: .8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition);
    cursor: pointer;
    font-weight: 500;
}
.btn-action:hover { background: var(--surface-hover); color: var(--text); border-color: #cbd5e1; }
.btn-action.action-danger { color: var(--danger); }
.btn-action.action-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-action.action-primary { color: var(--brand-accent); }
.btn-action.action-primary:hover { background: #eff6ff; border-color: #bfdbfe; }
.btn-action.action-success { color: var(--success); }
.btn-action.action-success:hover { background: #ecfdf5; border-color: #a7f3d0; }

/* ── Badges / Pills ── */
.tg-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .55rem;
    font-size: .7rem;
    font-weight: 600;
    border-radius: 999px;
    letter-spacing: .02em;
}
.tg-badge-success { background: #ecfdf5; color: #065f46; }
.tg-badge-warning { background: #fffbeb; color: #92400e; }
.tg-badge-danger { background: #fef2f2; color: #991b1b; }
.tg-badge-info { background: #eff6ff; color: #1e40af; }
.tg-badge-neutral { background: #f1f5f9; color: #475569; }
.tg-badge-secondary { background: #f1f5f9; color: #374151; }

/* ── Forms ── */
.tg-form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 560px;
    box-shadow: var(--shadow-sm);
}
.form-label {
    font-weight: 600;
    font-size: .8rem;
    color: var(--text);
    margin-bottom: .35rem;
}
.form-control, .form-select {
    border-radius: var(--radius);
    border-color: var(--border);
    font-size: .85rem;
    padding: .5rem .75rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .1);
}
.form-text { font-size: .78rem; color: var(--text-muted); }

/* ── Alerts ── */
.alert { border-radius: var(--radius); font-size: .85rem; border: none; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info { background: #eff6ff; color: #1e40af; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }
.empty-state .empty-text { font-size: .9rem; margin-bottom: 1rem; }

/* ── Pagination ── */
.pagination { gap: .25rem; }
.pagination .page-link {
    border-radius: var(--radius) !important;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: .8rem;
    padding: .35rem .65rem;
}
.pagination .page-item.active .page-link {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
}

/* ── Step indicator ── */
.step-indicator {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1.5rem;
}
.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 2px solid var(--border);
    color: var(--text-muted);
    background: var(--surface);
}
.step-dot.active {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
    color: #fff;
}
.step-dot.done {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    max-width: 60px;
}
.step-line.done { background: var(--success); }
.step-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
}
.step-label.active { color: var(--text); }

/* ── Utility ── */
.text-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: .82em; }
.gap-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
