@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --bg-dark: #020617;
    --bg-card: rgba(15, 23, 42, 0.8);
    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Outfit', sans-serif; }

/* Clase de utilidad global para ocultar elementos */
.hidden { display: none !important; }

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

#app { position: relative; height: 100vh; display: flex; flex-direction: column; }

/* --- Top Bar --- */
.top-bar {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 70px;
    z-index: 100;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.top-actions { display: flex; gap: 0.6rem; align-items: center; margin-left: auto; }

/* Media Query para Móviles (Android/iOS) */
@media (max-width: 600px) {
    .top-bar { 
        height: auto; 
        padding: 0.8rem 1rem; 
        flex-direction: column; 
        gap: 0.8rem; 
        text-align: center;
    }
    .logo { margin: 0 auto; font-size: 1.5rem; }
    .top-actions { 
        margin-left: 0; 
        width: 100%; 
        justify-content: center; 
        gap: 0.4rem; 
        flex-wrap: wrap;
    }
    .select-camera { max-width: 100px; font-size: 0.75rem; }
    .btn span { display: none; } /* Ocultar texto de botones en móvil para ahorrar espacio */
    .btn i { font-size: 1.1rem; margin: 0; }
    .icon-btn { padding: 0.6rem; }
}


/* --- Botones responsive --- */
.btn {
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: white;
    font-size: 0.82rem;
    background: rgba(255,255,255,0.05);
    white-space: nowrap;
    text-align: center;
    min-width: 0;
    flex-shrink: 0;
}

.btn-primary { background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple)); border: none; }
.btn-secondary { background: rgba(255,255,255,0.08); }
.btn-danger { background: var(--danger); border: none; }
.btn-full { width: 100%; margin-top: 0.8rem; justify-content: center; padding: 0.8rem 1rem; font-size: 0.95rem; border-radius: 12px; }
.icon-btn { padding: 0.5rem 0.7rem; }

/* FIX: Select e Inputs con contraste real */
select, input, textarea {
    background: #1e293b !important; /* Fondo oscuro sólido para selects */
    color: #ffffff !important;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.6rem;
    outline: none;
}

select option {
    background: #1e293b;
    color: white;
    padding: 10px;
}

.select-camera { max-width: 130px; }

/* --- AR Elements --- */
.scanner-container { position: relative; flex: 1; background: #000; overflow: hidden; }
#video { width: 100%; height: 100%; object-fit: cover; }
#canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

.ar-card {
    position: absolute;
    z-index: 20;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--accent-cyan);
    border-radius: 20px;
    padding: 1.2rem;
    width: 260px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.ar-card.hidden { display: none; }

.avatar { width: 60px; height: 60px; border-radius: 50%; border: 2px solid var(--accent-cyan); object-fit: cover; }
.user-info h2 { font-size: 1.1rem; }
.user-info p { font-size: 0.85rem; color: var(--accent-cyan); }
.card-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 0.8rem; gap: 0.5rem; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.7rem; }
.badge { font-size: 0.7rem; color: var(--accent-cyan); border: 1px solid var(--accent-cyan); padding: 2px 8px; border-radius: 10px; }

/* --- Social Orbit --- */
.social-orbit { 
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; height: 100%; 
    z-index: 150; /* Por encima de casi todo */
    pointer-events: none; 
}
.social-icon-mini {
    position: absolute;
    width: 40px; 
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--accent-cyan);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; cursor: pointer; pointer-events: auto !important;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 160;
}
.social-icon i { color: white !important; width: 26px; height: 26px; }
.social-icon.expanded { width: 180px; border-radius: 25px; justify-content: flex-start; padding-left: 12px; background: #8b5cf6; }
.info-text { display: none; margin-left: 8px; font-size: 0.75rem; font-weight: 600; }
.social-icon.expanded .info-text { display: block; }

/* --- Config Panel --- */
.config-panel {
    position: fixed; top: 0; right: 0; width: 380px; max-width: 100vw; height: 100vh;
    background: #0f172a; border-left: 1px solid var(--glass-border);
    z-index: 200; padding: 1.5rem; display: flex; flex-direction: column;
    transition: transform 0.3s ease;
    overflow-x: hidden;
    box-sizing: border-box;
}
.config-panel * { box-sizing: border-box; }
.config-panel.hidden { transform: translateX(100%); }

.config-footer { 
    margin-top: auto; 
    padding: 1.5rem 0; 
    display: flex; 
    flex-direction: column; 
    gap: 0.8rem;
    border-top: 1px solid var(--glass-border);
}
@media (max-width: 600px) {
    .config-footer { padding-bottom: 5rem; } /* Espacio extra para el botón de borrar en móvil */
}

.config-content { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 2rem; width: 100%; }
section { margin-bottom: 2rem; width: 100%; }
section h3 { font-size: 0.8rem; color: var(--accent-cyan); text-transform: uppercase; margin-bottom: 1rem; }

.input-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; width: 100%; }
.input-group label { font-size: 0.8rem; color: var(--text-secondary); }

