/* CIRUGÍA DE TEMAS: Variables Dinámicas */
:root {
    /* Variables por defecto (Tema Oscuro) */
    --bg-main: #131314;
    --bg-side: #1e1f20;
    --bg-card: #1e1f20;
    --bg-card-hover: #333537;
    --bg-user-msg: #2b2c2f;
    --text-main: #e3e3e3;
    --text-dim: #9aa0a6;
    --border: #3c4043;
    --blue: #8ab4f8;
    --green: #4caf50;
    --grad: linear-gradient(90deg, #4285f4, #9b72cb, #d96570);
    
    /* Variables Panel Settings Pro */
    --set-bg: #1e1f20;
    --set-side: #131314;
    --set-input: #131314;
}

[data-theme="light"] {
    /* Variables Tema Claro */
    --bg-main: #f8f9fa;
    --bg-side: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f3f4;
    --bg-user-msg: #e8eaed;
    --text-main: #202124;
    --text-dim: #5f6368;
    --border: #dadce0;
    --blue: #1a73e8;
    --set-bg: #ffffff;
    --set-side: #f8f9fa;
    --set-input: #ffffff;
}

* { font-family: 'Google Sans', sans-serif !important; }

body, html { 
    margin: 0; padding: 0; height: 100%; 
    background: var(--bg-main); color: var(--text-main); 
    overflow: hidden; 
    transition: background-color 0.3s ease, color 0.3s ease; /* Transición suave al cambiar tema */
}

/* --- ESTRUCTURA GENERAL (TECHO Y CUERPO) --- */
.app-container { 
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
    width: 100vw; 
}

/* LA BARRA SUPERIOR */
.top-header { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 0; background: var(--bg-main); height: 60px; box-sizing: border-box;
    border-bottom: 1px solid var(--border); /* Añadido un bordecito sutil para separar */
    overflow: visible !important; /* CIRUGÍA: Evita que los menús se corten */
}

.header-left { 
    display: flex; align-items: center; justify-content: space-between; 
    width: 304px; height: 100%; padding: 0 15px 0 20px; 
    background: var(--bg-side); position: relative; box-sizing: border-box; 
}

.header-center { flex: 1; text-align: left; display: flex; align-items: center; justify-content: flex-start; padding-left: 20px; box-sizing: border-box; height: 100%; } 

.header-right { 
    width: 380px; height: 100%; padding-right: 20px; 
    background: var(--bg-side); display: flex; justify-content: flex-end; align-items: center; box-sizing: border-box;
    overflow: visible !important; /* CIRUGÍA: Evita que los menús se corten */
} 

.brand-title { font-size: 1.4rem; font-weight: 500; color: var(--text-main); margin: 0; }

.search-btn-gemini { background: transparent; border: none; color: var(--text-dim); height: 48px; width: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; margin: 0; }
.search-btn-gemini:hover { background: var(--bg-card-hover); }
.search-btn-gemini svg { width: 20px; height: 20px; }

.search-container { position: absolute; right: 60px; top: 50%; transform: translateY(-50%); width: 190px; padding: 0; z-index: 10; }
.search-container input { background: var(--bg-user-msg); border: 1px solid var(--border); color: var(--text-main); border-radius: 20px; padding: 10px 15px; width: 100%; box-sizing: border-box; outline: none; font-size: 0.85rem; }

.user-avatar { width: 32px; height: 32px; background: var(--blue); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: bold; cursor: pointer; }

.icon-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1.4rem; padding: 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
.icon-btn:hover { background: var(--bg-card-hover); }

/* EL CUERPO PRINCIPAL */
.main-body { display: flex; flex: 1; overflow: hidden; }

/* --- SIDEBAR IZQUIERDA --- */
.sidebar { width: 280px; background: var(--bg-side); display: flex; flex-direction: column; padding: 12px; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden; border-right: 1px solid var(--border); }
.sidebar.collapsed { width: 72px; padding: 12px 8px; }
.sidebar.collapsed span, .sidebar.collapsed .history-label, .sidebar.collapsed .search-container, .sidebar.collapsed .history-section { display: none; }

.new-chat-pill, .nav-pill { background: var(--bg-main); border: 1px solid var(--border); color: var(--text-main); padding: 10px 16px; border-radius: 25px; display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 10px 5px; font-size: 0.9rem; font-weight: 500; transition: all 0.2s; white-space: nowrap; }
.sidebar.collapsed .new-chat-pill, .sidebar.collapsed .nav-pill { width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 50%; margin: 10px auto; border: none; }
.nav-pill { background: transparent; border: none; }
.new-chat-pill:hover, .nav-pill:hover { background: var(--bg-card-hover); }

.history-section { flex: 1; overflow-y: auto; }
.history-label { font-size: 0.7rem; color: var(--text-dim); padding: 20px 10px 8px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.hist-item { padding: 10px 15px; font-size: 0.85rem; border-radius: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); transition: 0.2s; }
.hist-item:hover { background: var(--bg-card-hover); padding-left: 20px; }

/* --- ZONA CENTRAL --- */
.main-content { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 0; background: var(--bg-main); }
.view-port { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; }
.content-container { width: 100%; max-width: 820px; padding: 20px; box-sizing: border-box; }

.welcome-title { font-size: 3.2rem; font-weight: 500; margin-top: 12vh; text-align: center; background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 50px; }
.card { background: var(--bg-card); padding: 20px; border-radius: 16px; cursor: pointer; transition: 0.2s; display: flex; flex-direction: column; justify-content: space-between; min-height: 100px; border: 1px solid var(--border); }
.card:hover { background: var(--bg-card-hover); border-color: var(--blue); }

/* --- COLUMNA DERECHA (REDISEÑO V5) --- */
.right-panel { width: 380px; background: var(--bg-side); display: flex; flex-direction: column; height: 100%; border-left: 1px solid var(--border); }

/* HUB DE SELECCIÓN SUPERIOR */
#sonodit-selection-hub {
    background: var(--bg-side);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.hub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

#hub-clear {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s;
}
#hub-clear:hover { color: var(--blue); }

