/* ===== ROOT (TEMA CLARO COM TONS DE CINZA E LARANJA) ===== */
:root {
    --bg: #e8eaed;
    --bg-card: #f5f6f8;
    --surface: rgba(245, 246, 248, 0.92);
    --hover: #ecedf0;
    --border: rgba(0, 0, 0, 0.07);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text: #1e1e1e;
    --text2: #2c2c2c;
    --text3: #4a4a4a;
    --muted: #6e6e6e;
    --accent: #e67e22;
    --accent-hover: #d35400;
    --accent-glow: rgba(230, 126, 34, 0.15);
    --accent-dim: rgba(230, 126, 34, 0.07);
    --good: #27ae60;
    --bad: #e74c3c;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.08);
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
    padding: 20px;
}

/* ===== TIPOGRAFIA ===== */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent-hover); }

i[data-lucide], svg.lucide {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    stroke: currentColor;
}

/* ===== HEADER ===== */
.app-header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 24px;
    margin-bottom: 24px;
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    box-shadow: var(--shadow-sm);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo-accent {
    color: var(--accent);
}

.app-header .sub {
    font-size: 0.85rem;
    color: var(--muted);
    max-width: 520px;
    margin-top: 2px;
}

.badge-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 4px 14px;
    border-radius: var(--radius-full);
    color: var(--muted);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
}

.badge.accent {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

/* ===== LAYOUT PRINCIPAL ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    max-width: 1440px;
    margin: 0 auto;
}

.main-col { min-width: 0; }

.side-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ===== CARDS ===== */
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.info-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.info-card h3 {
    font-size: 0.85rem;
    color: var(--text2);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.info-card h3 i {
    color: var(--accent);
}

.card-desc {
    font-size: 0.75rem;
    color: var(--text3);
    margin-bottom: 10px;
}

.source-note {
    font-size: 0.65rem;
    color: var(--muted);
    margin-top: 8px;
    margin-bottom: 0;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.stat-unit {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--muted);
}

.stat-change {
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 2px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive { color: var(--bad); }
.stat-change.negative { color: var(--good); }
.stat-change.neutral { color: var(--muted); }
.stat-change.unavailable { color: var(--muted); font-style: italic; }

.stat-note {
    font-size: 0.6rem;
    color: var(--muted);
    margin-top: 4px;
    line-height: 1.4;
}

/* ===== LOCATION BAR ===== */
.location-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    margin-bottom: 16px;
}

#locationLabel {
    color: var(--muted);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.search-wrap {
    position: relative;
    flex: 1;
    max-width: 380px;
    min-width: 180px;
}

.search-wrap form {
    display: flex;
    gap: 6px;
}

.search-wrap input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 8px 16px;
    font-size: 0.8rem;
    color: var(--text);
    font-family: var(--font);
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-search {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-full);
    padding: 0 16px;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.btn-search:hover {
    background: var(--accent-hover);
}

.btn-search:active {
    transform: scale(0.95);
}

.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    z-index: 1200;
    overflow: hidden;
    max-height: 280px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.search-results .result-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text);
    transition: background 0.15s;
}

.search-results .result-item:hover {
    background: var(--accent-dim);
}

.search-results .result-item .name {
    font-weight: 600;
}

.search-results .result-item .extra {
    color: var(--muted);
}

/* ===== MAPA ===== */
.map-section {
    margin-bottom: 4px;
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.map-wrapper {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    height: 540px;
    background: #d0d4da;
    box-shadow: var(--shadow-sm);
}

#climateMap {
    width: 100%;
    height: 100%;
}

.map-controls-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 1000;
    pointer-events: none;
}

.map-controls-overlay > * {
    pointer-events: auto;
}

.zoom-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text2);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

.zoom-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.map-controls-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0 6px;
}

.map-controls-wrapper .btn-layer {
    padding: 5px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font);
    box-shadow: var(--shadow-sm);
}

.map-controls-wrapper .btn-layer:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.map-controls-wrapper .btn-layer.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-refresh {
    border-radius: var(--radius-full) !important;
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
    color: var(--accent) !important;
    padding: 5px 16px !important;
    box-shadow: var(--shadow-sm);
}

.btn-refresh:hover {
    background: var(--accent);
    color: #fff !important;
    border-color: var(--accent);
}

.btn-refresh:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-refresh.small {
    padding: 3px 12px !important;
    font-size: 0.62rem;
}

.map-instructions {
    font-size: 0.68rem;
    color: var(--muted);
    padding: 4px 0 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    align-items: center;
}

#lastUpdateDisplay {
    color: var(--muted);
    font-size: 0.6rem;
}

