/* --- Floating Action Button Group --- */
.fab-group {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: flex-end;
    pointer-events: none; /* Let children handle pointer events */
}
.fab-group > button,
.fab-group > .horizontal-btn-group {
    pointer-events: auto;
}

/* --- Horizontal Button Group for Time Filters --- */
.horizontal-btn-group {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: center;
}

/* --- Time Filter Container with Expandable Animation --- */
.time-filter-container {
    display: flex;
    flex-direction: row-reverse; /* Items appear from right to left */
    align-items: center;
    gap: 12px;
    position: relative;
}

/* Primary button positioning - always stays in the same visual position */
.time-filter-btn.primary {
    order: -1; /* Always appears at the rightmost position in row-reverse */
}

.time-filter-btn:not(.primary) {
    order: 0;
}

.time-filter-container.expanded .time-filter-btn:not(.primary) {
    animation: slideIn 0.3s ease-out forwards;
    pointer-events: auto;
}

.time-filter-container:not(.expanded) .time-filter-btn:not(.primary) {
    animation: slideOut 0.3s ease-out forwards;
    pointer-events: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(20px) scale(0.8);
    }
}

/* Initially hide non-primary buttons */
.time-filter-container:not(.expanded) .time-filter-btn:not(.primary) {
    opacity: 0;
    transform: translateX(20px) scale(0.8);
    width: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* assets/css/main.css */

/* --- CSS Variables for Theming --- */
:root {
    --font-family: 'Inter', sans-serif;

    /* Light Theme */
    --background-color-light: #f4f7f9;
    --text-color-light: #1a1a1a;
    --header-bg-light: rgba(255, 255, 255, 0.8);
    --fab-bg-light: #007bff;
    --fab-text-light: #ffffff;
    --modal-bg-light: #ffffff;
    --modal-shadow-light: 0 5px 15px rgba(0,0,0,0.1);
    --button-bg-light: #007bff;
    --button-text-light: #ffffff;
    --button-hover-bg-light: #0056b3;
    --border-color-light: #e0e0e0;
    --button-secondary-bg-light: rgba(255, 255, 255, 0.7); /* NUOVO: Sfondo per pulsanti secondari */

    /* Dark Theme */
    --background-color-dark: #1a1d21;
    --text-color-dark: #e1e1e1;
    --header-bg-dark: rgba(26, 29, 33, 0.8);
    --fab-bg-dark: #4a90e2;
    --fab-text-dark: #ffffff;
    --modal-bg-dark: #2c3035;
    --modal-shadow-dark: 0 5px 20px rgba(0,0,0,0.4);
    --button-bg-dark: #4a90e2;
    --button-text-dark: #ffffff;
    --button-hover-bg-dark: #357abd;
    --border-color-dark: #444;
    --button-secondary-bg-dark: #2c3035; /* NUOVO: Sfondo solido per pulsanti secondari */
}

/* --- General Styles --- */
body {
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevents scrollbars from appearing next to the full-screen map */
    background-color: var(--background-color-light);
    color: var(--text-color-light);
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Improve text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body.dark-theme {
    background-color: var(--background-color-dark);
    color: var(--text-color-dark);
}

/* --- Map Container --- */
#cesiumContainer {
    height: 100vh;
    width: 100vw;
    z-index: 1;
}

/* Force sharp rendering on high-DPI displays */
#cesiumContainer canvas {
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Cesium adds its own UI elements, let's hide the default animation/timeline controls for a cleaner look */
.cesium-viewer-animationContainer,
.cesium-viewer-timelineContainer,
.cesium-viewer-bottom {
    display: none !important;
}

/* --- Header --- */
.main-header {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    text-align: center;
    background-color: var(--header-bg-light);
    padding: 5px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
    transition: background-color 0.3s ease;
}

body.dark-theme .main-header {
    background-color: var(--header-bg-dark);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.main-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.main-header p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* --- Floating Action Button (FAB) --- */
.fab {
    width: 58px;
    height: 58px;
    background-color: var(--fab-bg-light);
    color: var(--fab-text-light);
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    transform: translateZ(0);
    position: relative; /* For pseudo-element positioning */
}

.fab::before,
.fab::after {
    content: '';
    position: absolute;
    background-color: var(--fab-text-light);
    transition: transform 0.2s ease-out;
}

/* Vertical bar of the plus */
.fab::before {
    left: 50%;
    top: 30%;
    bottom: 30%;
    width: 3px;
    transform: translateX(-50%);
}

/* Horizontal bar of the plus */
.fab::after {
    top: 50%;
    left: 30%;
    right: 30%;
    height: 3px;
    transform: translateY(-50%);
}

body.dark-theme .fab {
    background-color: var(--fab-bg-dark);
}

.fab:active {
    /* MODIFICATO: Aggiunto un effetto "bounce" più pronunciato */
    transform: scale(0.9) translateZ(0);
    transition-duration: 0.1s; /* Rende la pressione più reattiva */
}

/* --- Theme & Home Buttons (Final Corrected Version) --- */
.theme-btn {
    width: 58px;
    height: 58px;
    background-color: var(--button-secondary-bg-light);
    border: 1px solid var(--border-color-light);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    position: relative; /* Cruciale per il posizionamento assoluto degli wrapper */
    overflow: hidden;
}

/* --- Time Filter Buttons --- */
.time-filter-btn {
    min-width: 54px;
    height: 54px;
    background-color: var(--button-secondary-bg-light);
    border: 2px solid var(--border-color-light);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color-light);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    white-space: nowrap;
}

.time-filter-btn.primary {
    /* Primary button always visible with pulsing effect when not expanded */
    position: relative;
}

.time-filter-container:not(.expanded) .time-filter-btn.primary::after {
    content: '⏱️';
    position: absolute;
    right: -4px;
    top: -4px;
    font-size: 0.9rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.6;
        transform: scale(1.1);
    }
}

