@import url('https://fonts.googleapis.com/css2?family=Helvetica+Neue:wght@400;500;700&family=Segoe+UI:wght@400;600&display=swap');

        /* IMPORTAZIONE DEL FONT CUSTOM PER IL TEMA APPLE */
        @font-face {
            font-family: 'LED Counter 7';
            src: url('led-counter-7.regular.ttf') format('truetype');
            font-weight: normal;
            font-style: normal;
            font-display: swap;
        }

:root {
            --blue-gloss-top: #74cbf6;
            --blue-gloss-mid: #2ea0eb;
            --blue-gloss-bottom: #0d79cc;
            --green-gloss-top: #8ede5f;
            --green-gloss-mid: #51a318;
            --green-gloss-bottom: #3b820a;
        }

* {
            box-sizing: border-box;
            -webkit-font-smoothing: antialiased;
            margin: 0;
            padding: 0;
        }

/* =========================================================
           1. GESTIONE SFONDO GLOBALE
           ========================================================= */
        body,
        html {
            height: 100%;
            overflow: hidden;
            position: relative;
            font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
            transition: background-color 0.5s ease;
        }

/* Controlli Fluttuanti Globali */
        .floating-controls {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 10000;
            display: flex;
            gap: 12px;
            flex-direction: row;
        }

.floating-btn {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            position: relative;
            border: 1px solid rgba(255, 255, 255, 0.4);
            background: rgba(0, 0, 0, 0.3);
            font-size: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
            transition: all 0.3s ease;
            color: #fff;
        }

/* --- NUOVO: SISTEMA DI ESPANSIONE PULSANTE TEMA (VERTICALE) --- */

        /* Base (Desktop): Espansione verso il basso */
        .theme-bubble-container {
            display: flex;
            flex-direction: column;
            /* Colonna normale: il bottone principale è sopra, le opzioni sotto */
            gap: 10px;
            transition: all 0.3s ease;
        }

.theme-bubble-options {
            display: flex;
            flex-direction: column;
            gap: 10px;
            max-height: 0;
            /* Su desktop animiamo l'altezza, non la larghezza */
            opacity: 0;
            overflow: hidden;
            transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
        }

/* Quando il contenitore ha la classe 'expanded', mostra le opzioni */
        .theme-bubble-container.expanded .theme-bubble-options {
            max-height: 350px;
            /* Abbastanza per contenere tutte le 5 icone extra */
            opacity: 1;
        }

/* Ottimizzazione GPU: rimuovi backdrop-filter quando nascosto */
        .theme-bubble-container:not(.expanded) .sub-theme-btn {
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
        }

/* Stile per i mini bottoncini del tema dentro l'espansione */
        .sub-theme-btn {
            width: 44px;
            height: 44px;
            border-radius: 50%;
            border: 1px solid rgba(255, 255, 255, 0.3);
            background: rgba(0, 0, 0, 0.5);
            font-size: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
            transition: transform 0.2s;
            color: #fff;
        }

.sub-theme-btn:hover {
            transform: scale(1.1);
            background: rgba(0, 0, 0, 0.7);
        }

.floating-btn:hover {
            background: rgba(0, 0, 0, 0.5);
            transform: scale(1.08);
        }

.chat-bubble-btn {
            display: none;
        }

/* Swap Pulsanti Floating in base al tema */
        #theme-toggle-btn {
            display: flex;
        }

#futuristic-settings-btn-floating {
            display: none;
        }

.notification-badge {
            position: absolute;
            top: -2px;
            right: -2px;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: radial-gradient(circle at 30% 30%, #ff4a4a, #cc0000);
            border: 1px solid #770000;
            display: none;
            z-index: 2;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.6);
        }

/* ---------------- REGOLE GLOBALI CHAT (Adattamento per Avatar) ---------------- */
        .msg-avatar-wrapper {
            display: none;
        }

/* Nascosto nei temi classici */
        .user-pill-avatar-wrapper {
            display: none;
        }

/* Nascosto nei temi classici */

        .msg-content-wrapper {
            display: flex;
            flex-direction: column;
            width: 100%;
        }

.msg.mine .msg-content-wrapper {
            align-items: flex-end;
        }

.msg.theirs .msg-content-wrapper {
            align-items: flex-start;
        }

.msg.mine .msg-name.is-mine {
            display: none;
        }

/* Nascondo il "Mio Nome" nei temi vecchi per non spaccarli */
        .msg-header {
            display: flex;
            gap: 8px;
            align-items: baseline;
            margin-bottom: 4px;
        }