/* ===== CO₂ ===== */
.co2-display {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== TIMELINE ===== */
.timeline-desc {
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 10px;
}

.timeline-scrubber {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 4px 12px;
    scroll-snap-type: x proximity;
}

.timeline-stop {
    flex: 0 0 auto;
    width: 180px;
    scroll-snap-align: start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    box-shadow: var(--shadow-sm);
}

.timeline-stop:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.timeline-stop.active {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.timeline-stop .ts-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.timeline-stop .ts-year {
    font-size: 0.6rem;
    color: var(--accent);
    font-weight: 600;
}

.timeline-stop .ts-place {
    font-size: 0.62rem;
    color: var(--muted);
    margin-top: 2px;
}

.timeline-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.timeline-detail p {
    font-size: 0.8rem;
    color: var(--text2);
    margin-bottom: 6px;
}

.timeline-progress {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}

.timeline-progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.2s linear;
}

/* ===== FAVORITOS ===== */
#favoritesList {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.favorite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    box-shadow: var(--shadow-sm);
}

.favorite-item .fav-remove {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.favorite-item .fav-remove:hover {
    color: var(--bad);
    background: rgba(231, 76, 60, 0.08);
}

/* ===== ALERTAS ===== */
#alertsStatus {
    font-size: 0.7rem;
    color: var(--muted);
    margin-left: 10px;
}

/* ===== SIDE COLUMN ITEMS ===== */
.api-status-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.api-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text3);
    padding: 3px 0;
}

.api-status-item .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.api-status-item .status-dot.online {
    background: var(--good);
}

.api-status-item .status-dot.offline {
    background: var(--bad);
}

.api-status-item .status-dot.checking {
    background: var(--muted);
}

.status-online { color: var(--good); }
.status-offline { color: var(--bad); }
.status-checking { color: var(--muted); }

.country-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.country-chip {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.68rem;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    box-shadow: var(--shadow-sm);
}

.country-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.country-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

.trace-sector-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.trace-sector-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    color: var(--text2);
    border-bottom: 1px dashed var(--border);
    padding-bottom: 3px;
}

.trace-sector-row span:last-child {
    font-weight: 600;
}

/* ===== NOTÍCIAS ===== */
#newsList {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.news-item {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    text-decoration: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}

.news-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.news-item-title {
    font-size: 0.8rem;
    color: var(--text);
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 3px;
}

.news-item-meta {
    font-size: 0.62rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ===== SISMOS ===== */
#quakeList {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quake-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
}

.quake-item .quake-mag {
    font-weight: 700;
    color: var(--accent);
}

.quake-item .quake-place {
    color: var(--text2);
}

.quake-item .quake-time {
    color: var(--muted);
    font-size: 0.65rem;
}

/* ===== ACCORDION ===== */
.accordion-wrapper {
    margin-top: 4px;
}

.accordion {
    margin-top: 12px;
    border-top: 1px solid var(--border);
}

.accordion-item {
    border-bottom: 1px solid var(--border);
}

.accordion-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: transparent;
    border: none;
    padding: 14px 4px;
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
    transition: color 0.2s;
    border-radius: var(--radius-sm);
}

.accordion-trigger:hover {
    color: var(--accent);
}

.accordion-trigger .trigger-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.accordion-icon-wrap {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    transition: border-color 0.2s, background 0.2s;
}

.accordion-item.open .accordion-icon-wrap {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.accordion-icon-wrap i {
    transition: transform 0.3s;
    color: var(--text2);
}

.accordion-item.open .accordion-icon-wrap i {
    transform: rotate(180deg);
}

.accordion-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s;
}

.accordion-panel-inner {
    padding: 0 4px 16px;
    font-size: 0.82rem;
    color: var(--text2);
    line-height: 1.6;
}

.accordion-panel-inner p {
    margin-bottom: 6px;
}

.accordion-panel-inner .api-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 6px;
}

.accordion-panel-inner .api-tag {
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 2px 12px;
    font-size: 0.66rem;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--text3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ===== NASA CUSTOM ===== */
#climateMap .cesium-viewer-bottom {
    display: none !important;
}

#climateMap .cesium-widget-credits {
    display: none !important;
}

#climateMap canvas {
    border-radius: inherit;
}

/* ===== RESPONSIVO ===== */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .side-col {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 16px;
    }

    .app-header h1 {
        font-size: 1.3rem;
    }

    .map-wrapper {
        height: 400px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }

    .stat-card {
        padding: 10px 12px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .side-col {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .map-controls-wrapper .btn-layer {
        font-size: 0.6rem;
        padding: 4px 10px;
    }

    .btn-refresh {
        font-size: 0.6rem !important;
        padding: 4px 10px !important;
    }

    .zoom-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .timeline-stop {
        width: 150px;
    }

    .search-wrap {
        max-width: 100%;
        flex: 1 1 100%;
    }

    .location-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .app-header .sub {
        font-size: 0.8rem;
    }
}

@media (max-width: 500px) {
    .map-wrapper {
        height: 320px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===== BEFORE/AFTER TOGGLE ===== */
.before-after-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.before-after-toggle button {
    border: none;
    background: transparent;
    color: var(--text3);
    font-family: var(--font);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 6px 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.before-after-toggle button:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

.before-after-toggle button.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.before-after-toggle button:first-child {
    border-radius: var(--radius-full) 0 0 var(--radius-full);
}

.before-after-toggle button:last-child {
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

/* Responsivo */
@media (max-width: 500px) {
    .before-after-toggle button {
        font-size: 0.6rem;
        padding: 4px 12px;
    }
}