/* ==========================================
   1. CONFIGURAZIONE TAVOLOZZE TEMI + SFONDI
   ========================================== */
.theme-default {
    --bg-main: #f4f7f6;
    --bg-chat: #f0f4f8;
    --bg-chat-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='20' cy='20' r='1' fill='%23cbd5e1'/%3E%3C/svg%3E");
    --bg-chat-size: 40px 40px;
    --bg-header: rgba(255, 255, 255, 0.85);
    --text-color: #1e293b;
    --text-muted: #64748b;
    --accent: #00adb5;
    --border-color: rgba(226, 232, 240, 0.6);
    --input-bg: rgba(255, 255, 255, 0.7);
    --led-color: #00adb5;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --border-radius: 20px;
}

.theme-whatsapp {
    --bg-main: #efeae2;
    --bg-chat: #efeae2;
    --bg-chat-image: url("data:image/svg+xml,%3Csvg width='50' height='50' viewBox='0 0 50 50' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M25 25c-1.5 0-2.5-1-2.5-2.5S23.5 20 25 20s2.5 1 2.5 2.5S26.5 25 25 25zm-10 10c-1.5 0-2.5-1-2.5-2.5S13.5 30 15 30s2.5 1 2.5 2.5S16.5 35 15 35zm20 0c-1.5 0-2.5-1-2.5-2.5S33.5 30 35 30s2.5 1 2.5 2.5S36.5 35 35 35z' fill='%23111b21' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
    --bg-chat-size: 50px 50px;
    --bg-header: #008069;
    --text-color: #111b21;
    --text-muted: #667781;
    --accent: #00a884;
    --border-color: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
    --led-color: #25d366;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --border-radius: 16px;
}

.theme-telegram {
    --bg-main: #e7ebf0;
    --bg-chat: #9bbadd;
    --bg-chat-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 30l15-15 15 15-15 15L30 30zm-15 15L0 30l15-15 15 15-15 15z' fill='%23ffffff' fill-opacity='0.15' fill-rule='evenodd'/%3E%3C/svg%3E");
    --bg-chat-size: 60px 60px;
    --bg-header: rgba(36, 129, 204, 0.9);
    --text-color: #000000;
    --text-muted: #5e6c7a;
    --accent: #2481cc;
    --border-color: rgba(255, 255, 255, 0.2);
    --input-bg: rgba(255, 255, 255, 0.9);
    --led-color: #2da5e1;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --border-radius: 18px;
}

.theme-terminal {
    --bg-main: #000000;
    --bg-chat: #050505;
    --bg-chat-image: linear-gradient(rgba(0, 255, 0, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 255, 0, 0.03) 1px, transparent 1px);
    --bg-chat-size: 25px 25px;
    --bg-header: #000000;
    --text-color: #00ff00;
    --text-muted: #008800;
    --accent: #00ff00;
    --border-color: #00ff00;
    --input-bg: rgba(0, 0, 0, 0.8);
    --led-color: #00ff00;
    --font-family: 'Courier New', Courier, monospace;
    --border-radius: 4px;
}

/* ==========================================
   2. REGOLE STRUTTURALI BASE
   ========================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { 
    background-color: var(--bg-main); 
    color: var(--text-color); 
    font-family: var(--font-family); 
    height: 100%; 
    width: 100%;
    overflow: hidden; 
    position: fixed; 
    -webkit-font-smoothing: antialiased;
}

#app-container { 
    position: absolute; top: 0; bottom: 0; left: 0; right: 0; 
    display: flex; flex-direction: column; 
}

.view-panel { 
    flex: 1; display: flex; flex-direction: column; 
    width: 100%; max-width: 900px; margin: 0 auto; overflow: hidden; 
}

.align-icon { vertical-align: middle; margin-right: 6px; }
.hidden { display: none !important; }

/* ==========================================
   3. DASHBOARD
   ========================================== */
#view-dashboard { padding: 40px 24px; justify-content: flex-start; overflow-y: auto; }
.dashboard-header { text-align: center; margin-bottom: 30px; }
.dashboard-header p { color: var(--text-muted); font-size: 1rem; font-weight: 400; }

.app-logo-text {
    font-family: 'Orbitron', sans-serif; font-size: 3.2rem;
    margin-bottom: 12px; letter-spacing: 1.5px;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.text-cyan { color: var(--accent); }
.text-dark { color: var(--text-color); }

.dashboard-actions { display: flex; flex-direction: column; align-items: center; justify-content: center; margin-bottom: 40px; width: 100%; }

.btn-primary { 
    background-color: var(--accent); color: white; border: none; 
    padding: 18px 36px; font-size: 1.3rem; font-weight: 700; 
    border-radius: var(--border-radius); cursor: pointer; width: 100%; max-width: 440px; 
    box-shadow: 0 8px 24px rgba(0, 173, 181, 0.3); 
    transition: transform 0.2s, box-shadow 0.2s; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
}
.btn-primary:active { transform: scale(0.97); box-shadow: 0 4px 12px rgba(0, 173, 181, 0.2); }
.theme-terminal .btn-primary { color: #000; background-color: #00ff00; box-shadow: 0 0 10px #00ff00; border: none; }

.contacts-section { 
    background: var(--bg-chat); padding: 24px; 
    border-radius: var(--border-radius); border: 1px solid var(--border-color); 
    box-shadow: 0 8px 24px rgba(0,0,0,0.03); 
}
.contacts-section h3 { font-size: 1.2rem; font-weight: 600; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.empty-list-text { color: var(--text-muted); font-style: italic; font-size: 0.95rem; text-align: center; padding: 20px 0; }
.recent-chat-item { display: flex; justify-content: space-between; align-items: center; padding: 14px; border-bottom: 1px solid var(--border-color); cursor: pointer; transition: background 0.2s; font-size: 1.05rem; font-weight: 500; }
.recent-chat-item:hover { background: rgba(0,0,0,0.02); }

.chat-actions-btn button { font-size: 1.2rem; padding: 6px; border-radius: 8px; transition: background 0.2s; display: flex; align-items: center; justify-content: center; }
.chat-actions-btn button:hover { background: rgba(0,0,0,0.05); }

.discreet-btn {
    background: transparent; color: var(--text-muted); border: 1px solid var(--border-color);
    padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.85rem;
    display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s; font-family: inherit;
}
.discreet-btn:hover { background: rgba(0,0,0,0.05); color: var(--text-color); }

/* ==========================================
   4. CHAT E GLASSMORPHISM
   ========================================== */
#top-bar { 
    flex: 0 0 auto; background-color: var(--bg-header); padding: 12px 18px; 
    display: flex; justify-content: space-between; align-items: center; 
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
#btn-back-dashboard { background: transparent; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-color); font-family: inherit; font-weight: 600;}
.theme-whatsapp #btn-back-dashboard, .theme-telegram #btn-back-dashboard { color: white; }
.brand-info { display: flex; flex-direction: column; }
#app-title { font-size: 1.2rem; font-weight: 700; color: var(--text-color); }
#partner-codename { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.theme-whatsapp #app-title, .theme-telegram #app-title { color: #ffffff; }
.theme-whatsapp #partner-codename, .theme-telegram #partner-codename { color: rgba(255,255,255,0.9); }

#led-scanner { flex: 0 0 auto; width: 100%; height: 2px; background: linear-gradient(90deg, transparent, var(--led-color), transparent); background-size: 200% 100%; animation: sweep 2.5s linear infinite; box-shadow: 0 1px 8px var(--led-color); z-index: 10; }
@keyframes sweep { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

#chat-messages { 
    flex: 1 1 auto; overflow-y: auto; padding: 20px 15px; display: flex; flex-direction: column; 
    background-color: var(--bg-chat); background-image: var(--bg-chat-image); background-size: var(--bg-chat-size);
}

.empty-state { 
    text-align: center; margin: auto; padding: 24px; color: var(--text-color); 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-radius: 24px; border: 1px solid rgba(255, 255, 255, 0.5); 
    box-shadow: 0 8px 32px rgba(0,0,0,0.05); 
}
.theme-terminal .empty-state { background: rgba(0,0,0,0.8); border: 1px solid #00ff00; color: #00ff00; }

/* Bolle Messaggi (Modern UI) */
.msg-row { 
    display: flex; margin-bottom: 16px; width: 100%; 
    animation: slideUp 0.35s cubic-bezier(0.25, 1, 0.5, 1) forwards; 
    opacity: 0; transform: translateY(12px); 
}
@keyframes slideUp { to { opacity: 1; transform: translateY(0); } }

.msg-row.me { justify-content: flex-end; }
.msg-row.partner { justify-content: flex-start; }

.msg-bubble { 
    max-width: 80%; padding: 12px 16px 8px 16px; position: relative; font-size: 1rem; line-height: 1.45; 
    display:flex; flex-direction:column; min-width: 90px;
    border-radius: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.06);
}

.msg-row.me .msg-bubble { 
    background-color: var(--accent); color: #ffffff; 
    border-bottom-right-radius: 4px; /* Codino moderno */
}
.msg-row.partner .msg-bubble { 
    background-color: rgba(255, 255, 255, 0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5); color: var(--text-color); 
    border-bottom-left-radius: 4px; 
}
.theme-terminal .msg-row.partner .msg-bubble { background: rgba(0, 0, 0, 0.8); border: 1px solid #00ff00; color: #00ff00; }

.sender-name { font-size: 0.75rem; font-weight: 700; margin-bottom: 6px; opacity: 0.8; letter-spacing: 0.5px; }
.msg-time { font-size: 0.65rem; opacity: 0.7; text-align: right; margin-top: 6px; display: block; align-self: flex-end; font-weight: 500; }

/* Floating Input Area (Glassmorphism) */
#chat-input-area { 
    flex: 0 0 auto; display: flex; gap: 8px; padding: 8px 10px; 
    margin: 0 12px 20px 12px; /* Staccato dai bordi */
    background: var(--input-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color); border-radius: 30px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.08); align-items: center;
} 
.theme-terminal #chat-input-area { box-shadow: 0 0 15px rgba(0,255,0,0.1); border-radius: 8px; }

#message-input { 
    flex: 1; background: transparent; border: none; color: var(--text-color); 
    padding: 0 12px; height: 40px; outline: none; font-size: 1rem; min-width: 0; font-family: inherit; 
}
#message-input::placeholder { color: var(--text-muted); opacity: 0.7; }

.media-buttons { display: flex; gap: 4px; }
.media-buttons button { 
    position: relative; background: transparent; border: none; color: var(--text-muted); 
    width: 38px; height: 38px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; 
    transition: background 0.2s, color 0.2s; 
}
.media-buttons button:hover { background: rgba(0,0,0,0.05); color: var(--accent); }
.theme-terminal .media-buttons button:hover { background: rgba(0,255,0,0.1); color: #00ff00; }

.lock-icon { position: absolute; top: -2px; right: -2px; font-size: 0.65rem; background: #e53e3e; color: white; border-radius: 50%; padding: 3px; box-shadow: 0 2px 6px rgba(229,62,62,0.5); display: flex; align-items: center; justify-content: center;}

#send-button { 
    background-color: var(--accent); color: #ffffff; border: none; width: 42px; height: 42px; 
    border-radius: 50%; cursor: pointer; display:flex; align-items:center; justify-content:center; 
    box-shadow: 0 4px 12px rgba(0, 173, 181, 0.4); transition: transform 0.2s; 
}
#send-button:hover { transform: scale(1.05); }

/* ==========================================
   5. OVERLAYS E PANNELLI (GLASS)
   ========================================== */
#splash-screen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: #0a0a0a; display: flex; justify-content: center; align-items: center; z-index: 9999; transition: opacity 0.4s, visibility 0.4s; }
#splash-screen.fade-out { opacity: 0; visibility: hidden; }
.splash-content { text-align: center; }
#splash-logo { width: 75px; height: 75px; margin-bottom: 15px; animation: pulseLed 1.4s infinite alternate; }
#splash-title { color: #00d4ff; font-family: 'Courier New', monospace; font-size: 1.5rem; font-weight: bold; letter-spacing: 3px; }
@keyframes pulseLed { 0% { transform: scale(0.97); filter: drop-shadow(0 0 4px #00d4ff); } 100% { transform: scale(1.03); filter: drop-shadow(0 0 14px #00d4ff); } }

/* Orologio Digitale */
.digital-clock {
    font-family: 'Orbitron', monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: #e53e3e;
    letter-spacing: 2px;
}
.theme-terminal .digital-clock { color: #00ff00; }

/* Modali Sfondate */
#legal-shield-modal, #paywall-screen, #share-room-overlay { 
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; 
    background: rgba(0,0,0,0.8); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); 
    display: flex; justify-content: center; align-items: center; z-index: 10000; 
}

.legal-box, .paywall-box, #share-room-box { 
    background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 30px; border-radius: 24px; max-width: 400px; width: 90%; text-align: center; color: #1e293b; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
}
.theme-terminal .legal-box, .theme-terminal .paywall-box, .theme-terminal #share-room-box { background: #000; border: 1px solid #00ff00; color: #00ff00; }

.paywall-box h2 { margin-bottom: 12px; color: #e53e3e; display:flex; justify-content:center; align-items:center; }
#pay-button { background: var(--accent); color: #fff; border: none; padding: 14px 28px; font-weight: bold; border-radius: 12px; cursor: pointer; margin-top: 20px; font-family: inherit; width: 100%; box-shadow: 0 4px 12px rgba(0, 173, 181, 0.3); }

#share-room-box p { margin-bottom: 15px; font-weight: 600; font-size: 1rem; }
#room-share-url { width: 100%; padding: 14px; border: 1px solid var(--border-color); background: rgba(0,0,0,0.03); color: var(--text-color); border-radius: 12px; font-size: 1rem; font-weight: bold; text-align: center; outline: none; margin-bottom: 15px; }
#btn-copy-url { background: var(--accent); color: white; border: none; padding: 14px; border-radius: 12px; cursor: pointer; font-weight: bold; font-size: 1.1rem; font-family: inherit; box-shadow: 0 4px 12px rgba(0, 173, 181, 0.3); }
#btn-close-share { margin-top: 15px; background: transparent; color: var(--text-muted); border: none; font-weight: 600; cursor: pointer; text-decoration: none; padding: 8px;}

/* ==========================================
   6. COMPONENTI UI MINORI
   ========================================== */
.timer-selector-container { width: 100%; max-width: 440px; text-align: left; margin-bottom: 25px; }
#timer-buttons { display: flex; gap: 8px; width: 100%; }
.timer-btn { 
    flex: 1; padding: 12px 4px; border-radius: 14px; border: 1px solid var(--border-color); 
    background: var(--bg-chat); color: var(--text-color); font-weight: 600; font-size: 0.9rem; 
    cursor: pointer; transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1); display: flex; flex-direction: column; 
    align-items: center; justify-content: center; font-family: inherit; 
}
.timer-btn:hover { background: var(--input-bg); }
.timer-btn.active { background: var(--accent); color: white; border-color: var(--accent); box-shadow: 0 6px 16px rgba(0, 173, 181, 0.3); transform: scale(1.05); }

#upload-progress-container { 
    flex: 0 0 auto; margin: 0 12px 10px 12px; height: 20px; 
    background: rgba(0,0,0,0.05); border-radius: 10px; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; 
}
#upload-progress-bar { position: absolute; top: 0; left: 0; height: 100%; background: var(--accent); width: 0%; transition: width 0.2s ease-out; z-index: 1; }
#upload-progress-text { position: relative; z-index: 2; font-size: 0.75rem; font-weight: bold; color: white; mix-blend-mode: difference; }

/* ==========================================
   7. MODALI DI SICUREZZA (LEGALE E DOWNLOAD)
   ========================================== */
.legal-box h2 { color: var(--accent); margin-bottom: 15px; font-size: 1.4rem; text-align: center; }
.legal-text { font-size: 0.95rem; line-height: 1.5; margin-bottom: 20px; text-align: center; }
.legal-text p { margin-bottom: 10px; }
.warning-text { color: #e53e3e; font-weight: bold; }
.tip-box { background: rgba(0, 173, 181, 0.1); padding: 12px; border-radius: 10px; border-left: 4px solid var(--accent); margin-top: 15px; font-size: 0.85rem; text-align: left; }
#btn-accept-legal {
    width: 100%; background: var(--accent); color: white; border: none; padding: 14px;
    border-radius: 12px; font-size: 1.1rem; font-weight: bold; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 173, 181, 0.3); font-family: inherit;
}
.theme-terminal .warning-text { color: #ff0000; }
.theme-terminal .tip-box { background: rgba(0,255,0,0.1); border-color: #00ff00; }