/* --- RESET & BASE --- */
html, body {
    height: 100%;
    height: 100svh;
    margin: 0;
    padding: 0;
    overflow: hidden; 
    font-family: 'Quicksand', sans-serif; 
    color: #ffffff; 
    
    background-color: transparent; 
    
    -webkit-tap-highlight-color: transparent; 
}
#background-media {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100svh;
    z-index: -1;
    
    background-color: #1c1e26; 
}

#background-media video,
#background-media img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    object-fit: cover;
}

#app-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

/* --- TIMER DISPLAY --- */
#timer-display {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    margin-bottom: 30px;
    letter-spacing: 2px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.7), 0 0 5px rgba(0, 0, 0, 0.5); 
    text-align: center;
    line-height: 1;
    /* Responsive font size */
    font-size: clamp(4rem, 15vw, 12rem); 
    transition: font-size 0.3s ease;
}

#timer-display.long-text {
    font-size: clamp(3rem, 10vw, 9rem); 
}

/* --- CONTROLLI PRINCIPALI (Start/Reset) --- */
#main-controls {
    display: flex;
    gap: 12px; 
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5); 
    backdrop-filter: blur(5px); 
    padding: 10px 20px; 
    border-radius: 50px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.6); 
    flex-wrap: wrap;
    max-width: 95%;
}

#main-controls button {
    padding: 12px 30px; 
    border-radius: 50px; 
    font-size: 1rem;
    cursor: pointer;
    font-weight: 700; 
    transition: all 0.2s ease-out; 
    border: none;
    background: linear-gradient(135deg, #7B68EE, #A29BFE); 
    color: white; 
    box-shadow: 0 4px 15px rgba(123, 104, 238, 0.4); 
    white-space: nowrap;
}

#main-controls button:hover {
    transform: translateY(-2px); 
    background: linear-gradient(135deg, #8A7DF0, #B0A9FF); 
}

#settings-btn {
    padding: 0 !important;
    width: 45px;
    height: 45px;
    border-radius: 50% !important; 
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

/* --- PANNELLO IMPOSTAZIONI (Centrale) --- */
#settings-panel {
    position: absolute;
    top: 50%; 
    left: 50%;
    transform: translate(-50%, -50%); 
    display: none; 
    flex-direction: column;
    gap: 15px;
    background: rgba(18, 18, 18, 0.95); 
    backdrop-filter: blur(15px); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    padding: 25px;
    border-radius: 20px; 
    width: 380px; 
    max-width: 90%; 
    max-height: 75vh; 
    overflow: visible !important;
    z-index: 2000;
}

#settings-panel.visible {
    display: flex;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from { opacity: 0; transform: translate(-50%, -40%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

#settings-panel h3 { margin-top: 0; color: #ddd; font-size: 1.2rem; }

#config-timer, #concentration-controls, #theme-controls {
    display: flex;
    align-items: center;
    justify-content: space-between; 
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

#settings-panel label { font-weight: 500; color: #ccc; font-size: 0.9rem; }

#settings-panel input[type="number"] {
    background: #2a2a2a; 
    border: 1px solid #444; 
    color: white;
    padding: 8px;
    border-radius: 8px;
    font-family: 'Quicksand', sans-serif;
    width: 60px;
    text-align: center;
}

#set-time-btn {
    padding: 8px 15px;
    border-radius: 8px;
    background: #7B68EE; 
    color: white; 
    border: none;
    cursor: pointer;
}

#close-settings-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.1);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- DROPDOWN CUSTOM (Usati nei Settings e Audio) --- */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    min-width: 140px;
    font-size: 0.9rem;
    flex: 1;
}

.custom-select__trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-weight: 500;
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.custom-select__trigger:hover { background: rgba(255, 255, 255, 0.1); }

.custom-options {
    position: absolute;
    display: block;
    bottom: 105%; /* Apre verso l'alto di default */
    left: 0;
    right: 0;
    background: #2a2a2a; 
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    z-index: 3000; 
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px); 
    transition: all 0.2s ease-in-out;
    max-height: 200px; 
    overflow-y: auto;
}

.custom-select-wrapper.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(0);
}

.custom-option {
    padding: 10px 15px;
    font-size: 0.9rem;
    color: #ddd;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.custom-option:hover, .custom-option.selected {
    background-color: #7B68EE; 
    color: #fff;
}

