:root {
    --bg-primary: #0d1117;
    --bg-card: #161b22;
    --bg-input: #21262d;
    --border-default: #30363d;
    --border-focus: #58a6ff;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent-blue: #58a6ff;
    --accent-green: #2ea043;
    --success-bg: #0d2b1a;
    --success-border: #2ea043;
    --success-text: #3fb950;
    --error-bg: #2d1117;
    --error-border: #f85149;
    --error-text: #f85149;
    --warning-bg: #2d2000;
    --warning-border: #d29922;
    --warning-text: #d29922;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Space Grotesk', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-default);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.header-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    text-decoration: none;
}
.header-brand span { color: var(--accent-blue); }
.header-badge {
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(88,166,255,0.12);
    color: var(--accent-blue);
    border: 1px solid rgba(88,166,255,0.3);
    border-radius: 20px;
    padding: 0.2rem 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ── Main Layout ── */
.main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.validator-card {
    width: 100%;
    max-width: 520px;
}

/* ── Title ── */
.card-title {
    text-align: center;
    margin-bottom: 1.5rem;
}
.card-title .icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    display: block;
}
.card-title h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}
.card-title p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.4rem;
}

/* ── Input Section ── */
.input-section {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}
.input-section:focus-within {
    border-color: var(--border-focus);
}
.input-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}
.input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
#ticket-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Space Grotesk', monospace;
    font-size: 0.95rem;
    padding: 0.7rem 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
#ticket-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(88,166,255,0.15);
}
#ticket-input::placeholder { color: var(--text-muted); }

/* ── QR Toggle Button ── */
.qr-toggle-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.qr-toggle-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}
.qr-toggle-btn.active {
    background: rgba(88,166,255,0.12);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ── Validate Button ── */
.btn-validate {
    width: 100%;
    background: var(--accent-blue);
    border: none;
    border-radius: 8px;
    color: #0d1117;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-bottom: 0.5rem;
}
.btn-validate:hover { background: #79b8ff; }
.btn-validate:active { transform: scale(0.97); }
.btn-validate:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}
.input-hint {
    font-size: 0.77rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── Scanner (camera) ── */
.scanner-section {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
}
.scanner-section.active { display: block; }
#scanner-container {
    width: 100%;
    min-height: 240px;
    background: #000;
    position: relative;
}
#scanner-container video {
    width: 100%;
    display: block;
}
.scanner-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border: 2px solid rgba(88,166,255,0.4);
    border-radius: 8px;
    pointer-events: none;
    margin: 12px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.3);
}
.scanner-overlay::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 40px; height: 40px;
    margin: -20px 0 0 -20px;
    border: 2px solid var(--accent-blue);
    border-radius: 4px;
    animation: scanPulse 2s ease-in-out infinite;
}
@keyframes scanPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}
.scanner-status {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    border-top: 1px solid var(--border-default);
}
.scanner-status .dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    margin-right: 6px;
    animation: blink 1s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── Result Panel ── */
#result-panel {
    border-radius: 12px;
    padding: 1.5rem;
    display: none;
    animation: fadeIn 0.3s ease;
}
#result-panel.show { display: block; }
#result-panel.success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
}
#result-panel.error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
}
#result-panel.warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
}
.result-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.result-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.result-message {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: 1rem;
}
.result-details {
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    font-size: 0.85rem;
}
.result-details .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.result-details .detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-secondary); font-weight: 500; }
.detail-value { font-weight: 600; text-align: right; }
.success .detail-value { color: var(--success-text); }
.error .detail-value { color: var(--error-text); }
.warning .detail-value { color: var(--warning-text); }

/* ── Loading spinner ── */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(0,0,0,0.3);
    border-top-color: #0d1117;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes pulseSuccess {
    0%   { box-shadow: 0 0 0 0 rgba(46,160,67,0.4); }
    70%  { box-shadow: 0 0 0 12px rgba(46,160,67,0); }
    100% { box-shadow: 0 0 0 0 rgba(46,160,67,0); }
}
@keyframes pulseError {
    0%   { box-shadow: 0 0 0 0 rgba(248,81,73,0.4); }
    70%  { box-shadow: 0 0 0 12px rgba(248,81,73,0); }
    100% { box-shadow: 0 0 0 0 rgba(248,81,73,0); }
}
#result-panel.success { animation: fadeIn 0.3s ease, pulseSuccess 0.8s ease; }
#result-panel.error   { animation: fadeIn 0.3s ease, pulseError 0.8s ease; }
#result-panel.warning { animation: fadeIn 0.3s ease, pulseError 0.8s ease; }

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-default);
    flex-shrink: 0;
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    min-width: 320px;
    max-width: 420px;
    padding: 16px 20px;
    border-radius: 12px;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}
.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}
.toast.success { background: linear-gradient(135deg, #1a4a2e 0%, #0d2b1a 100%); border: 1px solid #2ea043; }
.toast.success::before { background: #3fb950; }
.toast.error { background: linear-gradient(135deg, #4a1a1a 0%, #2d1117 100%); border: 1px solid #f85149; }
.toast.error::before { background: #f85149; }
.toast.warning { background: linear-gradient(135deg, #4a3d00 0%, #2d2000 100%); border: 1px solid #d29922; }
.toast.warning::before { background: #d29922; }
.toast-icon { font-size: 1.5rem; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-weight: 700; margin-bottom: 2px; }
.toast-message { font-size: 0.85rem; opacity: 0.85; font-weight: 400; }
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255,255,255,0.3);
    animation: toastProgress 4s linear forwards;
}
.toast.fade-out { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px) scale(0.8); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(100px) scale(0.8); }
}
@keyframes toastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .input-row { flex-wrap: wrap; }
    #ticket-input { min-width: 0; flex: 1 1 120px; }
    #scanner-container { min-height: 200px; }
}
