/* ═══════════════════════════════════════════════
   TICKETSYSTEM — Design System
   ═══════════════════════════════════════════════ */

/* ── Custom Properties (Light) ── */
:root {
    --primary:        #3b82f6;
    --primary-hover:  #2563eb;
    --primary-fg:     #ffffff;
    --primary-subtle: #eff6ff;

    --success:        #16a34a;
    --success-subtle: #dcfce7;
    --danger:         #dc2626;
    --danger-subtle:  #fee2e2;
    --warning:        #d97706;
    --warning-subtle: #fef3c7;

    --bg:        #f1f5f9;
    --surface:   #ffffff;
    --surface-2: #f8fafc;
    --text:      #0f172a;
    --text-2:    #334155;
    --text-muted:#64748b;
    --border:    #e2e8f0;

    --nav-bg:    #0f172a;
    --nav-text:  #94a3b8;
    --nav-hover: #f1f5f9;
    --brand:     #60a5fa;

    --shadow-xs: 0 1px 2px 0 rgb(0 0 0/.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0/.1),0 1px 2px -1px rgb(0 0 0/.1);
    --shadow:    0 4px 6px -1px rgb(0 0 0/.1),0 2px 4px -2px rgb(0 0 0/.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0/.1),0 4px 6px -4px rgb(0 0 0/.1);

    --r:    6px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-pill: 9999px;

    --ease: 150ms ease;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
    --primary:        #60a5fa;
    --primary-hover:  #93c5fd;
    --primary-fg:     #0f172a;
    --primary-subtle: rgba(96,165,250,.12);

    --success:        #4ade80;
    --success-subtle: rgba(74,222,128,.12);
    --danger:         #f87171;
    --danger-subtle:  rgba(248,113,113,.12);
    --warning:        #fbbf24;
    --warning-subtle: rgba(251,191,36,.12);

    --bg:        #0f172a;
    --surface:   #1e293b;
    --surface-2: #0f172a;
    --text:      #f1f5f9;
    --text-2:    #e2e8f0;
    --text-muted:#94a3b8;
    --border:    #334155;

    --nav-bg:    #020617;
    --nav-text:  #94a3b8;
    --nav-hover: #f1f5f9;

    --shadow-xs: 0 1px 2px 0 rgb(0 0 0/.4);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0/.5),0 1px 2px -1px rgb(0 0 0/.4);
    --shadow:    0 4px 6px -1px rgb(0 0 0/.5),0 2px 4px -2px rgb(0 0 0/.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0/.6),0 4px 6px -4px rgb(0 0 0/.5);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary:        #60a5fa;
        --primary-hover:  #93c5fd;
        --primary-fg:     #0f172a;
        --primary-subtle: rgba(96,165,250,.12);
        --success:        #4ade80;
        --success-subtle: rgba(74,222,128,.12);
        --danger:         #f87171;
        --danger-subtle:  rgba(248,113,113,.12);
        --warning:        #fbbf24;
        --warning-subtle: rgba(251,191,36,.12);
        --bg:        #0f172a;
        --surface:   #1e293b;
        --surface-2: #0f172a;
        --text:      #f1f5f9;
        --text-2:    #e2e8f0;
        --text-muted:#94a3b8;
        --border:    #334155;
        --nav-bg:    #020617;
        --nav-text:  #94a3b8;
        --nav-hover: #f1f5f9;
        --shadow-xs: 0 1px 2px 0 rgb(0 0 0/.4);
        --shadow-sm: 0 1px 3px 0 rgb(0 0 0/.5),0 1px 2px -1px rgb(0 0 0/.4);
        --shadow:    0 4px 6px -1px rgb(0 0 0/.5),0 2px 4px -2px rgb(0 0 0/.4);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0/.6),0 4px 6px -4px rgb(0 0 0/.5);
    }
}

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

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s, color .2s;
}

/* ── Links ── */
a                { color: var(--primary); text-decoration: none; }
a:hover          { color: var(--primary-hover); text-decoration: underline; }
a:visited        { color: var(--primary); }

/* ── Navigation ── */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--nav-bg);
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 20px;
    gap: 4px;
    box-shadow: 0 1px 0 rgba(255,255,255,.06);
}

.nav-brand {
    font-size: .95em;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--brand) !important;
    text-decoration: none !important;
    margin-right: 12px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.nav-brand:hover { opacity: .85; text-decoration: none !important; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    flex-wrap: wrap;
    overflow: hidden;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    padding: 6px 11px;
    border-radius: var(--r);
    font-size: .82em;
    font-weight: 500;
    color: var(--nav-text) !important;
    text-decoration: none !important;
    transition: color var(--ease), background var(--ease);
    white-space: nowrap;
}
.nav-links a:hover {
    color: var(--nav-hover) !important;
    background: rgba(255,255,255,.09);
    text-decoration: none !important;
}

.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

#theme-toggle {
    background: rgba(255,255,255,.07);
    color: var(--nav-text);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--r);
    padding: 6px 10px;
    cursor: pointer;
    font-size: .85em;
    line-height: 1;
    transition: background var(--ease), color var(--ease);
}
#theme-toggle:hover {
    background: rgba(255,255,255,.14);
    color: var(--nav-hover);
}