.hub-slots { display: flex; gap: 8px; width: 100%; }
.hub-slot {
    flex: 1;
    background: var(--bg-main);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 8px;
    font-size: 0.65rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.hub-slot.filled {
    border-style: solid;
    border-color: var(--blue);
    background: rgba(138, 180, 248, 0.08);
    color: var(--blue);
}

/* NAVEGACIÓN POR PESTAÑAS */
.sonodit-nav-tabs {
    display: flex;
    padding: 5px 10px 0;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-main); }

.tab-btn.active {
    color: var(--blue);
    border-bottom: 2px solid var(--blue);
}

#search-wrapper { padding: 12px 20px; }
#universal-search {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    outline: none;
}
#universal-search:focus { border-color: var(--blue); }

/* ESTILO MINI-CARD (CEREBRO V5) */
.audio-list { padding: 10px 20px; overflow-y: auto; flex: 1; }
.audio-card {
    background: var(--bg-main);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 6px;
    transition: 0.2s;
}
.audio-card:hover { background: var(--bg-card-hover); }
.audio-card.selected-card {
    border-color: var(--blue);
    background: rgba(138, 180, 248, 0.05);
}

.card-top { display: flex; align-items: center; gap: 10px; }
.play-btn-mini {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--blue); border: none; color: #000;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 0.7rem;
}

