/* 1. RESET E BASE */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    /* 🌌 GRADIENTI DI SFONDO DI BASE */
    --bg-gradient-dark: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --bg-gradient-light: linear-gradient(135deg, #abb9c9, #d8e1e9, #abb9c9);

    /* TEMA SCURO (Default) */
    --login-overlay-bg: #0f0c29;
    --text-primary: #ffffff;
    --text-muted: #b0bec5;
    
    --container-bg: rgba(255, 255, 255, 0.05);
    --container-border: rgba(255, 255, 255, 0.1);
    --container-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
    
    --element-bg: rgba(255, 255, 255, 0.1);
    --element-bg-hover: rgba(255, 255, 255, 0.15);
    --element-border: rgba(255, 255, 255, 0.1);
    
    --dropdown-bg: rgba(10, 10, 25, 0.98);
    --dropdown-border: rgba(255, 255, 255, 0.15);
    --dropdown-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    
    --sub-item-bg: rgba(255, 255, 255, 0.05);
    --sub-item-border: rgba(255, 255, 255, 0.08);
    --sub-item-hover-bg: rgba(10, 10, 25, 1);
    
    --orb-opacity: 0.45;
    --orb-mix-blend: normal;
}

[data-theme="light"] {
    /* ❄️ TEMA CHIARO */
    --login-overlay-bg: #d8e1e9;
    --text-primary: #1e293b; 
    --text-muted: #475569;
    
    --container-bg: rgba(255, 255, 255, 0.35);
    --container-border: rgba(255, 255, 255, 0.6);
    --container-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.08);
    
    --element-bg: rgba(255, 255, 255, 0.5);
    --element-bg-hover: rgba(255, 255, 255, 0.75);
    --element-border: rgba(0, 180, 216, 0.25);
    
    --dropdown-bg: rgba(240, 244, 248, 0.96); 
    --dropdown-border: rgba(0, 180, 216, 0.3);
    --dropdown-shadow: 0 10px 30px rgba(148, 163, 184, 0.2);
    
    --sub-item-bg: rgba(255, 255, 255, 0.6);
    --sub-item-border: rgba(15, 23, 42, 0.06);
    --sub-item-hover-bg: rgba(255, 255, 255, 1);
    
    --orb-opacity: 0.35; 
    --orb-mix-blend: difference;
}

body {
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    min-height: 100vh;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
    transition: color 0.5s ease;
}

/* 🟢 GRADIENTE SCURO (Sempre presente sul fondo) */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-gradient-dark);
    z-index: -2;
    /* Non serve animare l'opacità di questo perché sta sotto */
}

/* 🔵 GRADIENTE CHIARO (Sovrapposto, sfuma da 0 a 1 di opacità) */
body::after {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-gradient-light);
    z-index: -1;
    opacity: 0; /* Invisibile di default nel tema scuro */
    transition: opacity 0.5s ease; /* Transizione incredibilmente morbida di 0.5s */
}

/* Quando si attiva il tema chiaro, facciamo apparire il gradiente chiaro sopra quello scuro */
[data-theme="light"] body::after {
    opacity: 1;
}



/* 2. CONTENITORE PRINCIPALE */
.container {
    background: var(--container-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--container-border);
    box-shadow: var(--container-shadow);
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    padding: 40px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: background-color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease, color 0.5s ease;
}