/* Item de configuración social con privacidad */
.social-config-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.social-item-header { display: flex; align-items: center; gap: 0.5rem; color: var(--text-secondary); font-size: 0.8rem; }
.social-item-controls { display: flex; gap: 0.5rem; }
.social-item-controls input { flex: 1; font-size: 0.8rem; }
.social-item-controls select { width: 90px; font-size: 0.7rem; padding: 0.3rem; }

/* Modales */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 500;
    display: flex; align-items: center; justify-content: center;
}
.modal-content {
    background: #0f172a; 
    width: 90%; 
    max-width: 500px;
    border-radius: 24px; 
    border: 1px solid rgba(6, 182, 212, 0.2);
    padding: 2rem; 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-height: 90vh; 
    display: flex; 
    flex-direction: column;
    position: relative;
}
@media (max-width: 600px) {
    .modal-content {
        width: 95%;
        padding: 1.5rem 1.2rem;
    }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }

.viewer-controls { display: flex; gap: 1rem; margin-bottom: 1rem; }

/* Gestor de Archivos */
.upload-zone {
    border: 2px dashed var(--glass-border);
    padding: 1.5rem; text-align: center; border-radius: 12px;
    margin-bottom: 1rem; cursor: pointer; transition: border 0.3s;
}
.upload-zone:hover { border-color: var(--accent-cyan); }
.upload-zone p { font-size: 0.8rem; color: var(--text-secondary); }

.file-list-editor { display: flex; flex-direction: column; gap: 0.8rem; width: 100%; }
.file-edit-item {
    background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border);
    border-radius: 10px; padding: 0.8rem;
    display: flex; flex-direction: column; gap: 0.5rem;
    width: 100%; box-sizing: border-box; /* Asegura que no se pase del ancho */
}
.file-edit-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; width: 100%; }
.file-edit-header span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.file-edit-controls { display: flex; flex-direction: column; gap: 0.3rem; width: 100%; }
.file-edit-controls select { flex: 1; font-size: 0.7rem; }
.btn-icon-danger { color: var(--danger); background: none; border: none; cursor: pointer; }

/* Modal Body Items */
.modal-file-card {
    background: rgba(255,255,255,0.05); padding: 1rem; border-radius: 15px;
    display: flex; align-items: center; justify-content: space-between;
}
.file-info { display: flex; align-items: center; gap: 0.8rem; }
.file-info i { font-size: 1.2rem; color: var(--accent-cyan); }
.file-info span { font-size: 0.9rem; font-weight: 500; }

.debug-console {
    position: absolute; bottom: 10px; left: 10px; 
    font-family: monospace; font-size: 10px; color: #0f0; 
    background: rgba(0,0,0,0.5); padding: 5px; z-index: 1000; pointer-events: none;
}

.stealth-container { display: flex; align-items: center; gap: 0.5rem; margin-left: 1rem; border-left: 1px solid var(--glass-border); padding-left: 1rem; }
.stealth-toggle { position: relative; width: 40px; height: 20px; }
.stealth-toggle { position: relative; display: inline-block; width: 60px; height: 28px; }
.stealth-toggle input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #475569; transition: .4s; border-radius: 34px; border: 1px solid rgba(255,255,255,0.1); }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 3px; background: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,0.5); z-index: 2; }
.slider:after { content: "I"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 10px; font-weight: bold; color: rgba(255,255,255,0.5); transition: .4s; }