/* Hamburger */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--r);
    padding: 7px 9px;
    cursor: pointer;
}
.nav-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--nav-text);
    border-radius: 2px;
    transition: all var(--ease);
}

/* ── Toast notifications ── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 340px;
    width: calc(100vw - 32px);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    border-left-width: 4px;
    box-shadow: var(--shadow-lg);
    font-size: .85em;
    pointer-events: all;
    animation: toast-in .2s ease;
    color: var(--text);
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger);  }
.toast.warning { border-left-color: var(--warning); }
.toast.info    { border-left-color: var(--primary); }

.toast-icon  { font-size: 1em; flex-shrink: 0; margin-top: 1px; }
.toast-msg   { flex: 1; line-height: 1.4; }
.toast-close {
    background: none; border: none; padding: 0;
    cursor: pointer; color: var(--text-muted);
    font-size: 1.1em; line-height: 1; flex-shrink: 0;
}
.toast-close:hover { color: var(--text); }

@keyframes toast-in  { from { opacity:0; transform:translateX(12px) } to { opacity:1; transform:none } }
@keyframes toast-out { from { opacity:1; max-height:200px; margin-bottom:0 }
                       to   { opacity:0; max-height:0;     margin-bottom:-8px; padding-top:0; padding-bottom:0; overflow:hidden } }

/* ── Page title bar ── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 18px 24px;
}
header h1 {
    margin: 0;
    font-size: 1.25em;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text);
}

/* ── Main ── */
main {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Buttons ── */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 13px;
    border-radius: var(--r);
    font-size: .82em;
    font-weight: 500;
    line-height: 1.25;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: all var(--ease);
    white-space: nowrap;
    font-family: inherit;
}
button:hover, .btn:hover {
    background: var(--surface-2);
    border-color: var(--text-muted);
    text-decoration: none;
}

button[type="submit"]:not(.btn-ghost):not(.btn-danger) {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
}
button[type="submit"]:not(.btn-ghost):not(.btn-danger):hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-danger, button.btn-danger {
    background: var(--danger-subtle);
    color: var(--danger);
    border-color: transparent;
}
.btn-danger:hover, button.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-success, button.btn-success {
    background: var(--success-subtle);
    color: var(--success);
    border-color: transparent;
}
.btn-success:hover {
    background: var(--success);
    color: #fff;
}

/* Action links that look like buttons */
a.action-btn,
.ticket-filters a,
table td:last-child:not([data-label]) a,
table td[data-label=""] a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--r);
    font-size: .82em;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text) !important;
    text-decoration: none !important;
    transition: all var(--ease);
    cursor: pointer;
}
a.action-btn:hover,
.ticket-filters a:hover,
table td:last-child:not([data-label]) a:hover,
table td[data-label=""] a:hover {
    background: var(--surface-2);
    border-color: var(--text-muted);
    text-decoration: none !important;
}
a.action-btn.primary {
    background: var(--primary);
    color: var(--primary-fg) !important;
    border-color: var(--primary);
}
a.action-btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* ── Form card ── */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 24px;
    max-width: 520px;
    box-shadow: var(--shadow-xs);
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 14px;
}
.form-group input,
.form-group select,
.form-group textarea { width: 100%; }

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.form-group-inline input[type="checkbox"] { width: auto; flex-shrink: 0; }
.form-group-inline label {
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: .875em;
    font-weight: 500;
    color: var(--text);
}

.form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.form-error {
    background: var(--danger-subtle);
    color: var(--danger);
    border: 1px solid rgba(220,38,38,.25);
    border-left: 3px solid var(--danger);
    border-radius: var(--r);
    padding: 10px 14px;
    font-size: .875em;
    margin-bottom: 16px;
}
.form-success {
    background: var(--success-subtle);
    color: var(--success);
    border: 1px solid rgba(22,163,74,.25);
    border-left: 3px solid var(--success);
    border-radius: var(--r);
    padding: 10px 14px;
    font-size: .875em;
    margin-bottom: 16px;
}

/* Dashboard stat-card color variants */
.stat-card-blue   { background: var(--primary-subtle) !important; border-color: rgba(59,130,246,.3) !important; }
.stat-card-green  { background: var(--success-subtle) !important; border-color: rgba(22,163,74,.3) !important; }
.stat-card-yellow { background: var(--warning-subtle) !important; border-color: rgba(217,119,6,.3) !important; }
.stat-card-orange { background: rgba(249,115,22,.1) !important;  border-color: rgba(249,115,22,.3) !important; }
.stat-value-green  { color: var(--success) !important; }
.stat-value-red    { color: var(--danger) !important; }
.stat-value-orange { color: var(--warning) !important; }