h1 {
    text-align: center;
    font-weight: 300;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* 3. WRAPPER DEL DROPDOWN (L'ancora) */
.dropdown-container {
    position: relative; /* FONDAMENTALE: ancora la tendina qui */
    width: 100%;
}

/* 4. TASTO PRINCIPALE */
.neumorphic-element {
    background: var(--element-bg) !important;
    border: 1px solid var(--element-border) !important;
    color: var(--text-primary) !important;
    padding: 15px 25px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    text-align: center;
    width: 100%;
    transition: all 0.3s ease !important;
}

.neumorphic-element:hover {
    border-color: rgba(0, 212, 255, 0.6) !important;
    transform: translateY(-2px);
    background: var(--element-bg-hover) !important;
}

/* 5. TENDINA (Modificata) */
.dropdown-content {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: var(--dropdown-bg) !important;
    border: 1px solid var(--dropdown-border);
    border-radius: 15px;
    padding: 15px;
    display: none;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    box-shadow: var(--dropdown-shadow);
    opacity: 0;
    transition: background 0.3s ease, border 0.3s ease;
}

/* Animazione di entrata */
.dropdown-content.show {
    display: flex;
    opacity: 1;
    animation: fadeInDown 0.3s ease forwards;
}

/* Animazione di uscita */
.dropdown-content.hide {
    display: flex;
    animation: fadeOutUp 0.3s ease forwards;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOutUp {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

/* 6. VOCI INTERNE (I comandi) */
.sub-menu-item {
    background: var(--sub-item-bg) !important;
    border: 1px solid var(--sub-item-border) !important;
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.sub-menu-item:hover {
    background: var(--sub-item-hover-bg) !important; 
    border-color: rgba(0, 212, 255, 0.5) !important;
    transform: scale(1.02) translateX(5px);
}

.box-text.placeholder { color: #00d4ff; font-weight: bold; display: block; margin-bottom: 5px; }
.box-text.content { 
    color: var(--text-muted); /* Cambia colore dinamicamente */
    font-family: monospace; 
    font-size: 11px; 
    display: block; 
    white-space: pre-wrap; 
    word-break: break-all; 
    transition: color 0.3s ease;
}

/* 7. MESSAGGI E BLUR */
.copy-message {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
    background: #00d4ff; color: #010114; padding: 12px 25px;
    border-radius: 50px; opacity: 0; transition: 0.3s; z-index: 2000;
    pointer-events: none;
}
.copy-message.show { opacity: 1; }

.container.blur-bg h1, .container.blur-bg .dropdown-container:not(:has(.show)) {
    filter: blur(8px); opacity: 0.3; pointer-events: none;
}

/* LOGIN OVERLAY */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--login-overlay-bg); /* Sfondo dinamico in base al tema */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: background 0.5s ease;
}

.login-box {
    position: relative; /* Necessario per posizionare il pulsante dentro il box di login */
    background: rgba(255, 255, 255, 0.05);
    padding: 45px 40px 40px 40px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.login-box h2 { margin-bottom: 20px; font-weight: 300; }

.login-box input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.2);
    color: white;
    outline: none;
    text-align: center;
}

[data-theme="light"] .login-box {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    color: var(--text-primary);
}

[data-theme="light"] .login-box input {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0,0,0,0.15);
    color: var(--text-primary);
}

.login-box button {
    background: #00d4ff;
    color: #010114;
    border: none;
    padding: 10px 30px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.login-box button:hover { transform: scale(1.05); filter: brightness(1.1); }

.error-msg {
    color: #ff4b2b;
    font-size: 14px;
    margin-top: 15px;
    display: none; /* Nascosto di base */
}

/* =========================================
   8. ORB BACKGROUND (OPTIMIZED)
   ========================================= */
.orb-container {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  contain: paint; /* Limits repaint area */
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: var(--orb-opacity); 
  mix-blend-mode: var(--orb-mix-blend);
  translate: var(--px, 0) var(--py, 0);
  transition: translate 0.1s ease-out, opacity 0.5s ease;
}

.orb-1 {
  width: 450px; height: 450px;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.6) 0%, transparent 75%);
  top: -10%; left: -10%;
  animation: orbFloat1 28s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

.orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(131, 56, 236, 0.6) 0%, transparent 75%);
  bottom: -5%; right: -10%;
  animation: orbFloat2 32s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

.orb-3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(255, 0, 110, 0.5) 0%, transparent 75%);
  top: 45%; left: 55%;
  animation: orbFloat3 26s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

.orb-4 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(6, 214, 160, 0.5) 0%, transparent 75%);
  top: 15%; right: 25%;
  animation: orbFloat4 30s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

/* Keep transforms & opacity only (already GPU-friendly) */
@keyframes orbFloat1 {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(70px, 50px, 0) scale(1.1); }
  100% { transform: translate3d(-30px, 100px, 0) scale(0.95); }
}
@keyframes orbFloat2 {
  0% { transform: translate3d(0, 0, 0) scale(1.05); }
  50% { transform: translate3d(-80px, -40px, 0) scale(0.95); }
  100% { transform: translate3d(50px, -80px, 0) scale(1); }
}
@keyframes orbFloat3 {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(60px, -70px, 0) scale(1.08); }
  100% { transform: translate3d(-70px, 30px, 0) scale(0.92); }
}
@keyframes orbFloat4 {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-50px, 60px, 0) scale(0.98); }
  100% { transform: translate3d(60px, -40px, 0) scale(1.05); }
}