/* --- TASTI FLOTTANTI (Fullscreen & Audio Toggle) --- */
.fixed-control-btn {
    background-color: rgba(20, 20, 20, 0.8); 
    backdrop-filter: blur(5px);
    color: white;
    border: 1px solid rgba(255,255,255,0.2); 
    border-radius: 14px; 
    padding: 0;
    font-size: 1.2rem; 
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

.fixed-control-btn:hover { transform: scale(1.05); background-color: rgba(40, 40, 40, 0.9); }

#fullscreen-button {
    position: fixed; 
    bottom: 25px;
    left: 25px;
}

#audio-controls-fixed {
    position: fixed; 
    bottom: 25px;
    left: 85px; /* Accanto al fullscreen */
    z-index: 1000;
}

/* --- NUOVO DESIGN MIXER AUDIO (Verticale & Glass) --- */
#mini-player-details {
    position: absolute;
    bottom: 60px; /* Sopra il bottone */
    left: 0;
    width: 300px;
    background: rgba(15, 15, 20, 0.95); 
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    color: white;
    z-index: 1000;
    
    /* Animazione Entrata */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mini-player-details:not(.hidden) {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.audio-group { margin-bottom: 5px; }

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

.group-header label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    display: flex; align-items: center; gap: 8px;
}

/* Bottone Play Rotondo nel Mixer */
.play-btn-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #7B68EE;
    border: none;
    color: white;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 10px rgba(123, 104, 238, 0.3);
}
.play-btn-circle:hover { transform: scale(1.1); background: #8e7bf9; }

.separator-line {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 15px 0;
}

/* Slider Volume Custom */
.volume-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0 0 0;
}

.small-icon { font-size: 0.8rem; color: #666; width: 20px; text-align: center; }

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    margin-top: -5px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

/* --- FOOTER & CREDITI --- */
#credits-footer {
    position: fixed;
    bottom: 25px;
    right: 25px; 
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(5px);
    padding: 8px 16px;
    border-radius: 30px; 
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ccc;
    font-size: 0.9rem;
}

#credits-footer a { color: #fff; text-decoration: none; font-size: 1.1rem; }
.social-separator { width: 1px; height: 16px; background: rgba(255,255,255,0.3); }

.coffee-btn {
    display: flex; align-items: center; gap: 6px;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #fff; text-decoration: none;
    transition: background 0.3s;
}
.coffee-btn:hover { background: rgba(255, 255, 255, 0.2); }

/* --- MODALE (Standard & Conferma) --- */

/* Qui aggiungiamo anche #confirm-modal-overlay con la virgola */
#custom-modal-overlay, #confirm-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 99999; 
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease;
}

/* Quando attivi uno dei due, diventa visibile */
#custom-modal-overlay.active, #confirm-modal-overlay.active { 
    opacity: 1; 
    visibility: visible; 
}

/* Stile del box interno */
#custom-modal {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-width: 90%; width: 320px;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Animazione di entrata per entrambi */
#custom-modal-overlay.active #custom-modal, 
#confirm-modal-overlay.active #custom-modal { 
    transform: scale(1); 
}

.modal-icon { font-size: 3rem; margin-bottom: 15px; }
#modal-title { margin: 0 0 10px 0; font-size: 1.5rem; }
#modal-message { font-size: 1.1rem; margin-bottom: 20px; line-height: 1.5; }

/* Tasto 'Got it' del timer */
#modal-close-btn {
    background: #ff7e5f; color: white; border: none;
    padding: 10px 25px; border-radius: 50px;
    font-size: 1rem; cursor: pointer; transition: transform 0.2s;
}
#modal-close-btn:hover { transform: scale(1.05); }
/* --- MEDIA QUERIES (OTTIMIZZAZIONE MOBILE) --- */
@media (max-width: 768px) {
    
    /* Timer più piccolo per evitare che esca dallo schermo */
    #timer-display {
        margin-bottom: 20px;
        font-size: clamp(3.5rem, 15vw, 6rem);
    }
    
    /* Controlli principali più compatti */
    #main-controls {
        padding: 8px 15px;
        gap: 10px;
        width: auto;
    }
    #main-controls button {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    /* Footer: Nascondi testi per salvare spazio */
    #credits-footer {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        bottom: 20px;
        padding: 8px 15px;
        white-space: nowrap;
    }
    #credits-footer > span:first-child, .coffee-text, .social-separator { display: none; }
    
    .coffee-btn {
        padding: 8px;
        aspect-ratio: 1/1;
        justify-content: center;
        border-radius: 50%; 
        min-width: 35px;
    }

    /* Fullscreen nascosto su mobile (spesso non supportato o inutile) */
    #fullscreen-button {
        display: none !important;
    }

    /* POSIZIONAMENTO MENU AUDIO SU MOBILE */
    #audio-controls-fixed {
        left: 20px; /* Ancorato a sinistra */
        bottom: 20px; 
    }

    #mini-player-details {
        left: 0;
        bottom: 60px; /* Si apre sopra il tasto */
        width: 280px; /* Leggermente più stretto */
        padding: 15px;
    }

    /* Settings Panel Mobile */
    #settings-panel {
        width: 90%;
        max-height: 85vh;
        padding: 20px;
    }
    #config-timer, #concentration-controls, #theme-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .custom-select-wrapper { width: 100%; }
}

