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

:root {
    --bg-primary:   #0d1117;
    --bg-secondary: #161b22;
    --bg-card:      #1c2230;
    --border:       #30363d;
    --accent:       #58a6ff;
    --accent-dim:   #1f6feb;
    --text-primary: #e6edf3;
    --text-muted:   #8b949e;
    --green:        #3fb950;
    --bar-bg:       #21262d;
    --bar-fill:     #58a6ff;
    --radius:       10px;
    --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 1.08rem;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Background ===== */
#bg-gradient {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, #1e3a6e 0%, #0f1f3d 20%, #0d1117 40%, #080c12 100%);
    pointer-events: none;
    z-index: 0;
    transition: background 0.1s ease;
}

#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.page-wrapper {
    position: relative;
    z-index: 3;
}

/* ===== Layout ===== */
.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ===== Header ===== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(88, 166, 255, 0.3);
    box-shadow: 0 1px 0 rgba(88, 166, 255, 0.08);
}

.header-title {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

header h1 {
    font-size: 2.4rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
    text-shadow:
        0 0 30px rgba(88, 166, 255, 0.6),
        0 0 60px rgba(88, 166, 255, 0.25),
        0 2px 12px rgba(0, 0, 0, 0.8);
}

header h1 span {
    color: var(--accent);
    text-shadow:
        0 0 30px rgba(88, 166, 255, 0.9),
        0 0 60px rgba(88, 166, 255, 0.45),
        0 2px 12px rgba(0, 0, 0, 0.8);
}

.header-tagline {
    font-size: 0.92rem;
    color: var(--text-primary);
    font-style: italic;
    opacity: 1;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background-color: var(--green);
    box-shadow: 0 0 6px rgba(63, 185, 80, 0.8);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1;   box-shadow: 0 0 6px  rgba(63, 185, 80, 0.8); }
    50%       { opacity: 0.6; box-shadow: 0 0 12px rgba(63, 185, 80, 0.4); }
}

/* ===== Stat Cards ===== */
.cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card {
    background: rgba(28, 34, 48, 0.55);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem 1.6rem;
    box-shadow: var(--shadow);
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--accent-dim);
}

.card-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card-label br {
    display: none;
}

.card-value {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.card-value.accent {
    color: var(--text-primary);
}

/* ===== Section ===== */
.section {
    background: rgba(28, 34, 48, 0.55);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem 1.6rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

/* ===== Your Visit ===== */
.your-visit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.your-visit-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.your-visit-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.your-visit-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.three-col-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    margin-bottom: 1.5rem;
}

.three-col-row .section {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .three-col-row {
        grid-template-columns: 1fr;
    }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
}

.section-title {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
}

.section-header .section-title {
    margin-bottom: 0;
}

.filter-badges {
    display: flex;
    gap: 0.4rem;
}

.filter-clear {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.2rem 0.65rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.filter-clear:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

/* ===== Country Bars ===== */
.country-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 20rem;
    overflow-y: auto;
    padding-right: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.country-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: transform 0.15s ease;
}

.country-item:hover {
    transform: translateX(6px);
}

.country-item:hover .bar-fill {
    filter: brightness(1.5);
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.45);
}

.item-icon {
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.country-name {
    width: 130px;
    flex-shrink: 0;
    font-size: 0.88rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-wrap {
    flex: 1;
    height: 10px;
    background: var(--bar-bg);
    border-radius: 5px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--bar-fill);
    border-radius: 5px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.country-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 42px;
    text-align: right;
    flex-shrink: 0;
}

/* ===== Clickable country rows ===== */
.country-item.clickable {
    cursor: pointer;
}

.country-item.clickable:hover .country-name {
    color: var(--accent);
}

.country-item.active .bar-fill {
    background: var(--green);
}

.country-item.active .country-name {
    color: var(--accent);
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 1.5rem 0;
}

/* ===== Footer ===== */
footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-primary);
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer .tech-note {
    opacity: 0.85;
}

/* ===== Loading ===== */
.loading {
    opacity: 0.4;
}

/* ===== Globe ===== */
.globe-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 0.5rem;
}

.globe-section .section-title {
    align-self: flex-start;
}

#globe-container {
    position: relative;
    width: 100%;
    height: 500px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000510;
    display: flex;
    justify-content: center;
    align-items: center;
}

#globe-loader {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000510;
    z-index: 10;
    transition: opacity 0.6s ease;
}

#globe-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.globe-icon {
    width: 54px;
    height: 54px;
    animation: globe-spin 3s linear infinite;
    filter: drop-shadow(0 0 8px rgba(79, 195, 247, 0.35));
    transform-origin: center;
}

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

#globe-container > div {
    margin: 0 auto;
}

/* ===== Heatmap ===== */
.heatmap-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.heatmap-hour-labels {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    margin-left: 2.8rem;
    gap: 2px;
}

.heatmap-hour-labels span {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-align: center;
}

.heatmap-body {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
}

.heatmap-day-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    min-width: 2.4rem;
    gap: 2px;
}

.heatmap-day-labels span {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-align: right;
    line-height: 1;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 2px;
    flex: 1;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    min-width: 14px;
    cursor: pointer;
    position: relative;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.heatmap-cell:hover {
    transform: scale(1.5);
    filter: brightness(1.6);
    outline: 1.5px solid var(--accent);
    z-index: 2;
}

.heatmap-cell.active {
    outline: 2px solid var(--accent);
    z-index: 3;
}


.heatmap-day-labels span,
.heatmap-hour-labels span {
    cursor: pointer;
    transition: color 0.15s;
}

.heatmap-day-labels span:hover,
.heatmap-hour-labels span:hover {
    color: var(--accent);
}

.heatmap-day-labels span.active,
.heatmap-hour-labels span.active {
    color: var(--accent);
    font-weight: 700;
}

/* ===== Tooltip ===== */
.tooltip {
    position: fixed;
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 9999;
    box-shadow: var(--shadow);
    white-space: nowrap;
    line-height: 1.5;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .heatmap-cell {
        min-width: 0;
        border-radius: 2px;
    }

    .heatmap-hour-labels span {
        font-size: 0.5rem;
    }

    .heatmap-day-labels {
        min-width: 1.8rem;
    }

    .heatmap-day-labels span {
        font-size: 0.55rem;
    }

    .heatmap-hour-labels {
        margin-left: 2.2rem;
    }
}

@media (max-width: 480px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .card-value {
        font-size: 2rem;
    }

    .card-label br {
        display: inline;
    }

    .card-label {
        min-height: 2.2em;
    }
}
