/* --- CONFIGURACIÓN BASE --- */
body {
    font-family: 'Poppins', sans-serif;
    margin: 0; padding: 0;
    height: 100dvh; width: 100vw;
    overflow: hidden;
    background-color: #0f172a;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.5s ease;
}

#main-app { height: 100%; width: 100%; display: flex; flex-direction: column; }

/* Vista Desktop */
@media (min-width: 768px) {
    body { display: flex; align-items: center; justify-content: center; }
    #main-app { height: 90vh; width: 420px; border-radius: 32px; overflow: hidden; box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6); }
}

/* --- ANIMACIONES --- */
@keyframes gradientBG { 
    0% { background-position: 0% 50%; } 
    50% { background-position: 100% 50%; } 
    100% { background-position: 0% 50%; } 
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-4px, -4px); }
    20%, 40%, 60%, 80% { transform: translate(4px, 4px); }
}
.shake-effect { animation: shake 0.5s; border: 4px solid #facc15 !important; }

@keyframes highlightPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.7); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px 10px rgba(250, 204, 21, 0); background-color: rgba(250, 204, 21, 0.3); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(250, 204, 21, 0); }
}
.highlight-msg { animation: highlightPulse 1.5s ease-out; z-index: 10; position: relative; border: 2px solid #facc15 !important; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out; }
.reply-bar { animation: slideUp 0.2s ease-out; }

/* --- TEMAS VISUALES --- */
/* Danny */
body.theme-danny { 
    background: linear-gradient(-45deg, #fdfbf7, #f3e5ab, #d4a5a5, #701919); 
    background-size: 400% 400%; animation: gradientBG 15s ease infinite; 
}
html.dark body.theme-danny { 
    background: linear-gradient(-45deg, #1a0505, #2b0808, #4a0d0d, #000000) !important; 
    background-size: 400% 400%; 
}

/* Andreita */
body.theme-andreita { 
    background: linear-gradient(-45deg, #ffffff, #E6E6FA, #D8BFD8, #dda0dd); 
    background-size: 400% 400%; animation: gradientBG 15s ease infinite; 
}
html.dark body.theme-andreita { 
    background: linear-gradient(-45deg, #10002b, #240046, #3c096c, #000000) !important; 
    background-size: 400% 400%; 
}

/* --- CRISTAL (UI) --- */
.glass-panel { 
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4); 
    transition: all 0.4s ease;
    color: #333;
}
html.dark .glass-panel { 
    background: rgba(20, 20, 20, 0.85); 
    border-color: rgba(255,255,255,0.08); 
    color: #e2e8f0;
}

.glass-input { 
    background: rgba(255, 255, 255, 0.5); 
    border: 1px solid rgba(0,0,0,0.1); 
    color: #333; 
}
html.dark .glass-input { 
    background: rgba(255, 255, 255, 0.1); 
    border: 1px solid rgba(255,255,255,0.2); 
    color: white; 
}
.glass-input::placeholder { color: inherit; opacity: 0.6; }

/* --- BURBUJAS CHAT --- */
.message-bubble { 
    max-width: 85%; padding: 10px 14px; border-radius: 18px; 
    position: relative; font-size: 0.95rem; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
    word-wrap: break-word; user-select: none; 
    transition: transform 0.1s; cursor: pointer; 
}
.message-bubble:active { transform: scale(0.98); }
.message-bubble.deleted { font-style: italic; opacity: 0.7; background: rgba(100,100,100,0.1) !important; border: 1px dashed currentColor; }

/* Colores Danny */
.theme-danny .msg-sent { background-color: #701919; color: #fff8e1; border-bottom-right-radius: 2px; }
.theme-danny .msg-received { background-color: #ffffff; color: #333; border-bottom-left-radius: 2px; }
html.dark .theme-danny .msg-sent { background-color: #9b2226; color: #fff; }

/* Colores Andreita */
.theme-andreita .msg-sent { background-color: #9d4edd; color: white; border-bottom-right-radius: 2px; }
.theme-andreita .msg-received { background-color: #ffffff; color: #333; border-bottom-left-radius: 2px; }
html.dark .theme-andreita .msg-sent { background-color: #7b2cbf; color: #fff; }

/* Global Received Dark */
html.dark .msg-received { background-color: #334155 !important; color: #f1f5f9 !important; }

/* --- COMPONENTES --- */
.ui-bar { background: rgba(255,255,255,0.4); backdrop-filter: blur(20px); border-top: 1px solid rgba(255,255,255,0.2); transition: background 0.3s; }
html.dark .ui-bar { background: rgba(15, 23, 42, 0.9); border-color: rgba(255,255,255,0.05); }

.action-btn { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: all 0.2s; color: #555; cursor: pointer; }
html.dark .action-btn { color: #cbd5e1; }
.action-btn:active { transform: scale(0.9); background: rgba(0,0,0,0.1); }

.reply-preview { border-left: 4px solid; padding: 4px 8px; margin-bottom: 6px; font-size: 0.75rem; background: rgba(0,0,0,0.05); border-radius: 4px; cursor: pointer; transition: background 0.2s; }
html.dark .reply-preview { background: rgba(255,255,255,0.1); }

/* Notas */
.note-card {
    color: #333;
    transform: rotate(-1deg);
    box-shadow: 2px 4px 8px rgba(0,0,0,0.15);
    font-family: 'Poppins', sans-serif;
    padding: 12px;
    border-radius: 4px;
    position: relative;
    transition: transform 0.2s;
}
.note-card:hover { transform: scale(1.02) rotate(0deg); z-index: 10; }
.note-card p { font-weight: 500; font-size: 0.9rem; line-height: 1.4; }

/* Context Menu */
#context-menu { position: fixed; z-index: 100; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); border-radius: 12px; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,0.2); transform: scale(0); transition: transform 0.1s ease; transform-origin: top left; min-width: 160px; }
html.dark #context-menu { background: rgba(30, 30, 40, 0.95); border: 1px solid rgba(255,255,255,0.1); }
#context-menu.visible { transform: scale(1); }
.ctx-item { padding: 12px 20px; color: #333; font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(0,0,0,0.05); }
html.dark .ctx-item { color: #e2e8f0; border-color: rgba(255,255,255,0.1); }
.ctx-item:active { background: rgba(0,0,0,0.05); }
html.dark .ctx-item:active { background: rgba(255,255,255,0.1); }
.ctx-item:last-child { border-bottom: none; }

.hidden { display: none !important; }
.text-input { background: rgba(255,255,255,0.5); border: 1px solid rgba(0,0,0,0.1); color: #333; border-radius: 20px; padding: 10px 15px; outline: none; }
html.dark .text-input { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); color: white; }
.text-input::placeholder { color: inherit; opacity: 0.5; }

/* Stickers */
.sticker-img { width: 90px; height: 90px; object-fit: contain; cursor: pointer; transition: transform 0.1s; }
.sticker-img:active { transform: scale(0.9); }
lottie-player { width: 120px; height: 120px; cursor: pointer; }
.tgs-msg lottie-player { width: 140px; height: 140px; }

/* Tabs Stickers */
.sticker-tab { opacity: 0.5; transition: opacity 0.2s; border-bottom: 2px solid transparent; }
.sticker-tab.active { opacity: 1; border-color: currentColor; }