/* ♿ Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  .orb { animation: none !important; }
}

/* =========================================
   9. PULSANTI DI DOWNLOAD (LOGIN & MAIN)
   ========================================= */
.login-downloads {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
    width: 100%;
}

/* Rende gli stili universali per tutti i pulsanti download */
.download-btn {
    flex: 1;
    display: inline-block;
    padding: 12px 15px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important; /* Rimuove la sottolineatura blu del browser */
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    white-space: nowrap;
    text-align: center;
}

/* Variante Cyan */
.download-btn.btn-cyan {
    color: #00d4ff !important;
}
.download-btn.btn-cyan:hover {
    border-color: rgba(0, 212, 255, 0.6) !important;
    background: rgba(0, 212, 255, 0.1) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.2);
}

/* Variante Purple */
.download-btn.btn-purple {
    color: #bf55ec !important; /* Nuovo viola neon ad alta luminosità */
}
.download-btn.btn-purple:hover {
    border-color: rgba(191, 85, 236, 0.7) !important;
    background: rgba(191, 85, 236, 0.15) !important; /* Sfondo hover leggermente più visibile */
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(191, 85, 236, 0.35); /* Alone di luce più intenso */
}

/* Variante White/Gray */
.download-btn.btn-white {
    color: #c7c7c7 !important;
}
.download-btn.btn-white:hover {
    border-color: rgba(255, 255, 255, 0.6) !important;
    background: rgba(255, 255, 255, 0.1) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

/* Layout specifico per la pagina principale */
.main-downloads-section {
    margin-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 25px;
    width: 100%;
}

.main-downloads-section .section-title {
    font-size: 20px;
    font-weight: 300;
    text-align: center;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

/* STILE DEI TASTI DI LOGOUT (In alto a sinistra) */
.logout-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--sub-item-bg);
    border: 1px solid var(--sub-item-border);
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    width: 38px;
    height: 38px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.logout-btn:hover {
    background: var(--element-bg-hover);
    border-color: rgba(255, 75, 75, 0.4); /* Un leggero alone rosso in hover */
    color: #ff4b4b;
    transform: scale(1.1);
}

.logout-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.logout-btn:hover .logout-icon {
    transform: translateX(-2px); /* Sposta leggermente la freccia verso sinistra */
}

/* STILE UNIFICATO PULSANTE SWITCH DENTRO I CONTAINER */
.theme-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--sub-item-bg);
    border: 1px solid var(--sub-item-border);
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    width: 38px;
    height: 38px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.theme-toggle-btn:hover {
    background: var(--element-bg-hover);
    border-color: rgba(0, 212, 255, 0.5);
    transform: scale(1.1);
}

.theme-toggle-btn svg {
    position: absolute;
    width: 18px;
    height: 18px;
    transition: transform 0.4s ease, opacity 0.3s ease, fill 0.3s ease;
}

/* 3. BORDI DEI TASTI DOWNLOAD PER IL TEMA CHIARO */
[data-theme="light"] .download-btn.btn-cyan {
    border: 1px solid rgba(0, 180, 216, 0.4) !important;
}

[data-theme="light"] .download-btn.btn-purple {
    border: 1px solid rgba(191, 85, 236, 0.5) !important; /* Bordo coordinato e ben visibile sul chiaro */
}

[data-theme="light"] .download-btn.btn-white {
    border: 1px solid rgba(30, 41, 59, 0.3) !important;
    color: var(--text-primary) !important;
}

/* 🛠️ CONTROLLO ICONE (RISOLVE LA SOVRAPPOSIZIONE) */
/* Quando siamo in Dark Mode (Default o data-theme="dark") */
html:not([data-theme="light"]) .sun-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}
html:not([data-theme="light"]) .moon-icon {
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

/* Quando siamo in Light Mode */
[data-theme="light"] .sun-icon {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}
[data-theme="light"] .moon-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}