/* ---------------- STRUTTURA CLASSICA E LOGICA DI ALLINEAMENTO FLUIDO ---------------- */
        .device-shell {
            width: 92vw;
            max-width: 1400px;
            height: 85vh;
            max-height: 900px;
            min-height: 600px;
            margin: auto;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            transition: all 0.5s ease;
        }

.header-area {
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            z-index: 10;
        }

.window-titlebar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 38px;
        }

.app-toolbar {
            display: flex;
            align-items: center;
            gap: 8px;
        }

.modules-container {
            display: flex;
            flex: 1;
            overflow: hidden;
            align-items: stretch;
        }

/* COLONNE BASE: Rigide e Matematiche per azzerare lo "Squish" */
        .timer-col {
            flex: 0 0 360px;
            width: 360px;
            max-width: 360px;
            min-width: 360px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-evenly;
            padding: 30px 20px;
            position: relative;
        }

.dashboard-col {
            flex: 0 0 360px;
            width: 360px;
            max-width: 360px;
            min-width: 360px;
            display: flex;
            flex-direction: column;
            gap: 24px;
            padding: 24px;
            overflow-x: hidden;
            overflow-y: auto;
        }

/* La chat è l'unica flessibile di base, ma controlliamo le min/max width per l'animazione */
        .chat-col {
            flex: 1 1 0%;
            min-width: 25%;
            max-width: 100%;
            display: flex;
            flex-direction: column;
            position: relative;
        }

.mobile-chat-header {
            display: none;
        }

.timer-top-bar {
            display: flex;
            width: 100%;
            max-width: 360px;
            gap: 12px;
            align-items: center;
            margin: 0 auto 15px auto;
        }

.session-counter-display {
            width: 100%;
            max-width: 360px;
            margin: 0 auto 15px auto;
            text-align: center;
            font-size: 13px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1px;
            transition: all 0.4s ease;
        }

.bezel {
            width: 270px;
            height: 270px;
            border-radius: 50%;
            padding: 20px;
            position: relative;
            margin: 0 auto;
            flex-shrink: 0;
        }

.playback-controls {
            display: flex;
            gap: 16px;
            align-items: center;
            justify-content: center;
            width: 100%;
            max-width: 360px;
            margin: 0 auto;
        }

.cycle-leds {
            display: flex;
            gap: 14px;
            justify-content: center;
            width: 100%;
            max-width: 360px;
            margin: 0 auto;
        }

.dial-glass {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            position: relative;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
        }

.svg-dial {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            transform: rotate(-90deg);
            z-index: 1;
            overflow: visible;
        }

.dial-track,
        .dial-progress {
            fill: none;
            stroke-width: 10;
        }

.dial-progress,
        .timer-ring-progress {
            stroke-linecap: round;
            transition: none !important;
        }

.digits {
            z-index: 10;
            position: relative;
            margin-top: -15px;
            font-family: 'Courier New', monospace;
            font-size: 58px;
            font-weight: bold;
        }

.segmented-control {
            display: flex;
            flex: 1;
            width: 100%;
        }

.segment-btn {
            flex: 1;
            padding: 10px 0;
            border: none;
            cursor: pointer;
            text-align: center;
            transition: all 0.2s;
        }

/* FIX: quando il timer e' attivo i tab Pausa Breve / Pausa Lunga / Timer
           restano visibili ma non sono cliccabili, in nessun tema. */
        .segment-btn.locked {
            cursor: not-allowed;
            pointer-events: none;
            opacity: 0.5;
            filter: grayscale(30%);
        }

.stats-flex {
            display: flex;
            gap: 12px;
            width: 100%;
        }

.online-users-list {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

.user-pill {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            font-size: 12px;
            font-weight: bold;
            transition: all 0.2s;
        }

.status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background-color: #4cd964;
            box-shadow: 0 0 5px #4cd964;
        }

.chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 24px 20px;
            padding-right: 12px;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

.chat-input-wrapper {
            flex-shrink: 0;
        }

.chat-input-bar {
            padding: 14px 20px;
            display: flex;
            gap: 12px;
            align-items: flex-end;
        }

.chat-textarea {
            flex: 1;
            resize: none;
            max-height: 100px;
            min-height: 40px;
            font-family: inherit;
        }

.msg {
            display: flex;
            flex-direction: column;
            max-width: 85%;
            min-width: 0;
        }

.msg.mine {
            align-self: flex-end;
            align-items: flex-end;
            margin-right: 12px;
        }

.msg.theirs {
            align-self: flex-start;
            align-items: flex-start;
        }

