/* =========================================================
   Astro Observer - Stylesheet
   Dark space theme, fully responsive
   ========================================================= */

/* Google Font import */
@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@300;400;600;700&family=Space+Mono:wght@400;700&display=swap');

/* =========================================================
   CSS Variables
   ========================================================= */
.astro-observer-wrap {
    --astro-bg: #0b0e1a;
    --astro-bg-2: #111828;
    --astro-bg-3: #1a2235;
    --astro-border: rgba(100, 160, 255, 0.18);
    --astro-accent: #4fc3f7;
    --astro-accent-2: #7c4dff;
    --astro-accent-gold: #ffd54f;
    --astro-text: #dde8f8;
    --astro-text-muted: #7a95bb;
    --astro-sunrise: #ffab40;
    --astro-sunset: #ef5350;
    --astro-moonrise: #80cbc4;
    --astro-moonset: #7986cb;
    --astro-twilight: #9575cd;
    --astro-green: #69f0ae;
    --astro-red: #ff5252;
    --astro-radius: 12px;
    --astro-radius-sm: 8px;
    --astro-shadow: 0 4px 32px rgba(0,0,0,0.5);
    --astro-font: 'Exo 2', 'Segoe UI', sans-serif;
    --astro-mono: 'Space Mono', 'Courier New', monospace;
}

/* =========================================================
   Wrapper
   ========================================================= */
.astro-observer-wrap {
    font-family: var(--astro-font);
    background: var(--astro-bg);
    color: var(--astro-text);
    border-radius: var(--astro-radius);
    padding: 0;
    overflow: hidden;
    box-shadow: var(--astro-shadow), 0 0 0 1px var(--astro-border);
    max-width: 100%;
    position: relative;
}

/* Starfield background */
.astro-observer-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 15% 20%, rgba(79,195,247,0.05) 0%, transparent 50%),
        radial-gradient(circle at 85% 80%, rgba(124,77,255,0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.astro-observer-wrap > * {
    position: relative;
    z-index: 1;
}

/* =========================================================
   Header
   ========================================================= */
.astro-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 28px 20px;
    border-bottom: 1px solid var(--astro-border);
    background: linear-gradient(135deg, rgba(79,195,247,0.08) 0%, transparent 60%);
}

.astro-logo {
    width: 48px;
    height: 48px;
    color: var(--astro-accent);
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(79,195,247,0.5));
}

.astro-title {
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: 700;
    margin: 0 0 2px;
    color: #fff;
    letter-spacing: 0.04em;
    background: linear-gradient(135deg, #fff, var(--astro-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.astro-subtitle {
    font-size: 0.82rem;
    color: var(--astro-text-muted);
    margin: 0;
    font-weight: 300;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* =========================================================
   Controls
   ========================================================= */
.astro-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    padding: 20px 28px;
    background: var(--astro-bg-2);
    border-bottom: 1px solid var(--astro-border);
}

.astro-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 220px;
}

.astro-days-group {
    flex: 0 1 130px;
}

.astro-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--astro-text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.astro-input,
.astro-select {
    background: var(--astro-bg-3);
    border: 1px solid var(--astro-border);
    border-radius: var(--astro-radius-sm);
    color: var(--astro-text);
    font-family: var(--astro-font);
    font-size: 0.95rem;
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.astro-input:focus,
.astro-select:focus {
    border-color: var(--astro-accent);
    box-shadow: 0 0 0 3px rgba(79,195,247,0.15);
}

.astro-input::placeholder {
    color: var(--astro-text-muted);
}

.astro-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234fc3f7' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.astro-btn-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--astro-accent), var(--astro-accent-2));
    color: #fff;
    border: none;
    border-radius: var(--astro-radius-sm);
    padding: 10px 22px;
    font-family: var(--astro-font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
    letter-spacing: 0.03em;
    white-space: nowrap;
    align-self: flex-end;
    box-shadow: 0 2px 12px rgba(79,195,247,0.25);
}

.astro-btn-search:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(79,195,247,0.35);
}

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

/* =========================================================
   Status
   ========================================================= */
.astro-status {
    padding: 14px 28px;
    font-size: 0.9rem;
    text-align: center;
}

.astro-status--loading {
    color: var(--astro-accent);
    animation: astro-pulse 1.5s ease-in-out infinite;
}

