/* ═══════════════════════════════════════════
   NOORSTAR — Neubrutalist Design System
   ═══════════════════════════════════════════ */

:root {
    --purple: #2D1B69;
    --pink: #FF1493;
    --yellow: #FFE566;
    --blue: #4355FF;
    --red: #FF4444;
    --green: #22C55E;
    --orange: #FF8C42;
    --pink-light: #FF6B9D;
    --bg: #F5F0E8;
    --card-bg: #FFFFFF;
    --text: #1A1A1A;
    --muted: #6B7280;
    --purple-light: #E8E0F5;
    --lilac: #B8A9E8;
    --border: #1A1A1A;
    --shadow: #1A1A1A;
    --gold: #D4A017;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --font-sans: 'Space Grotesk', system-ui, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── HEADER ── */
.ns-header {
    background: var(--purple);
    border-bottom: 3px solid var(--border);
    position: relative;
    overflow: hidden;
}
.ns-header canvas.ns-stars {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.ns-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}
.ns-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
.ns-logo-square {
    width: 40px;
    height: 40px;
    background: var(--pink);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
}
.ns-logo-star {
    color: #fff;
    font-size: 22px;
    line-height: 1;
}
.ns-brand-name {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 22px;
    color: #fff;
    letter-spacing: 2px;
}
.ns-brand-tagline {
    display: block;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 16px;
    color: var(--lilac);
    letter-spacing: 3px;
}
.ns-nav { display: flex; gap: 16px; }
.ns-nav-link {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--lilac);
    text-decoration: none;
    padding: 4px 8px;
}
.ns-nav-link:hover { color: #fff; text-decoration: none; }

/* ── FOOTER ── */
.ns-footer {
    background: var(--purple);
    border-top: 3px solid var(--border);
    position: relative;
    overflow: hidden;
}
.ns-footer canvas.ns-stars {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.ns-footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}
.ns-footer-brand {
    font-family: var(--font-mono);
    font-weight: 800;
    color: #fff;
    letter-spacing: 2px;
    font-size: 14px;
}
.ns-footer-text {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--lilac);
}

/* ── MAIN ── */
.ns-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

/* ── CARDS ── */
.ns-card {
    background: var(--card-bg);
    border: 3px solid var(--border);
    box-shadow: 4px 4px 0 var(--shadow);
    margin-bottom: 20px;
}
.ns-section-bar {
    background: var(--purple);
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 2px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}
.ns-section-bar::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1px);
    background-size: 16px 16px;
    pointer-events: none;
}

/* ── SEARCH FORM ── */
.ns-search-form { padding: 20px; }
.ns-form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.ns-form-group { flex: 1; min-width: 140px; }
.ns-form-group-route { flex: 2; min-width: 200px; }
.ns-label {
    display: block;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--text);
    margin-bottom: 4px;
}
.ns-input {
    width: 100%;
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 14px;
    border: 2px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    outline: none;
}
.ns-input:focus { border-color: var(--purple); box-shadow: 2px 2px 0 var(--purple); }
.ns-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.ns-input-wrap .ns-input { padding-right: 32px; }
.ns-clear-btn {
    position: absolute;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text);
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.ns-clear-btn:hover { background: var(--red); }

/* Checkboxes */
.ns-form-row-checks { align-items: flex-start; }
.ns-checkbox-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.ns-check-label {
    font-family: var(--font-mono);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.ns-check-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--purple);
}

/* Search buttons */
.ns-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}
.ns-btn {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1px;
    border: 2px solid var(--border);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    transition: transform 0.1s, box-shadow 0.1s;
}
.ns-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--shadow);
    text-decoration: none;
}
.ns-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--shadow);
}
.ns-btn-primary, .ns-btn-search {
    background: var(--purple);
    color: #fff;
    border: 3px solid var(--border);
}
.ns-btn-book {
    background: var(--purple);
    color: #fff;
    width: 100%;
}
.ns-btn-discovered {
    background: var(--blue);
    color: #fff;
    width: 100%;
}
.ns-btn-leg {
    background: var(--card-bg);
    color: var(--text);
    width: 100%;
    font-size: 12px;
}
.ns-btn-copy {
    background: var(--bg);
    color: var(--text);
    width: 100%;
    font-size: 12px;
}

/* Progress bar */
.ns-progress-bar-wrap {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.ns-progress-bar {
    flex: 1;
    height: 14px;
    background: var(--bg);
    border: 2px solid var(--border);
    overflow: hidden;
}
.ns-progress-fill {
    height: 100%;
    background: var(--green);
    transition: width 0.5s ease;
}
.ns-progress-text {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

/* ── DISRUPTION BOXES ── */
.ns-disruption-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 900px) {
    .ns-disruption-row { grid-template-columns: 1fr; }
}
.ns-disruption-box { margin-bottom: 0; }
.ns-disruption-header {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 2px;
    padding: 10px 14px;
    color: #fff;
}
.ns-disruption-header-red { background: var(--red); }
.ns-disruption-header-orange { background: var(--orange); }
.ns-disruption-header-pink { background: var(--pink-light); }
.ns-disruption-body { padding: 0; }
.ns-disruption-entry { padding: 10px 14px; }
.ns-disruption-entry-border { border-bottom: 1px solid #e5e5e5; }
.ns-disruption-entry-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ns-disruption-entry-detail {
    font-size: 12px;
    margin-top: 2px;
}
.ns-disruption-empty {
    padding: 16px 14px;
    font-size: 13px;
    text-align: center;
}

/* ── BADGES ── */
.ns-badge {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 1px;
    padding: 2px 8px;
    border: 2px solid var(--border);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.badge-red { background: var(--red); color: #fff; }
.badge-orange { background: var(--orange); color: #fff; }
.badge-yellow { background: var(--yellow); color: var(--text); }
.badge-green { background: var(--green); color: #fff; }
.badge-discovered { background: var(--blue); color: #fff; }
.badge-cabin { background: var(--purple-light); color: var(--purple); }
.badge-gold { background: var(--gold); color: #fff; }

/* ── RESULTS ── */
.ns-results-bar {
    background: var(--purple);
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 2px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 3px solid var(--border);
    border-bottom: none;
    position: relative;
    overflow: hidden;
}
.ns-results-bar::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1px);
    background-size: 16px 16px;
    pointer-events: none;
}
.ns-results-bar-title { position: relative; z-index: 1; }
.ns-results-bar-count {
    position: relative;
    z-index: 1;
    background: var(--yellow);
    color: var(--text);
    padding: 2px 10px;
    border: 2px solid var(--border);
    font-size: 13px;
}
.ns-sort-tabs {
    display: flex;
    border: 3px solid var(--border);
    border-top: none;
    background: var(--card-bg);
    margin-bottom: 16px;
}
.ns-sort-tab {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--text);
    text-decoration: none;
    border-right: 2px solid var(--border);
}
.ns-sort-tab:last-child { border-right: none; }
.ns-sort-tab:hover { background: var(--bg); text-decoration: none; }
.ns-sort-tab-active {
    background: var(--purple);
    color: #fff;
}

/* Stop section headers */
.ns-stop-header {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 2px;
    padding: 8px 16px;
    border: 2px solid var(--border);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}
.ns-stop-header-0 { background: var(--red); }
.ns-stop-header-1 { background: var(--green); }
.ns-stop-header-2 { background: var(--blue); }
.ns-stop-header-3 { background: var(--yellow); color: var(--text); }
.ns-stop-count {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.9;
}

/* ── RESULT CARD ── */
.ns-result-card { padding: 0; }
.ns-result-main {
    display: flex;
    gap: 0;
}
.ns-result-rank {
    background: var(--yellow);
    border-right: 3px solid var(--border);
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 16px 8px;
}
.ns-result-body {
    flex: 1;
    padding: 14px 16px;
    min-width: 0;
}
.ns-result-route-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.ns-route-text {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 1px;
}
.ns-route-text-lg { font-size: 22px; }
.ns-result-airlines {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}
.ns-result-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.ns-result-source { font-size: 11px; }
.ns-self-transfer-warning {
    background: var(--yellow);
    border: 2px solid var(--border);
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    margin: 6px 0;
}
.ns-result-times {
    font-family: var(--font-mono);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ns-arrow { font-size: 16px; }
.ns-muted { color: var(--muted); }
.ns-mono-bold {
    font-family: var(--font-mono);
    font-weight: 700;
}

/* Price column */
.ns-result-price-col {
    border-left: 3px solid var(--border);
    display: flex;
    flex-direction: column;
    min-width: 180px;
    max-width: 220px;
}
.ns-price-card {
    background: var(--yellow);
    padding: 14px 16px;
    text-align: center;
    border-bottom: 3px solid var(--border);
    box-shadow: inset 0 0 0 0 var(--shadow);
}
.ns-price-card-lg { padding: 20px 24px; }
.ns-price-currency {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 18px;
}
.ns-price-amount {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 28px;
    letter-spacing: -1px;
}
.ns-result-actions {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}
.ns-result-detail-link {
    display: block;
    text-align: center;
    padding: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--purple);
    border-top: 2px solid var(--border);
}
.ns-result-detail-link:hover { background: var(--bg); text-decoration: none; }

/* ── SEARCH STATUS ── */
.ns-status-panel { margin-bottom: 20px; }
.ns-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0;
    padding: 0;
}
.ns-status-item {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
    border-right: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ns-status-label {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--muted);
}
.ns-status-value {
    font-family: var(--font-mono);
    font-size: 13px;
}
.ns-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.ns-status-dot-done { background: var(--green); }
.ns-status-dot-fail { background: var(--red); }
.ns-status-dot-running {
    background: var(--green);
    animation: pulse 1s infinite alternate;
}
@keyframes pulse {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.4; transform: scale(0.8); }
}
.ns-status-summary {
    background: var(--yellow);
    padding: 10px 16px;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 1px;
    border-top: 2px solid var(--border);
}
.ns-status-error {
    background: var(--red);
    color: #fff;
    padding: 8px 16px;
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ── FLIGHT DETAIL ── */
.ns-flight-detail { max-width: 900px; margin: 0 auto; }
.ns-back-link {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 16px;
    color: var(--purple);
}
.ns-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 16px;
}
.ns-detail-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 16px 12px;
}
.ns-detail-legs { padding: 0 16px 16px; }
.ns-leg-card {
    border: 2px solid var(--border);
    margin-bottom: 8px;
}
.ns-leg-header {
    background: var(--purple-light);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 2px;
    padding: 6px 12px;
    color: var(--purple);
}
.ns-leg-body { padding: 12px; }
.ns-leg-route {
    font-family: var(--font-mono);
    font-size: 16px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ns-leg-info { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.ns-leg-times {
    font-family: var(--font-mono);
    font-size: 12px;
    display: flex;
    gap: 16px;
}
.ns-layover-info {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
    padding: 4px 0;
}
.ns-detail-summary {
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.ns-detail-price-section {
    padding: 16px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.ns-detail-actions {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}

/* Price history table */
.ns-price-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 13px;
}
.ns-price-table th {
    text-align: left;
    padding: 8px 14px;
    background: var(--bg);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--border);
}
.ns-price-table td {
    padding: 8px 14px;
    border-bottom: 1px solid #e5e5e5;
}

/* ── EMPTY STATE ── */
.ns-empty-state {
    padding: 40px 24px;
    text-align: center;
    color: var(--muted);
}
.ns-empty-state .ns-mono { font-family: var(--font-mono); }

/* ── BUDGET BAR ── */
.ns-budget-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    margin-bottom: 16px;
}
.ns-budget-meter {
    flex: 1;
    height: 10px;
    background: var(--bg);
    border: 2px solid var(--border);
    overflow: hidden;
    max-width: 200px;
}
.ns-budget-fill {
    height: 100%;
    background: var(--purple);
    transition: width 0.3s ease;
}

/* ── DISRUPTION TIMESTAMP ── */
.ns-disruption-timestamp {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

/* ── REFRESH BUTTON (in disruption headers) ── */
.ns-disruption-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ns-refresh-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    line-height: 1;
}
.ns-refresh-btn:hover {
    opacity: 1;
    transform: rotate(90deg);
}

/* ── HTMX INDICATOR ── */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .ns-result-main { flex-direction: column; }
    .ns-result-price-col {
        border-left: none;
        border-top: 3px solid var(--border);
        max-width: 100%;
        min-width: 0;
    }
    .ns-result-rank {
        border-right: none;
        border-bottom: 3px solid var(--border);
        min-width: 0;
        padding: 8px 16px;
    }
    .ns-form-row { flex-direction: column; gap: 12px; }
    .ns-form-group-route { flex: unset; min-width: 0; }
    .ns-form-group { flex: unset; min-width: 0; }
    .ns-header-inner { flex-direction: column; gap: 10px; }
    .ns-sort-tabs { flex-wrap: wrap; }
    .ns-main { padding: 12px; }
    .ns-card { margin-bottom: 12px; }
    .ns-results-bar { font-size: 12px; padding: 10px 12px; }
    .ns-detail-price-section { flex-direction: column; }
    .ns-footer-inner { flex-direction: column; gap: 6px; text-align: center; }
    .ns-budget-bar { flex-direction: column; gap: 6px; }
    .ns-form-actions { flex-direction: column; }
    .ns-btn-search { width: 100%; }
}