/* --- POMODORO BUTTONS --- */
.pomodoro-controls {
    display: flex;
    gap: 8px;
}

.pomo-btn {
    flex: 1; /* Occupa tutto lo spazio disponibile */
    padding: 10px;
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: bold;
    font-family: 'Quicksand', sans-serif;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 5px;
    transition: transform 0.2s;
}

.pomo-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.pomo-btn:active { transform: scale(0.95); }

/* Colori specifici */
.pomo-btn.focus { background:#7B68EE;; box-shadow: 0 4px 10px rgba(123,104,238,0.3); }
.pomo-btn.break { background: #7B68EE;; box-shadow: 0 4px 10px rgba(123,104,238,0.3); }
.pomo-btn.long-break { background: #7B68EE;; box-shadow: 0 4px 10px rgba(123,104,238,0.3); }


#daily-stats {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6); /* Grigio chiaro */
    margin-top: -20px; /* Lo avvicina al timer */
    margin-bottom: 25px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.8rem;
    background: rgba(0,0,0,0.3);
    padding: 5px 15px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

#focus-minutes {
    color: #fff;
    font-weight: 700;
}

/* --- TASTO RESET STATS --- */
#reset-stats-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3); /* Molto discreto */
    cursor: pointer;
    margin-left: 10px;
    font-size: 0.8rem;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

#reset-stats-btn:hover {
    color: #ff6b6b; /* Diventa rosso per indicare "pericolo/cancellazione" */
    background: rgba(255, 107, 107, 0.1);
    transform: rotate(-180deg); /* Piccola animazione carina */
}


/* --- NOTEPAD / BLOCCO NOTE --- */

/* Il contenitore del blocco note */
#floating-notepad {
    position: fixed;
    bottom: 90px; /* Un po' sopra il tasto */
    left: 25px;   /* Allineato a sinistra */
    width: 300px;
    height: 400px;
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    
    /* Animazione di entrata */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 1;
    transform: translateY(0) scale(1);
    transform-origin: bottom left;
}

/* Quando è nascosto (Classe gestita dal JS) */
#floating-notepad.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none; /* Non cliccabile quando nascosto */
}

/* Header del blocco note */
.notepad-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px 16px 0 0;
}

.notepad-header span {
    font-weight: 700;
    color: #ddd;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

/* Tasto chiudi X */
#close-notepad-btn {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    transition: color 0.2s;
}
#close-notepad-btn:hover { color: #ff6b6b; }

/* Area di testo */
#notepad-content {
    flex: 1;
    background: transparent;
    border: none;
    padding: 15px;
    color: #eee;
    font-family: 'Quicksand', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}
#notepad-content::placeholder { color: rgba(255,255,255,0.3); }


/* --- ADATTAMENTO MOBILE --- */
@media (max-width: 768px) {
    
    /* 1. Posizione Notepad su Mobile (Centrato) */
    #floating-notepad {
        left: 50%;
        bottom: 80px;
        transform: translateX(-50%); 
        width: 90%;
        height: 50vh;
        transform-origin: bottom center;
    }
    
    #floating-notepad.hidden {
        transform: translateX(-50%) translateY(20px) scale(0.9);
    }

    /* 2. Tasto MUSICA (Primo a sinistra) */
    #audio-controls-fixed {
        left: 20px !important; 
        bottom: 25px !important;
    }

    /* 3. Tasto PENNA (Subito accanto) */
   #notepad-toggle {
        left: auto !important;   /* Lo stacchiamo da sinistra */
        right: 20px !important;  /* Lo attacchiamo a destra */
        bottom: 25px !important; /* Allineato in basso con gli altri */
    }

    /* 4. Nascondi Fullscreen su mobile (non serve) */
    #fullscreen-button {
        display: none !important;
    }
}