.astro-status--error {
    color: var(--astro-red);
    background: rgba(255,82,82,0.08);
}

@keyframes astro-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* =========================================================
   Results container
   ========================================================= */
.astro-results {
    padding: 0;
}

.astro-location-badge {
    padding: 10px 28px;
    font-size: 0.82rem;
    color: var(--astro-accent);
    background: rgba(79,195,247,0.06);
    border-bottom: 1px solid var(--astro-border);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.astro-location-badge small {
    color: var(--astro-text-muted);
    font-weight: 400;
}

/* =========================================================
   Sections
   ========================================================= */
.astro-section {
    border-bottom: 1px solid var(--astro-border);
}

.astro-section:last-child {
    border-bottom: none;
}

.astro-section-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 28px 16px;
    background: linear-gradient(90deg, rgba(79,195,247,0.04) 0%, transparent 100%);
    border-bottom: 1px solid var(--astro-border);
}

.astro-section-imgs {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.astro-section-imgs--planets {
    gap: 4px;
}

.astro-header-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--astro-border);
    box-shadow: 0 0 12px rgba(0,0,0,0.6);
    transition: transform 0.3s, box-shadow 0.3s;
}

.astro-header-img:hover {
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(79,195,247,0.3);
}

.astro-header-img--sm {
    width: 42px;
    height: 42px;
}

.astro-header-img--wide {
    width: 90px;
    height: 60px;
    border-radius: var(--astro-radius-sm);
    object-fit: contain;
    background: #0a0d16;
}

.astro-section-title {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-weight: 700;
    margin: 0 0 4px;
    color: #fff;
    letter-spacing: 0.02em;
}

.astro-section-desc {
    font-size: 0.8rem;
    color: var(--astro-text-muted);
    margin: 0;
}

/* =========================================================
   Tables
   ========================================================= */
.astro-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 28px 20px;
}

.astro-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 580px;
}

.astro-table th {
    background: rgba(79,195,247,0.08);
    color: var(--astro-accent);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--astro-border);
    white-space: nowrap;
}

.astro-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(100,160,255,0.08);
    color: var(--astro-text);
    vertical-align: middle;
}

.astro-table tbody tr:hover td {
    background: rgba(79,195,247,0.04);
}

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

.th-icon {
    margin-right: 4px;
}

/* Specialized cell colors */
.astro-time-cell {
    font-family: var(--astro-mono);
    font-size: 0.92rem;
    letter-spacing: 0.03em;
}

.astro-date-cell {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
}

.astro-twilight { color: var(--astro-twilight) !important; }
.astro-sunrise  { color: var(--astro-sunrise) !important; }
.astro-sunset   { color: var(--astro-sunset) !important; }
.astro-moonrise { color: var(--astro-moonrise) !important; }
.astro-moonset  { color: var(--astro-moonset) !important; }

.astro-phase-cell {
    font-size: 0.85rem;
    line-height: 1.5;
}

.astro-illum {
    color: var(--astro-text-muted);
    font-size: 0.78rem;
}

.astro-alt-cell {
    font-family: var(--astro-mono);
    color: var(--astro-accent-gold);
}

/* =========================================================
   Planet filter pills
   ========================================================= */
.astro-planet-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: rgba(79,195,247,0.03);
    border-bottom: 1px solid var(--astro-border);
}

.astro-filter-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--astro-text-muted);
    font-weight: 600;
    margin-right: 4px;
    flex-shrink: 0;
}

.astro-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 13px;
    border-radius: 20px;
    border: 1px solid var(--astro-border);
    background: transparent;
    color: var(--astro-text-muted);
    font-family: var(--astro-font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
    white-space: nowrap;
}

.astro-pill:hover {
    border-color: var(--pill-color, var(--astro-accent));
    color: var(--pill-color, var(--astro-accent));
    background: rgba(255,255,255,0.04);
}

.astro-pill--active {
    background: rgba(79,195,247,0.12);
    border-color: var(--pill-color, var(--astro-accent));
    color: var(--pill-color, var(--astro-accent));
    box-shadow: 0 0 8px rgba(79,195,247,0.15);
}

/* =========================================================
   Planet multi-day blocks
   ========================================================= */