.time-filter-btn.active {
    background-color: var(--fab-bg-light);
    color: var(--fab-text-light);
    border-color: var(--fab-bg-light);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
}

body.dark-theme .time-filter-btn {
    background-color: var(--button-secondary-bg-dark);
    border-color: var(--border-color-dark);
    color: var(--text-color-dark);
}

body.dark-theme .time-filter-btn.active {
    background-color: var(--fab-bg-dark);
    color: var(--fab-text-dark);
    border-color: var(--fab-bg-dark);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
}

.time-filter-btn:active {
    transform: scale(0.95);
    transition-duration: 0.1s;
}

@media (hover: hover) and (pointer: fine) {
    .time-filter-btn:hover {
        transform: translateY(-2px) scale(1.05);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
}

.theme-btn:active {
    /* MODIFICATO: Aggiunto un effetto "bounce" più pronunciato */
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition-duration: 0.1s;
}

@media (hover: hover) and (pointer: fine) {
    .fab:hover {
        transform: scale(1.1) translateZ(0);
    }

    .theme-btn:hover {
        transform: translateY(-2px) scale(1.05);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
}

body.dark-theme .theme-btn {
    background-color: var(--button-secondary-bg-dark);
    border-color: var(--border-color-dark);
}

/* --- Icon Wrappers & Icons (SOLUZIONE DEFINITIVA) --- */
.icon-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* Usa Flexbox per un centraggio robusto */
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-wrapper span {
    font-size: 1.9rem;
    /* Normalizza il comportamento dell'icona per un centraggio perfetto */
    line-height: 1;
    display: inline-block;
    /* RIMOSSO: La traslazione manuale era l'errore */
}

body.dark-theme .icon-wrapper span {
    color: var(--text-color-dark);
}

/* --- Icon Animation Logic --- */
#theme-switcher .moon-wrapper {
    opacity: 0;
    transform: scale(0) rotate(-90deg);
}

body.dark-theme #theme-switcher .sun-wrapper {
    opacity: 0;
    transform: scale(0) rotate(90deg);
}

body.dark-theme #theme-switcher .moon-wrapper {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}


/* --- Emoji Marker on Map --- */
.emoji-marker {
    font-size: 2rem; /* Adjust size of emoji on map */
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    background: transparent;
    border: none;
}

/* --- Modal Styles --- */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--modal-bg-light);
    color: var(--text-color-light);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--modal-shadow-light);
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

body.dark-theme .modal-content {
    background-color: var(--modal-bg-dark);
    color: var(--text-color-dark);
    box-shadow: var(--modal-shadow-dark);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    color: #aaa;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-color-light);
}
body.dark-theme .close-btn:hover {
    color: var(--text-color-dark);
}

#emoji-picker {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    max-height: 200px;
    overflow-y: scroll; /* Always show scrollbar to prevent layout shift */
    padding-right: 5px; /* Add a little space for the scrollbar */
}

/* Custom Scrollbar for Emoji Picker */
#emoji-picker::-webkit-scrollbar {
    width: 14px;
}

#emoji-picker::-webkit-scrollbar-track {
    background: transparent;
}

#emoji-picker::-webkit-scrollbar-thumb {
    background-color: var(--border-color-light);
    border-radius: 6px;
    border: 4px solid var(--modal-bg-light); /* Creates padding around thumb */
}

body.dark-theme #emoji-picker::-webkit-scrollbar-thumb {
    background-color: var(--border-color-dark);
    border-color: var(--modal-bg-dark);
}

.emoji-option {
    font-size: 2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: transform 0.2s, background-color 0.2s;
}

.emoji-option:hover {
    transform: scale(1.2);
}

.emoji-option.selected {
    background-color: rgba(0, 123, 255, 0.2);
    transform: scale(1.2);
}
body.dark-theme .emoji-option.selected {
    background-color: rgba(74, 144, 226, 0.3);
}

#submit-mood-btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: 500;
    background-color: var(--button-bg-light);
    color: var(--button-text-light);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

body.dark-theme #submit-mood-btn {
    background-color: var(--button-bg-dark);
    color: var(--button-text-dark);
}

#submit-mood-btn:hover:not(:disabled) {
    background-color: var(--button-hover-bg-light);
}
body.dark-theme #submit-mood-btn:hover:not(:disabled) {
    background-color: var(--button-hover-bg-dark);
}

#submit-mood-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}
body.dark-theme #submit-mood-btn:disabled {
    background-color: #555;
}

#modal-status {
    margin-top: 15px;
    min-height: 1.2em;
    font-size: 0.9rem;
}

/* --- Responsive Design --- */
@media (max-width: 600px) {
    .main-header {
        padding: 8px 15px; /* A bit more vertical padding */
        width: auto; /* Let it size to its content */
        max-width: 95%; /* But don't let it touch the edges */
    }
    .main-header h1 {
        font-size: 1.1rem;
    }
    .main-header p {
        font-size: 0.75rem;
        white-space: nowrap; /* This is the key: prevents the subtitle from wrapping */
    }
    .fab-group {
        right: 10px;
        bottom: 10px;
        gap: 10px;
    }
    .horizontal-btn-group {
        gap: 8px;
    }
    .fab {
        width: 50px;
        height: 50px;
        font-size: 2rem;
        line-height: 50px;
    }
    .theme-btn {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }
    .time-filter-btn {
        min-width: 46px;
        height: 46px;
        font-size: 0.75rem;
        padding: 0 6px;
    }
    .modal-content {
        width: 95%;
        padding: 20px;
    }
}