input:checked + .slider { background: #10b981; }
input:checked + .slider:before { transform: translateX(32px); }
input:checked + .slider:after { content: "V"; left: 10px; right: auto; color: white; }


@media (max-width: 500px) { .config-panel { width: 100%; } }

/* ── Mensajería ── */
.chat-input-area { display: flex; gap: 0.5rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--glass-border); }
.chat-input-area input { flex: 1; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 20px; padding: 0.8rem 1.2rem; color: white; outline: none; }
.chat-input-area input:focus { border-color: var(--accent-cyan); }
#msg-modal-body { display: flex; flex-direction: column; gap: 0.5rem; height: 350px; overflow-y: auto; overflow-x: hidden; position: relative; }
.chat-bubble { padding: 0.8rem 1.2rem; border-radius: 15px; max-width: 85%; font-size: 0.85rem; line-height: 1.4; }
.chat-bubble.sent { background: var(--accent-cyan); color: #0f172a; align-self: flex-end; border-bottom-right-radius: 2px; box-shadow: 0 4px 15px rgba(6,182,212,0.3); }
.chat-bubble.received { background: #1e293b; color: white; align-self: flex-start; border-bottom-left-radius: 2px; border: 1px solid var(--glass-border); box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.chat-time { font-size: 0.65rem; opacity: 0.7; display: block; margin-top: 4px; text-align: right; }

/* Inbox List */
.inbox-list { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
.inbox-item { 
    display: flex; align-items: center; gap: 1rem; padding: 1rem; 
    background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border); 
    border-radius: 15px; cursor: pointer; transition: all 0.2s; 
}
.inbox-item:hover { background: rgba(255,255,255,0.08); border-color: var(--accent-cyan); }
.inbox-avatar { width: 45px; height: 45px; border-radius: 50%; object-fit: cover; border: 2px solid var(--glass-border); }
.inbox-item.self-note .inbox-avatar { border-color: var(--accent-cyan); background: #1e293b; display:flex; align-items:center; justify-content:center; }
.inbox-details { flex: 1; overflow: hidden; }
.inbox-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 3px; display: flex; justify-content: space-between; }
.inbox-last-msg { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-time { font-size: 0.7rem; color: var(--text-secondary); font-weight: normal; }


/* ── Welcome Overlay ── */
.welcome-overlay { 
    position: absolute; inset: 0; 
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.95), var(--bg-dark)); 
    backdrop-filter: blur(15px); 
    display: flex; align-items: center; justify-content: center; 
    z-index: 500; 
}
.welcome-content { 
    text-align: center; padding: 2rem; width: 100%; max-width: 400px; 
    animation: fadeIn 0.8s ease-out;
}
.welcome-icon { font-size: 5rem; color: var(--accent-cyan); margin-bottom: 1.5rem; filter: drop-shadow(0 0 15px var(--accent-cyan)); animation: pulse 2s infinite; }
.welcome-content h2 { 
    font-size: 2.2rem; font-weight: 800; margin-bottom: 1rem; 
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 30%, var(--accent-cyan)); 
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; 
}
.welcome-content p { color: var(--text-secondary); margin-bottom: 2.5rem; line-height: 1.6; font-size: 1.1rem; }

/* ── Modal de Registro Móvil ── */
.modal-content {
    width: 92%;
    max-height: 85vh;
    padding: 2rem 1.5rem;
    overflow-y: auto;
    background: #0f172a;
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.face-scan-area { 
    text-align: center; padding: 2.5rem 1rem; 
    background: rgba(6, 182, 212, 0.05); 
    border: 2px dashed rgba(6, 182, 212, 0.3); 
    border-radius: 20px; margin-bottom: 1.5rem; 
}
.scan-icon { font-size: 4rem; color: var(--accent-cyan); margin-bottom: 1.5rem; animation: pulse 2s infinite; }

/* ── Registro Exitoso ── */
.reg-success { text-align: center; padding: 1.5rem 0; }
.reg-success i { font-size: 4.5rem; color: var(--success); margin-bottom: 1.5rem; display: block; filter: drop-shadow(0 0 10px var(--success)); }
.reg-success h4 { font-size: 1.5rem; margin-bottom: 0.8rem; color: #fff; }
.reg-success p { color: var(--text-secondary); font-size: 1rem; margin-bottom: 2rem; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100%{transform:scale(1);opacity:1;} 50%{transform:scale(1.08);opacity:0.8;} }



/* Mensajería y Chat */
.chat-input-area { display: flex; gap: 0.5rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--glass-border); }
.chat-input-area input { flex: 1; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 20px; padding: 0.8rem 1.2rem; color: white; outline: none; }
.chat-input-area input:focus { border-color: var(--accent-cyan); }

#msg-modal-body { display: flex; flex-direction: column; gap: 0.5rem; height: 350px; overflow-y: auto; padding-right: 5px; }

/* ── Notificaciones ── */
.notification-container {
    position: fixed; top: 80px; right: 20px; 
    display: flex; flex-direction: column; gap: 10px; z-index: 1000;
}
.toast {
    background: var(--bg-card); border: 1px solid var(--accent-cyan);
    padding: 0.8rem 1.2rem; border-radius: 12px; backdrop-filter: blur(10px);
    display: flex; align-items: center; gap: 10px; font-size: 0.85rem;
    animation: slideIn 0.3s ease-out; box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    color: white; border-left: 4px solid var(--accent-cyan);
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.notify-badge {
    position: absolute; top: 0px; right: 0px;
    width: 10px; height: 10px; background: var(--danger);
    border-radius: 50%; border: 1.5px solid var(--bg-dark);
}