.astro-planet-block {
    border-bottom: 1px solid var(--astro-border);
    animation: astro-fade-in 0.3s ease;
}

.astro-planet-block:last-child {
    border-bottom: none;
}

.astro-planet-block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 28px 8px;
    background: rgba(255,255,255,0.02);
}

.planet-symbol-lg {
    font-size: 1.5rem;
    line-height: 1;
    filter: drop-shadow(0 0 6px currentColor);
}

.planet-name-lg {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.04em;
}

.astro-table--planets {
    min-width: 560px;
}

@media (max-width: 700px) {
    .astro-planet-filters {
        padding: 12px 16px;
        gap: 6px;
    }

    .astro-pill {
        font-size: 0.76rem;
        padding: 4px 10px;
    }

    .astro-planet-block-header {
        padding: 10px 16px 6px;
    }
}

/* =========================================================
   Planet filter pills
.astro-planet-cell {
    white-space: nowrap;
}

.planet-symbol {
    font-size: 1.1rem;
    font-weight: 700;
    margin-right: 4px;
}

/* =========================================================
   Direction / Compass
   ========================================================= */
.astro-dir {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--astro-mono);
    font-size: 0.82rem;
    color: var(--astro-text-muted);
}

.compass-arrow {
    color: var(--astro-accent);
    transition: transform 0.3s;
}

/* =========================================================
   Visibility badges
   ========================================================= */
.astro-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.astro-badge--visible {
    background: rgba(105,240,174,0.12);
    color: var(--astro-green);
    border: 1px solid rgba(105,240,174,0.25);
}

.astro-badge--hidden {
    background: rgba(255,82,82,0.08);
    color: var(--astro-red);
    border: 1px solid rgba(255,82,82,0.2);
}

/* =========================================================
   ISS section
   ========================================================= */
.astro-iss-day {
    border-bottom: 1px solid var(--astro-border);
    padding: 16px 28px;
}

.astro-iss-day:last-child {
    border-bottom: none;
}

.astro-iss-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--astro-accent-gold);
    margin: 0 0 12px;
    letter-spacing: 0.03em;
}

.astro-table--iss {
    min-width: 480px;
}