/* Info notice banner */
.notice {
    background: var(--primary-subtle);
    color: var(--text-2);
    border: 1px solid rgba(59,130,246,.25);
    border-left: 3px solid var(--primary);
    border-radius: var(--r);
    padding: 10px 14px;
    font-size: .875em;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.notice a { color: var(--primary); font-weight: 600; }

/* Bulk selection toolbar */
.bulk-toolbar {
    display: none;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--primary-subtle);
    border: 1px solid rgba(59,130,246,.3);
    border-radius: var(--r-lg);
    margin-bottom: 12px;
    font-size: .875em;
}
.bulk-toolbar.active { display: flex; }
.bulk-count { font-weight: 600; color: var(--primary); margin-right: 4px; }

/* ── Form elements ── */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 8px 10px;
    font-size: .85em;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
    transition: border-color var(--ease), box-shadow var(--ease);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

label {
    display: block;
    font-size: .75em;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 4px;
}

/* ── Tables ── */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    margin: 0;
    font-size: .875em;
}

table th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

a.sort-link {
    color: inherit !important;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
a.sort-link:hover { color: var(--text) !important; }
.sort-arrow { opacity: .7; font-size: .9em; }

table td {
    padding: 10px 14px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }
table tr:hover td      { background: var(--surface-2); }

/* ── Filter form ── */
.ticket-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}
.ticket-filters > div {
    display: flex;
    flex-direction: column;
}
.ticket-filters select,
.ticket-filters input[type="text"] {
    min-width: 140px;
}

/* ── Toolbar (above table) ── */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

/* ── Pagination ── */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    margin: 16px 0;
}
.pagination a,
.pagination strong,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-size: .8em;
    color: var(--text);
    background: var(--surface);
    transition: all var(--ease);
    text-decoration: none;
}
.pagination a:hover {
    background: var(--primary);
    color: #fff !important;
    border-color: var(--primary);
    text-decoration: none;
}
.pagination strong {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
}
.pagination .pagination-info {
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: .8em;
    padding: 0 6px;
}

/* ── Summary section ── */
.ticket-summary {
    margin-top: 24px;
    padding: 20px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}
.ticket-summary h2, .ticket-summary h3 {
    margin: 0 0 12px;
    font-size: 1em;
    font-weight: 600;
    color: var(--text);
}
.ticket-summary h3 { margin-top: 20px; }
.ticket-summary ul {
    margin: 0 0 8px;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 24px;
}
.ticket-summary ul li {
    font-size: .85em;
    color: var(--text-2);
}

/* ── Dashboard stat cards ── */
.stats-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}
.stat-card {
    border-radius: var(--r-lg);
    padding: 20px 22px;
    min-width: 150px;
    flex: 1 1 140px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}
.stat-card .stat-value {
    font-size: 1.7em;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -.02em;
    color: var(--text);
}
.stat-card .stat-label {
    font-size: .78em;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
}
[data-theme="dark"] .stat-card                            { background: var(--surface) !important; border-color: var(--border) !important; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .stat-card            { background: var(--surface) !important; border-color: var(--border) !important; }
}

/* ── Modal ── */
#buyerModal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: var(--surface);
    color: var(--text);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--r-xl);
    width: min(440px, 92vw);
}
#buyerModal h2 {
    margin: 0 0 16px;
    font-size: 1.05em;
    font-weight: 600;
}
#modalBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(3px);
    z-index: 999;
}

/* ── Utility ── */
.no-tickets {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}

/* ════════════════════════════════
   RESPONSIVE  ≤ 768 px
   ════════════════════════════════ */
@media (max-width: 768px) {
    /* Nav */
    .nav-hamburger { display: flex; }
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--nav-bg);
        flex-direction: column;
        gap: 0;
        padding: 8px 12px 14px;
        border-top: 1px solid rgba(255,255,255,.06);
        box-shadow: var(--shadow-lg);
        z-index: 199;
    }
    .nav-links.open { display: flex; }
    .nav-links a    { padding: 10px 12px; font-size: .875em; }
    .site-nav       { overflow: visible; position: sticky; }

    /* Layout */
    header { padding: 14px 16px; }
    main   { padding: 14px; }

    /* Card table */
    table { display: block; overflow-x: visible; min-width: 0; }
    table tr:has(th) { display: none; }
    table tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid var(--border);
        border-radius: var(--r-lg);
        background: var(--surface);
        overflow: hidden;
        box-shadow: var(--shadow-xs);
    }
    table td {
        display: flex;
        padding: 9px 14px;
        border: none;
        border-bottom: 1px solid var(--border);
        gap: 10px;
        align-items: flex-start;
        word-break: break-word;
        font-size: .875em;
    }
    table td:last-child { border-bottom: none; }
    table td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: .72em;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--text-muted);
        min-width: 80px;
        flex-shrink: 0;
        padding-top: 3px;
    }
    table td:not([data-label])::before,
    table td[data-label=""]::before { display: none; min-width: 0; }

    /* Filter form */
    .ticket-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .ticket-filters select,
    .ticket-filters input[type="text"] { min-width: 0; width: 100%; }

    /* Stats */
    .stats-grid { gap: 10px; }

    /* Modal */
    #buyerModal { width: min(400px, 92vw); }

    /* Pagination */
    .pagination a,
    .pagination strong { min-width: 28px; height: 28px; font-size: .75em; }
}