/* FIX BOLLE CHAT: regola base condivisa da tutti i temi.
           Senza questa, .msg-bubble e' un div block-level che si allarga
           per riempire il contenitore invece di adattarsi al testo. */
        .msg-bubble {
            display: inline-block;
            width: fit-content;
            max-width: 100%;
            word-wrap: break-word;
            overflow-wrap: anywhere;
            word-break: break-word;
            white-space: pre-wrap;
        }

.typing-row {
            padding: 6px 16px 0;
            font-size: 12px;
            display: none;
            font-style: italic;
        }

/* Animazioni fluide Focus/Break Mode - Ora senza schiacciamento */
        @media (min-width: 1001px) {

            .timer-col,
            .dashboard-col,
            .chat-col {
                transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1) !important;
            }

            .dashboard-col {
                white-space: nowrap;
            }

            /* Nascondere la Dashboard fluida */
            .modules-container.focus-mode .dashboard-col,
            .modules-container.break-mode .dashboard-col {
                flex: 0 0 0px !important;
                width: 0px !important;
                max-width: 0px !important;
                min-width: 0px !important;
                padding-left: 0 !important;
                padding-right: 0 !important;
                margin-left: 0 !important;
                margin-right: 0 !important;
                opacity: 0 !important;
                border: none !important;
                overflow: hidden !important;
            }

            /* Focus Mode Classica (Apple/Aero) */
            .modules-container.focus-mode .timer-col {
                flex: 0 0 75% !important;
                width: 75% !important;
                max-width: 75% !important;
                min-width: 75% !important;
            }

            .modules-container.focus-mode .chat-col {
                flex: 1 1 0% !important;
                max-width: 25% !important;
                min-width: 25% !important;
            }

            /* Break Mode Classica (Apple/Aero) */
            .modules-container.break-mode .timer-col {
                flex: 0 0 50% !important;
                width: 50% !important;
                max-width: 50% !important;
                min-width: 50% !important;
            }

            .modules-container.break-mode .chat-col {
                flex: 1 1 0% !important;
                max-width: 50% !important;
                min-width: 50% !important;
            }

            /* Matematica precisa per i temi con Margini o Gap per azzerare i conflitti e l'overlap */
            body.theme-minimal .modules-container.focus-mode .timer-col {
                width: calc(75% - 10px) !important;
                max-width: calc(75% - 10px) !important;
                min-width: calc(75% - 10px) !important;
            }

            body.theme-minimal .modules-container.focus-mode .chat-col {
                max-width: calc(25% - 10px) !important;
                min-width: calc(25% - 10px) !important;
            }

            body.theme-minimal .modules-container.break-mode .timer-col {
                width: calc(50% - 10px) !important;
                max-width: calc(50% - 10px) !important;
                min-width: calc(50% - 10px) !important;
            }

            body.theme-minimal .modules-container.break-mode .chat-col {
                max-width: calc(50% - 10px) !important;
                min-width: calc(50% - 10px) !important;
            }
        }

.win-btn {
            width: 29px;
            height: 21px;
            cursor: default;
            padding: 0;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 49%, rgba(255, 255, 255, 0.0) 50%, rgba(255, 255, 255, 0.2) 100%);
            border: 1px solid rgba(0, 0, 0, 0.3);
            border-top: none;
            border-bottom-left-radius: 3px;
            border-bottom-right-radius: 3px;
            color: #000;
            text-shadow: 0 0 4px rgba(255, 255, 255, 0.9);
            font-size: 11px;
            line-height: 18px;
            text-align: center;
        }

.win-btn:hover {
            background: linear-gradient(180deg, rgba(200, 230, 255, 0.8) 0%, rgba(150, 200, 240, 0.7) 49%, rgba(100, 180, 230, 0.5) 50%, rgba(150, 220, 255, 0.7) 100%);
            border-color: rgba(50, 150, 200, 0.9);
            box-shadow: inset 0 0 2px #fff, 0 0 6px rgba(100, 200, 255, 0.9);
        }

.win-btn.close {
            width: 45px;
            font-size: 12px;
        }

.win-btn.close:hover {
            background: linear-gradient(180deg, rgba(240, 150, 150, 0.9) 0%, rgba(220, 100, 100, 0.8) 49%, rgba(200, 50, 50, 0.7) 50%, rgba(230, 100, 100, 0.9) 100%);
            border-color: #800;
            color: #fff;
            text-shadow: 0 0 2px #000;
            box-shadow: inset 0 0 2px #fff, 0 0 8px rgba(255, 50, 50, 0.9);
        }

/* Mobile specific toggles & overlays (Nascosti su Desktop) */
        .mobile-nav-toggle,
        .discord-drawer-overlay {
            display: none;
        }

