/*
  ==============================================
  Global Emotions Index - Modern Stylesheet (2026)
  ==============================================
*/

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Inter:wght@400;600&display=swap');

/* --- CSS Variables --- */
:root {
    /* Colors */
    --color-background: #0D1117;
    --color-surface: #161B22;
    --color-border: #30363D;
    --color-primary-text: #E6EDF3;
    --color-secondary-text: #8B949E;
    --color-accent: #58A6FF;
    --color-success: #3FB950;
    --color-danger: #F85149;

    /* Typography */
    --font-primary: 'Cairo', 'Inter', sans-serif;
    --font-secondary: 'Inter', sans-serif;

    /* Sizing & Radius */
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 18px;
    --sidebar-width: 380px;

    /* Transitions */
    --transition-fast: 0.15s ease-in-out;
    --transition-smooth: 0.3s ease-in-out;
}

/* --- Base & Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--color-background);
    color: var(--color-primary-text);
    overflow: hidden;
    /* Prevent body scroll */
    line-height: 1.6;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2 {
    font-weight: 700;
    line-height: 1.3;
}

p {
    color: var(--color-secondary-text);
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

/* --- App Layout --- */
#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    opacity: 0;
    animation: fadeIn 0.8s ease-out forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}


/* --- Sidebar --- */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--color-background);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 1002;
    transition: transform var(--transition-smooth);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Custom scrollbar for sidebar */
.sidebar-content::-webkit-scrollbar {
    width: 8px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

header {
    margin-bottom: 24px;
}

header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

header .logo svg {
    color: var(--color-accent);
}

header h1 {
    font-size: 1.5rem;
    color: var(--color-primary-text);
}

header p {
    font-size: 0.9rem;
}

/* --- Emotion Selector --- */
#emotion-selector {
    margin-bottom: 24px;
}

#emotion-selector h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--color-secondary-text);
}

.emotions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 600px) {
    .emotions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.emo-btn {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-primary-text);
    padding: 12px;
    border-radius: var(--border-radius-md);
    font-size: 2rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    aspect-ratio: 1 / 1;
}

.emo-btn span {
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-primary);
}

.emo-btn:hover {
    transform: translateY(-4px);
    border-color: var(--color-accent);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.emo-btn:active {
    transform: translateY(-1px) scale(0.98);
}


/* --- Card Elements (Stats & Timeline) --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    padding: 20px;
    margin-bottom: 20px;
    animation: slideUp 0.6s ease-out forwards;
    opacity: 0;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#global-stats-container {
    animation-delay: 0.1s;
}

#timeline-container {
    animation-delay: 0.2s;
}


.card h2 {
    margin-top: 0;
    padding-bottom: 12px;
    font-size: 1.1rem;
    color: var(--color-primary-text);
    border-bottom: 1px solid var(--color-border);
}

/* Timeline specific styles */
#timeline-container {
    flex: 1;
    overflow-y: hidden;
}

#timeline {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
    height: 200px;
    /* Example fixed height */
    overflow-y: auto;
}

#timeline::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar */
#timeline {
    -ms-overflow-style: none;
    scrollbar-width: none;
}


#timeline li {
    padding: 10px 4px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
}

#timeline li:last-child {
    border-bottom: none;
}

#timeline li .loc {
    font-weight: bold;
    color: var(--color-primary-text);
}


/* --- Map --- */
#map-container {
    flex: 1;
    position: relative;
    height: 100vh;
}

#map {
    height: 100%;
    width: 100%;
    background-color: #010409;
}

/* .leaflet-tile-pane {
  filter: grayscale(80%) brightness(0.6) contrast(1.2);
} */

/* Custom popup */
.leaflet-popup-content-wrapper {
    background: var(--color-surface);
    color: var(--color-primary-text);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.leaflet-popup-content {
    margin: 15px;
    font-family: var(--font-primary);
}

.leaflet-popup-tip {
    background: var(--color-surface);
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--color-secondary-text);
    transition: color var(--transition-fast);
}

.leaflet-container a.leaflet-popup-close-button:hover {
    color: var(--color-primary-text);
}


/* --- Map Controls --- */
#map-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(5px);
    padding: 10px 15px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    z-index: 1000;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    font-size: 0.9rem;
}

.switch input {
    display: none;
}

.slider {
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background-color: var(--color-border);
    transition: var(--transition-smooth);
    margin-right: 12px;
}

.slider::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: #fff;
    transition: var(--transition-smooth);
}

.switch input:checked+.slider {
    background-color: var(--color-accent);
}

.switch input:checked+.slider::before {
    transform: translateX(16px);
}

/* --- Mobile Sidebar Toggle --- */

#sidebar-toggle-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1003;
    background-color: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid var(--color-border);
    color: var(--color-primary-text);
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    display: none;
    /* مخفي على الشاشات الكبيرة */
    align-items: center;
    justify-content: center;
}


/* --- Loader --- */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: white;
    font-size: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

#loader.visible {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* --- Pulse Animation on Map (Glow & Large) --- */
.pulse-icon-container {
    z-index: 1001;
}

.pulse-icon {
    width: 28px;       /* حجم أكبر */
    height: 28px;
    border-radius: 50%;
    border: 4px solid white;
    background-color: var(--color-accent); /* لون النبضة الأساسي */
    box-shadow:
        0 0 15px var(--color-accent),   /* توهج داخلي */
        0 0 30px var(--color-accent),   /* توهج خارجي */
        0 0 45px var(--color-accent);   /* توهج بعيد أكبر */
    animation: pulse-glow 2s ease-out infinite;
}

/* Pulse keyframes with glow effect */
@keyframes pulse-glow {
    0% {
        transform: scale(0.6);
        opacity: 0.7;
        box-shadow:
            0 0 10px var(--color-accent),
            0 0 20px var(--color-accent),
            0 0 30px var(--color-accent);
    }

    50% {
        opacity: 1;
        box-shadow:
            0 0 20px var(--color-accent),
            0 0 40px var(--color-accent),
            0 0 60px var(--color-accent);
    }

    100% {
        transform: scale(3.2);
        opacity: 0;
        box-shadow:
            0 0 25px var(--color-accent),
            0 0 50px var(--color-accent),
            0 0 75px var(--color-accent);
    }
}


/* Placeholders */
.placeholder {
    display: inline-block;
    min-height: 1em;
    vertical-align: middle;
    cursor: wait;
    background-color: currentColor;
    opacity: 0.2;
}

.placeholder.col-12 {
    width: 100%;
}

.placeholder-glow .placeholder {
    animation: placeholder-glow 2s ease-in-out infinite;
}

@keyframes placeholder-glow {
    50% {
        opacity: 0.1;
    }
}

footer {
    padding: 24px;
    text-align: center;
    border-top: 1px solid var(--color-border);
}

footer p {
    font-size: 0.8rem;
    color: var(--color-secondary-text);
}


/* --- Responsive Design --- */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: auto;
    }
}


@media (max-width: 768px) {
    :root {
        --sidebar-width: auto;
    }

    #app-container {
        flex-direction: column;
    }

    #sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        transform: translateX(100%);
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
        border-left: 1px solid var(--color-border);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #sidebar-toggle-btn {
        display: flex;
        left: 20px;
        right: auto;
    }

    #map-controls {
        bottom: auto;
        top: 20px;
        left: auto;
        right: 20px;
    }
}