.astro-no-pass {
    padding: 14px 0;
    color: var(--astro-text-muted);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.no-pass-icon {
    font-size: 1.1rem;
}

/* =========================================================
   Responsive — layout général
   ========================================================= */
@media (max-width: 700px) {
    .astro-header {
        padding: 16px 14px 12px;
        gap: 10px;
    }
    .astro-logo { width: 34px; height: 34px; }

    .astro-controls {
        padding: 12px 14px;
        gap: 10px;
    }
    .astro-input-group  { flex: 1 1 100%; }
    .astro-days-group   { flex: 0 1 120px; }
    .astro-btn-search   { flex: 1 1 auto; justify-content: center; }

    .astro-section-header {
        padding: 12px 14px 10px;
        gap: 10px;
        flex-wrap: wrap;
    }
    .astro-header-img       { width: 40px; height: 40px; }
    .astro-header-img--sm   { width: 28px; height: 28px; }
    .astro-header-img--wide { width: 60px; height: 40px; }

    .astro-location-badge { padding: 8px 14px; }

    .astro-planet-filters { padding: 10px 14px; gap: 6px; }
    .astro-pill           { font-size: 0.74rem; padding: 4px 9px; }

    .astro-planet-block-header { padding: 10px 14px 6px; }
    .astro-iss-day             { padding: 10px 14px; }
}

@media (max-width: 480px) {
    .astro-section-imgs    { display: none; }
    .astro-section-title   { font-size: 1rem; }
}

/* =========================================================
   Responsive — cartes mobiles (tableaux → cartes 4 lignes)

   Principe : on masque thead, et chaque <tr> devient une carte.
   Chaque <td> affiche son label via data-label + ::before.
   Les données sont regroupées en 4 rangées visuelles via
   une grille 2 colonnes à l'intérieur de chaque carte.
   ========================================================= */
@media (max-width: 700px) {

    /* --- Wrapper : plus de scroll horizontal, plus de min-width --- */
    .astro-table-wrap {
        overflow-x: visible;
        padding: 10px 14px 14px;
    }

    .astro-table,
    .astro-table tbody,
    .astro-table tr {
        display: block;
        width: 100%;
    }

    /* Cacher les en-têtes */
    .astro-table thead {
        display: none;
    }

    /* Chaque ligne = une carte */
    .astro-table tbody tr {
        background: var(--astro-bg-3);
        border: 1px solid var(--astro-border);
        border-radius: var(--astro-radius-sm);
        margin-bottom: 10px;
        padding: 10px 12px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0;
        position: relative;
    }

    .astro-table tbody tr:last-child {
        margin-bottom: 0;
    }

    /* Toutes les cellules : affichage flex avec label au-dessus */
    .astro-table td {
        display: flex;
        flex-direction: column;
        padding: 5px 6px;
        border: none;
        font-size: 0.85rem;
        background: transparent !important;
    }

    /* Label au-dessus de la valeur */
    .astro-table td::before {
        content: attr(data-label);
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--astro-text-muted);
        font-weight: 600;
        margin-bottom: 2px;
        font-family: var(--astro-font);
    }

    /* --- Soleil/Lune : 8 colonnes → 4 rangées × 2 colonnes --- */
    /* Date : pleine largeur, ligne 1 */
    .astro-table:not(.astro-table--iss):not(.astro-table--planets) td.astro-date-cell {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        border-bottom: 1px solid var(--astro-border);
        padding-bottom: 8px;
        margin-bottom: 2px;
        font-size: 0.9rem;
    }
    .astro-table:not(.astro-table--iss):not(.astro-table--planets) td.astro-date-cell::before {
        display: none;
    }

    /* Ligne 2 : aube astro + lever soleil */
    /* Ligne 3 : coucher soleil + crépuscule */
    /* Ligne 4 : lever lune + coucher lune */
    /* Ligne 5 : phase lune (pleine largeur) */
    .astro-table:not(.astro-table--iss):not(.astro-table--planets) td.astro-phase-cell {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        border-top: 1px solid var(--astro-border);
        margin-top: 2px;
        padding-top: 8px;
    }
    .astro-table:not(.astro-table--iss):not(.astro-table--planets) td.astro-phase-cell::before {
        display: none;
    }
    .astro-table:not(.astro-table--iss):not(.astro-table--planets) td.astro-phase-cell br {
        display: none;
    }
    .astro-table:not(.astro-table--iss):not(.astro-table--planets) td.astro-phase-cell .astro-illum {
        margin-left: 6px;
        opacity: 0.7;
    }

    /* --- Planètes : 7 colonnes → carte par date --- */
    .astro-table--planets tbody tr {
        grid-template-columns: 1fr 1fr;
    }

    /* Date : ligne pleine */
    .astro-table--planets td.astro-date-cell {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        border-bottom: 1px solid var(--astro-border);
        padding-bottom: 8px;
        margin-bottom: 2px;
        font-size: 0.88rem;
    }
    .astro-table--planets td.astro-date-cell::before { display: none; }

    /* Visible : ligne pleine, en bas */
    .astro-table--planets td.astro-visible-cell {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        border-top: 1px solid var(--astro-border);
        margin-top: 2px;
        padding-top: 8px;
    }

    /* --- ISS : 6 colonnes → 3 rangées × 2 colonnes --- */
    .astro-table--iss tbody tr {
        grid-template-columns: 1fr 1fr;
    }
}

/* =========================================================
   Scrollbar styling for dark theme
   ========================================================= */
.astro-table-wrap::-webkit-scrollbar {
    height: 4px;
}

.astro-table-wrap::-webkit-scrollbar-track {
    background: var(--astro-bg-3);
}

.astro-table-wrap::-webkit-scrollbar-thumb {
    background: var(--astro-border);
    border-radius: 2px;
}

.astro-table-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--astro-accent);
}

/* =========================================================
   Fade-in animation for results
   ========================================================= */
#astro-results {
    animation: astro-fade-in 0.4s ease;
}

@keyframes astro-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.astro-section {
    animation: astro-fade-in 0.5s ease both;
}

.astro-section:nth-child(1) { animation-delay: 0.05s; }
.astro-section:nth-child(2) { animation-delay: 0.12s; }
.astro-section:nth-child(3) { animation-delay: 0.20s; }