/* =========================================================
           ANIMAZIONE ESPANSIONE DISCORD DESKTOP (FOCUS MODE)
           ========================================================= */
        @media (min-width: 1001px) {
            body.theme-discord #discord-ui {
                transition: grid-template-columns 0.6s cubic-bezier(0.25, 1, 0.5, 1) !important;
            }

            /* Espansione 50/50 durante il Lavoro */
            body.focus-mode.theme-discord #discord-ui {
                grid-template-columns: 72px 1fr 1fr 240px !important;
            }

            /* Espansione 50/50 durante la Pausa */
            body.break-mode.theme-discord #discord-ui {
                grid-template-columns: 72px 1fr 1fr 240px !important;
            }

            /* Ingrandisce il Timer gradualmente insieme alla barra */
            body.theme-discord .discord-timer-display {
                font-size: 42px;
                transition: font-size 0.6s cubic-bezier(0.25, 1, 0.5, 1);
            }

            body.focus-mode.theme-discord .discord-timer-display {
                font-size: 80px;
            }

            body.break-mode.theme-discord .discord-timer-display {
                font-size: 80px;
            }
        }

/* =========================================================
           OVERLAY COUNTDOWN GLOBALE E MODALS
           ========================================================= */
        #countdown-overlay {
            position: fixed;
            inset: 0;
            z-index: 10005;
            background: rgba(0, 0, 0, 0.6);
            display: none;
            /* Distruzione del nodo quando inattivo */
            align-items: center;
            justify-content: center;
            pointer-events: none;
        }

#countdown-overlay.active {
            display: flex;
            pointer-events: auto;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
        }

#countdown-text {
            font-size: 160px;
            font-weight: bold;
            color: #fff;
            text-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 255, 255, 0.4);
            transform: scale(0.5);
            transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

#countdown-overlay.pop #countdown-text {
            transform: scale(1);
        }

/* Struttura base modale Settings Universale */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.6);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 10002;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }

.modal-overlay.active {
            display: flex;
        }

.alert-box {
            background: #000000d9;
            border: 2px solid #fff;
            border-radius: 12px;
            width: 320px;
            text-align: center;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
            color: #fff;
        }

.alert-header {
            background: linear-gradient(180deg, #515464 0%, #303345 50%, #202334 50%, #151829 100%);
            padding: 14px;
            font-weight: bold;
            font-size: 17px;
            border-bottom: 1px solid #000;
            text-shadow: 0 -1px 0 #000;
        }

.alert-body {
            padding: 24px;
            background: rgba(25, 30, 45, 0.8);
        }

.alert-input {
            width: 100%;
            padding: 10px;
            margin-bottom: 18px;
        }

.alert-btn {
            width: 100%;
            padding: 12px;
            cursor: pointer;
        }

/* Tasto Scroll to Bottom Globale */
        .scroll-bottom-btn {
            position: absolute;
            bottom: 75px;
            right: 20px;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            pointer-events: none;
            transform: translateY(10px);
            transition: opacity 0.3s ease, transform 0.3s ease;
            z-index: 100;
        }

.scroll-bottom-btn.visible {
            opacity: 1;
            pointer-events: auto;
            transform: translateY(0);
        }

textarea.composerInputs, textarea.chat-input, textarea.composer-input, textarea.chat-textarea {
            resize: none;
            overflow-y: auto;
            font-family: inherit;
            white-space: pre-wrap;
        }


/* =========================================================
   OTTIMIZZAZIONI PERFORMANCE: HARDWARE ACCELERATION & CONTAINMENT
   ========================================================= */

/* Isola il ricalcolo dei numeri per impedire shift orizzontali ("balli" tipografici) */
.digits, .lcd-val {
    font-variant-numeric: tabular-nums;
    will-change: contents;
}

/* Isola le zone ad alto refresh per non ricalcolare i background e i blur complessi */
.bezel, .timer-wrapper, .dial-glass, .lcd-screen {
    contain: layout paint;
    transform: translateZ(0); /* Promozione su layer GPU */
}

/* Isola la chat per abbattere i costi di Repaint durante lo scroll e l'arrivo di messaggi */
.chat-messages, .discord-messages {
    contain: layout paint;
    transform: translateZ(0);
}

/* Ottimizzazione massiva per i messaggi: non renderizza quelli fuori dallo schermo */
.msg {
    content-visibility: auto;
    contain-intrinsic-size: 60px;
}


/* MASTER OVERRIDE: Disattiva tutte le animazioni e transizioni globalmente */
body.disable-animations *,
body.disable-animations *::before,
body.disable-animations *::after {
    transition: none !important;
    animation: none !important;
}
