/* ===== Design Tokens ===== */
:root {
    --bg-primary: #0a0b0f;
    --bg-secondary: #12141c;
    --bg-card: rgba(18, 20, 30, 0.85);
    --bg-card-hover: rgba(24, 27, 40, 0.9);
    --bg-input: rgba(255, 255, 255, 0.04);
    --bg-input-focus: rgba(255, 255, 255, 0.07);

    --text-primary: #e8eaf0;
    --text-secondary: #8b90a0;
    --text-muted: #5c6070;

    --accent: #7c5cfc;
    --accent-light: #9d83ff;
    --accent-dark: #5a3fcc;
    --accent-glow: rgba(124, 92, 252, 0.25);

    --success: #22c997;
    --success-bg: rgba(34, 201, 151, 0.1);
    --error: #f5475b;
    --error-bg: rgba(245, 71, 91, 0.1);

    --border: rgba(255, 255, 255, 0.06);
    --border-active: rgba(124, 92, 252, 0.4);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 40px var(--accent-glow);

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Animated BG gradient */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(124, 92, 252, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(34, 201, 151, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-5%, -3%); }
}

/* ===== App Layout ===== */
.app {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 24px 16px 60px;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    text-align: center;
    padding: 40px 0 32px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo svg {
    color: var(--accent);
    filter: drop-shadow(0 0 12px var(--accent-glow));
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.08);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.card-header svg {
    color: var(--accent);
    opacity: 0.8;
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 12px 16px;
    transition: all var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b90a0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form-group select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* Cookie toggle */
.toggle-cookie-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: transform var(--transition), color var(--transition);
}

.toggle-cookie-btn:hover {
    color: var(--accent);
}

.toggle-cookie-btn.rotated {
    transform: rotate(180deg);
}

.cookie-wrapper {
    transition: max-height 0.4s ease, opacity 0.3s ease;
    max-height: 200px;
    opacity: 1;
    overflow: hidden;
}

.cookie-wrapper.collapsed {
    max-height: 0;
    opacity: 0;
}

.hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ===== Button ===== */
.btn-primary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    margin-top: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
    opacity: 0;
    transition: opacity var(--transition);
}

.btn-primary:hover::before {
    opacity: 1;
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== Loading ===== */
.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 24px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== Error ===== */
.error-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--error-bg);
    border-color: rgba(245, 71, 91, 0.15);
}

.error-icon {
    flex-shrink: 0;
    color: var(--error);
}

.error-card p {
    color: var(--error);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ===== Result ===== */
.event-info {
    margin-bottom: 20px;
}

.event-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Cheapest ticket */
.cheapest-ticket {
    background: linear-gradient(135deg, rgba(124, 92, 252, 0.08), rgba(34, 201, 151, 0.06));
    border: 1px solid rgba(124, 92, 252, 0.15);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.cheapest-ticket::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--success));
}

.cheapest-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-light);
    margin-bottom: 8px;
}

.cheapest-price {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--success);
    letter-spacing: -0.02em;
    line-height: 1.2;
    transition: transform 0.3s ease;
}

.cheapest-price.pulse {
    animation: pricePulse 0.6s ease;
}

@keyframes pricePulse {
    0% { transform: scale(0.85); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.cheapest-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Listings table */
.listings-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.listings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.listings-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.listings-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.listings-table tr:last-child td {
    border-bottom: none;
}

.listings-table tr.cheapest-row td {
    color: var(--success);
    font-weight: 600;
}

.price-cell {
    font-weight: 600;
    color: var(--text-primary) !important;
    font-variant-numeric: tabular-nums;
}

.listings-table tr.cheapest-row .price-cell {
    color: var(--success) !important;
}

.discount-tag {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--success);
    background: var(--success-bg);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.listings-table tr {
    transition: background var(--transition);
}

.listings-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ===== History ===== */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.history-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.history-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-light);
    flex-shrink: 0;
    margin-left: 16px;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 24px 0;
}

.footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== Responsive ===== */
@media (max-width: 520px) {
    .app {
        padding: 16px 12px 48px;
    }

    .header {
        padding: 24px 0 20px;
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .card {
        padding: 18px;
        border-radius: var(--radius-md);
    }

    .cheapest-price {
        font-size: 2rem;
    }

    .listings-table {
        font-size: 0.8rem;
    }

    .listings-table th,
    .listings-table td {
        padding: 8px;
    }
}