.card-info { flex: 1; overflow: hidden; }
.card-title { font-size: 0.75rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-cat { font-size: 0.6rem; color: var(--blue); text-transform: uppercase; font-weight: 700; margin-top: 2px; }

.select-btn {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-dim); font-size: 0.65rem; padding: 4px 10px;
    border-radius: 15px; cursor: pointer; transition: 0.2s;
}
.select-btn:hover { border-color: var(--blue); color: var(--text-main); }
.selected-card .select-btn { background: var(--blue); border-color: var(--blue); color: #000; font-weight: 700; }

.wave-box { width: 100%; height: 15px; margin-top: 6px; opacity: 0.5; }

/* MODULOS DE CONTENIDO */
.panel-module { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* --- OTROS ESTILOS EXISTENTES --- */
.section-title { font-size: 2.2rem; font-weight: 400; margin-bottom: 30px; }
.spots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; padding-bottom: 50px; width: 100%; }
.spot-card { position: relative; height: 220px; background-color: var(--bg-card); background-size: cover; background-position: center; border-radius: 20px; border: 1px solid var(--border); overflow: hidden; cursor: pointer; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease; }
.spot-card:hover { transform: translateY(-5px) scale(1.02); border-color: var(--blue); }
.spot-card-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0) 100%); display: flex; flex-direction: column; justify-content: flex-end; padding: 18px; box-sizing: border-box; }
.spot-card h3 { margin: 0; font-size: 0.95rem; color: #fff; font-weight: 500; text-transform: uppercase; }
.spot-card p { margin: 4px 0 0 0; font-size: 0.75rem; color: rgba(255,255,255,0.7); }

.input-section { padding: 10px 20px 15px; display: flex; flex-direction: column; align-items: center; box-sizing: border-box; }
.input-container { width: 100%; max-width: 820px; background: var(--bg-card); border-radius: 28px; padding: 10px 24px; display: flex; align-items: flex-end; border: 1px solid var(--border); box-sizing: border-box; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
#user-input { flex: 1; background: none; border: none; color: var(--text-main); padding: 10px 0; font-size: 1rem; outline: none; resize: none; max-height: 200px; }
.send-btn { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 1.6rem; padding: 8px; }

.disclaimer { color: var(--text-dim); font-size: 0.75rem; margin: 8px 0 0 0; text-align: center; }

.msg { margin-bottom: 30px; display: flex; gap: 15px; width: 100%; }
.msg-av { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.msg.user { justify-content: flex-end; flex-direction: row-reverse; }
.msg.user .msg-av { background: var(--blue); color: #fff; }
.msg.ai .msg-av { background: var(--grad); color: #fff; }

.msg-body { flex: 1; line-height: 1.6; font-size: 1.0rem; letter-spacing: 0.2px; } 
.msg.user .msg-body { flex: none; max-width: 80%; background: var(--bg-user-msg); padding: 12px 18px; border-radius: 20px 20px 4px 20px; }

.player-pill { background: var(--bg-card); border-radius: 30px; padding: 8px 16px; display: inline-flex; align-items: center; gap: 12px; border: 1px solid var(--border); margin: 10px 0; }

/* SCROLLBARS OCULTOS */
* { scrollbar-width: none; }
::-webkit-scrollbar { display: none; }

/* ==============================================================
   COMPONENTE: SELECTOR DUAL (IDIOMA Y PAÍS)
============================================================== */
#country-selector-root { position: relative; margin-right: 15px; overflow: visible !important; }

.selector-dual-container {
    display: flex;
    gap: 12px;
    align-items: center;
    position: relative;
    z-index: 1000;
}

.dropdown-wrapper { position: relative; }

.dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.dropdown-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--blue);
}

.dropdown-btn img { 
    width: 20px; height: 20px; border-radius: 50%; 
    object-fit: cover; box-shadow: 0 1px 3px rgba(0,0,0,0.3); 
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 160px;
    max-height: 350px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
}

.dropdown-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 0.9rem;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.dropdown-item:hover { background: var(--bg-card-hover); }
.dropdown-item.active { background: rgba(138, 180, 248, 0.08); color: var(--blue); font-weight: 600; }

.dropdown-menu::-webkit-scrollbar { width: 6px; }
.dropdown-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }


/* MODAL AUTH */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 9999; animation: fadeIn 0.2s ease; }
.modal-card { background: var(--bg-card); border: 1px solid var(--border); width: 100%; max-width: 420px; border-radius: 28px; padding: 40px; position: relative; box-shadow: 0 24px 48px rgba(0,0,0,0.3); }
.close-modal { position: absolute; top: 20px; right: 20px; background: none; border: none; color: var(--text-dim); font-size: 24px; cursor: pointer; }
.modal-header { text-align: center; margin-bottom: 30px; }
.modal-logo { font-size: 40px; margin-bottom: 10px; }
.modal-header h2 { font-size: 1.8rem; font-weight: 500; margin: 0; color: var(--text-main); }
.modal-header p { color: var(--text-dim); font-size: 0.9rem; margin-top: 8px; }

.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 8px; margin-left: 4px; }
.input-group input { width: 100%; background: var(--bg-main); border: 1px solid var(--border); color: var(--text-main); padding: 14px 20px; border-radius: 12px; font-size: 1rem; outline: none; transition: border-color 0.2s; box-sizing: border-box; }
.input-group input:focus { border-color: var(--blue); }

.primary-btn { width: 100%; background: var(--blue); color: #fff; border: none; padding: 14px; border-radius: 25px; font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 10px; transition: opacity 0.2s; }
.primary-btn:hover { opacity: 0.9; }

.switch-auth { text-align: center; margin-top: 25px; font-size: 0.9rem; color: var(--text-dim); }
.switch-auth span { color: var(--blue); cursor: pointer; font-weight: 500; }
.switch-auth span:hover { text-decoration: underline; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }