/* =============================================================================
   Travel App — CSS custom properties and component styles
   Uses Pico CSS (loaded from CDN in each HTML page) as the base.
   ============================================================================= */

:root {
    --hero-bg: #1e293b;
    --hero-text: #f8fafc;
    --hero-muted: #94a3b8;

    --badge-draft-bg:      #e5e7eb;
    --badge-draft-text:    #374151;
    --badge-ready-bg:      #dbeafe;
    --badge-ready-text:    #1d4ed8;
    --badge-validated-bg:  #dcfce7;
    --badge-validated-text:#15803d;
    --badge-done-bg:       #f3f4f6;
    --badge-done-text:     #6b7280;
    --badge-postponed-bg:  #fef3c7;
    --badge-postponed-text:#b45309;

    --warning-amber:       #d97706;
    --color-stale:         #9ca3af;
    --pool-sidebar-width:  260px;
}

/* ---- Status badges ---- */
.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.badge-DRAFT     { background: var(--badge-draft-bg);     color: var(--badge-draft-text); }
.badge-READY     { background: var(--badge-ready-bg);     color: var(--badge-ready-text); }
.badge-VALIDATED { background: var(--badge-validated-bg); color: var(--badge-validated-text); }
.badge-DONE      { background: var(--badge-done-bg);      color: var(--badge-done-text); }
.badge-POSTPONED { background: var(--badge-postponed-bg); color: var(--badge-postponed-text); }

/* ---- Hero bar ---- */
.trip-hero {
    background: var(--hero-bg);
    color: var(--hero-text);
    padding: 1.5rem 2rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.trip-hero h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    color: var(--hero-text);
    border: none;
}

.trip-hero .stats {
    font-family: monospace;
    color: var(--hero-muted);
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.trip-hero .hero-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ---- Trip dashboard layout ---- */
.trip-layout {
    display: grid;
    grid-template-columns: 1fr var(--pool-sidebar-width);
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 768px) {
    .trip-layout {
        grid-template-columns: 1fr;
    }
}

/* ---- Pool sidebar ---- */
.pool-sidebar {
    border: 1px solid var(--pico-muted-border-color, #e2e8f0);
    border-radius: 0.5rem;
    padding: 1rem;
}

.pool-sidebar h3 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--hero-muted);
}

/* ---- Alternative tabs ---- */
.alt-tabs {
    display: flex;
    gap: 0.25rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    border-bottom: 2px solid var(--pico-muted-border-color, #e2e8f0);
    margin-bottom: 1rem;
    padding-bottom: 0;
}

.alt-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    color: inherit;
}

.alt-tab[aria-selected="true"] {
    border-bottom-color: var(--pico-primary, #2563eb);
    font-weight: 600;
}

/* ---- City row ---- */
.city-row {
    display: grid;
    grid-template-columns: 24px 2rem 1fr 10rem 1fr auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.25rem;
    border-bottom: 1px solid var(--pico-muted-border-color, #f1f5f9);
}

.drag-handle {
    cursor: grab;
    color: var(--hero-muted);
    font-size: 1.1rem;
    line-height: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

.city-position {
    font-size: 0.75rem;
    color: var(--hero-muted);
    text-align: right;
}

/* ---- Consecutive-city warning ---- */
.warning-consecutive {
    color: var(--warning-amber);
    font-size: 0.8rem;
    margin: 0.1rem 0 0.25rem 2rem;
}

/* ---- Inline date editor ---- */
.city-date-display {
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
}

.city-date-display:hover {
    background: var(--pico-muted-background, #f1f5f9);
}

/* ---- CitySearchDropdown ---- */
.city-search-wrapper {
    position: relative;
    margin-bottom: 0.75rem;
}

.city-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--pico-muted-border-color, #e2e8f0);
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
}

.city-search-results li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.city-search-results li:hover,
.city-search-results li[aria-selected="true"] {
    background: var(--pico-primary-background, #eff6ff);
}

.city-search-results .no-results {
    color: var(--hero-muted);
    cursor: default;
    font-style: italic;
}

.rate-limit-msg {
    color: var(--warning-amber);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ---- Form helpers ---- */
.form-error {
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ---- Leg row ---- */
.leg-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    color: var(--hero-muted);
    border-bottom: 1px dashed var(--pico-muted-border-color, #f1f5f9);
    font-family: monospace;
}

.leg-error {
    color: #dc2626;
    font-family: inherit;
    font-style: italic;
}

/* ---- City row rain state ---- */
.city-row--rain {
    background: #fffbeb;
    border-left: 3px solid var(--warning-amber);
}

/* ---- Loading indicators (bulk refresh) ---- */
.city-row--loading {
    opacity: 0.5;
    animation: pulse-loading 1.2s ease-in-out infinite;
}

.leg-row--loading {
    opacity: 0.4;
    animation: pulse-loading 1.2s ease-in-out infinite;
}

@keyframes pulse-loading {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* ---- Weather badge ---- */
.city-weather {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.weather-badge {
    font-size: 0.78rem;
    font-family: monospace;
    color: var(--hero-muted);
    white-space: nowrap;
}

.weather-badge--rain {
    color: var(--warning-amber);
    font-weight: 600;
}

.weather-badge--no-data {
    color: var(--hero-muted);
    font-style: italic;
}

/* ---- Source tag ---- */
.source-tag {
    font-size: 0.7rem;
    padding: 0.1em 0.4em;
    border-radius: 0.25rem;
    white-space: nowrap;
}

.source-tag--forecast {
    background: #dbeafe;
    color: #1d4ed8;
}

.source-tag--normal {
    background: #f3f4f6;
    color: #6b7280;
}

/* ---- Staleness indicator ---- */
.staleness-indicator {
    font-size: 0.68rem;
    color: var(--color-stale, #9ca3af);
    display: block;
    margin-top: 0.1rem;
}

.staleness-indicator--stale {
    color: var(--warning-amber);
}

/* ---- Per-city refresh button ---- */
.per-city-refresh-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.1rem 0.25rem;
    opacity: 0.6;
    line-height: 1;
}

.per-city-refresh-btn:hover {
    opacity: 1;
}

/* ---- Map ---- */
.map-city-marker {
    width: 26px;
    height: 26px;
    background: #4f46e5;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    border: 2px solid #fff;
    box-shadow: 0 1px 5px rgba(0,0,0,0.45);
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--hero-muted);
}

.empty-state p {
    margin-bottom: 1rem;
}

/* City Notes */
.notes-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    font-size: 0.9rem;
    opacity: 0.4;
}
.notes-btn--active {
    opacity: 1;
}
.notes-btn:hover {
    opacity: 1;
}
.notes-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
}
.notes-panel--open {
    display: flex;
    align-items: center;
    justify-content: center;
}
.notes-panel-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
}
.notes-panel-content {
    position: relative;
    background: var(--card-background-color, #fff);
    border-radius: 8px;
    padding: 1.5rem;
    width: min(90vw, 32rem);
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1;
}
.notes-panel-content label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    display: block;
}
.notes-panel-content textarea {
    width: 100%;
    resize: vertical;
}
