/* === AI SoftwaLabs - Complete Stylesheet === */
/* Ported from workspace.html with all features */

/* Default = dark theme */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #0f172a;
    --bg-chat: #0b1120;
    --sidebar-bg: #060a14;
    --sidebar-hover: #0f172a;
    --sidebar-border: #1e293b;
    --sidebar-active: rgba(96,165,250,0.12);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-sidebar: #cbd5e1;
    --border-light: #1e293b;
    --border-medium: #334155;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-glow: rgba(96,165,250,0.1);
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --code-bg: #010409;
    --code-header: #0d1117;
    --code-border: #30363d;
    --code-text: #e6edf3;
    --user-bubble: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
    --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-chat: #ffffff;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-border: #475569;
    --sidebar-active: rgba(59,130,246,0.15);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-sidebar: #e2e8f0;
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59,130,246,0.15);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --code-bg: #1e293b;
    --code-header: #334155;
    --code-border: #475569;
    --code-text: #e2e8f0;
    --user-bubble: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background var(--transition), color var(--transition);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ================================ */
/* === AUTH PAGES === */
/* ================================ */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-container { width: 100%; max-width: 400px; padding: 20px; }
.auth-card { background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 36px; }
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 8px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.85rem; color: var(--text-muted); }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select {
    width: 100%; padding: 10px 14px; background: var(--bg-tertiary); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.9rem; font-family: var(--font);
    transition: border-color var(--transition); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
small { display: block; margin-top: 4px; font-size: 0.75rem; color: var(--text-muted); }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 12px; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--danger); }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: var(--success); }

.spinner-sm { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.logo { font-size: 1.05rem; font-weight: 600; display: flex; align-items: center; gap: 10px; letter-spacing: -0.02em; color: var(--text-sidebar); }
.logo .brand-icon { width: 28px; height: 28px; background: linear-gradient(135deg, #3b82f6, #8b5cf6); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: white; }

/* === Buttons === */
.btn-principal {
    background: var(--accent); color: #fff; border: none; padding: 11px 16px; border-radius: var(--radius-sm);
    cursor: pointer; font-family: var(--font); font-weight: 600; font-size: 0.88rem; display: flex;
    align-items: center; justify-content: center; gap: 10px; width: 100%; transition: all var(--transition);
}
.btn-principal:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.btn-principal:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-secundario {
    background: transparent; color: var(--text-sidebar); border: 1px solid var(--sidebar-border); padding: 9px 16px;
    border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font); font-weight: 500; font-size: 0.84rem;
    display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; transition: all var(--transition);
}
.btn-secundario:hover { background: var(--sidebar-hover); border-color: var(--text-muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: all var(--transition); font-family: var(--font); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-light); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.btn-icono {
    background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 5px 6px;
    border-radius: 5px; transition: all var(--transition); display: flex; align-items: center; justify-content: center; font-size: 0.75rem;
}
.btn-icono:hover { background: rgba(255,255,255,0.08); color: #fff; }
.btn-icono.danger:hover { color: var(--danger); }

/* ================================ */
/* === CHAT PAGE LAYOUT === */
/* ================================ */
.chat-page { height: 100vh; overflow: hidden; }
.chat-page .app-layout { display: flex; width: 100%; height: 100%; }

/* === SIDEBAR === */
.sidebar {
    width: 300px; background: var(--sidebar-bg); color: var(--text-sidebar); display: flex; flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); z-index: 100; flex-shrink: 0; border-right: 1px solid var(--sidebar-border);
}
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--sidebar-border); display: flex; flex-direction: column; gap: 12px; }
.sidebar-brand { display: flex; justify-content: space-between; align-items: center; }
.sidebar-search { position: relative; }
.sidebar-search input {
    width: 100%; padding: 9px 12px 9px 36px; background: rgba(255,255,255,0.06); border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm); color: var(--text-sidebar); font-family: var(--font); font-size: 0.85rem; outline: none;
}
.sidebar-search input::placeholder { color: #4a5568; }
.sidebar-search input:focus { border-color: var(--accent); background: rgba(255,255,255,0.08); }
.sidebar-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #4a5568; font-size: 0.8rem; }

.lista-proyectos { flex-grow: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }

.proyecto-bloque { border-radius: var(--radius-sm); overflow: hidden; border: 1px solid transparent; transition: border-color var(--transition); }
.proyecto-bloque:hover { border-color: var(--sidebar-border); }

.proyecto-header {
    padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; cursor: pointer;
    font-weight: 500; font-size: 0.88rem; border-radius: var(--radius-sm); transition: background var(--transition);
}
.proyecto-header:hover { background: var(--sidebar-hover); }

.proyecto-titulo { display: flex; align-items: center; gap: 9px; flex-grow: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.proyecto-titulo .folder-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; }
.proyecto-acciones { display: flex; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.proyecto-header:hover .proyecto-acciones { opacity: 1; }

.proyecto-chats { display: flex; flex-direction: column; padding: 2px 4px 6px 4px; gap: 1px; }

.chat-item {
    padding: 9px 10px 9px 14px; border-radius: 6px; cursor: pointer; transition: all var(--transition);
    display: flex; justify-content: space-between; align-items: center; font-size: 0.83rem; color: #64748b; margin-left: 8px;
}
.chat-item:hover { background: rgba(255,255,255,0.04); color: var(--text-sidebar); }
.chat-item.activo {
    background: var(--sidebar-active); color: var(--accent); font-weight: 500;
    border-left: 2.5px solid var(--accent); border-radius: 0 6px 6px 0; margin-left: 0; padding-left: 19px;
}
.chat-item-titulo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-grow: 1; margin-right: 8px; display: flex; align-items: center; gap: 8px; }
.chat-acciones { display: flex; gap: 1px; opacity: 0; transition: opacity var(--transition); }
.chat-item:hover .chat-acciones { opacity: 1; }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--sidebar-border); display: flex; gap: 8px; }
.btn-footer {
    flex: 1; padding: 8px; background: rgba(255,255,255,0.04); border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; font-family: var(--font);
    font-size: 0.8rem; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all var(--transition);
}
.btn-footer:hover { background: rgba(255,255,255,0.08); color: var(--text-sidebar); }

/* === MAIN CONTENT === */
.main-content { flex-grow: 1; display: flex; flex-direction: column; height: 100vh; position: relative; min-width: 0; background: var(--bg-primary); }

.cabecera {
    display: flex; justify-content: space-between; align-items: center; padding: 12px 24px;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border-light); z-index: 20;
}
.cabecera-izq { display: flex; align-items: center; gap: 14px; }
.cabecera h2 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 9px; letter-spacing: -0.01em; }
.cabecera-der { display: flex; align-items: center; gap: 10px; }

.btn-toggle-sidebar {
    display: none; background: transparent; border: none; font-size: 1.15rem; color: var(--text-secondary);
    cursor: pointer; padding: 6px; border-radius: 6px; transition: background var(--transition);
}
.btn-toggle-sidebar:hover { background: var(--bg-tertiary); }

.cabecera select {
    padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-light); font-family: var(--font);
    font-size: 0.83rem; background: var(--bg-tertiary); cursor: pointer; outline: none; font-weight: 500; color: var(--text-secondary);
}
.cabecera select:hover { border-color: var(--border-medium); }

.btn-header {
    background: transparent; border: 1px solid var(--border-light); color: var(--text-secondary); padding: 7px 10px;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 0.9rem; transition: all var(--transition);
    display: flex; align-items: center; gap: 6px;
}
.btn-header:hover { background: var(--bg-tertiary); border-color: var(--border-medium); }

.btn-think, .btn-research {
    background: transparent; border: 1px solid var(--border-light); color: var(--text-muted); padding: 6px 12px;
    border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font); font-size: 0.82rem; font-weight: 500;
    transition: all var(--transition); display: flex; align-items: center; gap: 6px;
}
.btn-think:hover, .btn-research:hover { background: var(--bg-tertiary); border-color: var(--border-medium); }
.btn-think.activo { background: rgba(139,92,246,0.1); border-color: rgba(139,92,246,0.35); color: #a78bfa; }
.btn-research.activo { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.35); color: #10b981; }

/* === CHAT ZONE === */
.historial-chat {
    flex-grow: 1; overflow-y: auto; padding: 24px; background: var(--bg-chat); scroll-behavior: smooth;
    display: flex; flex-direction: column; align-items: center;
}
.chat-inner { width: 100%; max-width: 860px; }

.welcome-screen { text-align: center; margin-top: 12vh; color: var(--text-muted); animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.welcome-screen .welcome-icon {
    width: 72px; height: 72px; background: linear-gradient(135deg, var(--accent), #8b5cf6); border-radius: 20px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.8rem; color: white;
    margin-bottom: 20px; box-shadow: 0 8px 24px rgba(59,130,246,0.2);
}
.welcome-screen h2 { color: var(--text-primary); font-size: 1.4rem; font-weight: 600; margin-bottom: 8px; }
.welcome-screen p { font-size: 0.92rem; color: var(--text-muted); }

/* === MESSAGES === */
.mensaje {
    margin-bottom: 24px; max-width: 100%; line-height: 1.7; padding: 16px 20px; border-radius: var(--radius-lg);
    clear: both; word-wrap: break-word; position: relative; font-size: 0.93rem;
    animation: msgIn 0.35s cubic-bezier(0.4,0,0.2,1);
}
@keyframes msgIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.mensaje.user {
    background: var(--user-bubble); color: white; float: right; border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px rgba(59,130,246,0.2); max-width: 78%; white-space: pre-line;
    padding: 10px 16px;
}
.mensaje.assistant { background: transparent; color: var(--text-primary); float: left; width: 100%; padding-left: 0; padding-right: 0; }
.mensaje.sistema {
    background: rgba(245,158,11,0.08); color: var(--warning); font-size: 0.85rem; float: left;
    border-radius: var(--radius-sm); border: 1px solid rgba(245,158,11,0.2); padding: 10px 15px;
}

.acciones-msg { position: absolute; bottom: -28px; right: 4px; display: flex; gap: 4px; z-index: 1; }
.btn-mini {
    background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 9px;
    cursor: pointer; font-size: 0.88rem; color: inherit; transition: all var(--transition);
    display: inline-flex; align-items: center; justify-content: center; opacity: 0;
}
.mensaje:hover .btn-mini { opacity: 0.7; }
.mensaje:hover .btn-mini:hover { opacity: 1; }
.mensaje.user .btn-mini { color: rgba(255,255,255,0.8); }
.mensaje.user .btn-mini:hover { background: rgba(255,255,255,0.15); color: white; }
.mensaje.assistant .btn-mini { color: var(--text-muted); }
.mensaje.assistant .btn-mini:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* === MARKDOWN IN MESSAGES === */
.mensaje.assistant strong { font-weight: 600; }
.mensaje.assistant em { font-style: italic; }
.mensaje.assistant a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); }
.mensaje.assistant a:hover { border-bottom-style: solid; }
.mensaje.assistant .inline-code {
    background: var(--bg-tertiary); border: 1px solid var(--border-light); padding: 2px 7px;
    border-radius: 5px; font-family: var(--font-mono); font-size: 0.85em; color: var(--accent);
}
.mensaje.assistant hr { border: none; border-top: 1px solid var(--border-light); margin: 16px 0; }
.mensaje.assistant blockquote {
    border-left: 3px solid var(--accent); padding: 8px 16px; margin: 12px 0;
    background: var(--accent-glow); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-secondary);
}

/* === THINK / CODE BLOCKS === */
.cot-block { margin: 12px 0 20px 0; border: 1px solid var(--border-light); border-radius: var(--radius-md); background: var(--bg-secondary); overflow: hidden; }
.cot-block summary {
    padding: 11px 16px; cursor: pointer; font-weight: 600; font-size: 0.85rem; color: var(--text-muted);
    background: var(--bg-tertiary); display: flex; align-items: center; gap: 10px; user-select: none; list-style: none;
}
.cot-block summary:hover { background: var(--border-light); }
.cot-block summary::-webkit-details-marker { display: none; }
.cot-block summary .cot-arrow { transition: transform 0.2s; display: inline-block; font-size: 0.7rem; }
.cot-block[open] summary .cot-arrow { transform: rotate(90deg); }
.cot-content {
    padding: 16px; font-size: 0.87rem; color: var(--text-muted); font-family: var(--font-mono);
    border-top: 1px solid var(--border-light); max-height: 400px; overflow-y: auto; line-height: 1.6;
}

/* Thinking indicator (animated) */
.cot-block.thinking-active { border-color: var(--accent); border-left: 3px solid var(--accent); }
.cot-block.thinking-active summary { color: var(--accent); }
.cot-thinking-icon {
    width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cot-thinking-icon svg { width: 20px; height: 20px; }
.cot-thinking-icon.animado { animation: think-pulse 2s ease-in-out infinite; }
@keyframes think-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.85); filter: brightness(0.8); }
    50% { opacity: 1; transform: scale(1.15); filter: brightness(1.4); }
}
.cot-thinking-dots { display: inline-flex; gap: 3px; margin-left: 4px; }
.cot-thinking-dots span {
    width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: think-dot 1.4s ease-in-out infinite;
}
.cot-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.cot-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes think-dot {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

.code-container {
    background: var(--code-bg); color: var(--code-text); border-radius: var(--radius-md); margin: 16px 0;
    font-family: var(--font-mono); box-shadow: var(--shadow-lg); border: 1px solid var(--code-border); overflow: hidden;
}
.code-header {
    background: var(--code-header); padding: 10px 16px; display: flex; justify-content: space-between;
    align-items: center; border-bottom: 1px solid var(--code-border);
}
.code-header-left { display: flex; align-items: center; gap: 14px; }
.mac-dots { display: flex; gap: 6px; }
.mac-dot { width: 11px; height: 11px; border-radius: 50%; }
.mac-dot.red { background: #ff5f56; }
.mac-dot.yellow { background: #ffbd2e; }
.mac-dot.green { background: #27c93f; }
.lang-badge { color: #8b949e; font-size: 0.78rem; font-family: var(--font); font-weight: 500; text-transform: uppercase; letter-spacing: 0.8px; }
.code-acciones { display: flex; gap: 6px; align-items: center; }
.btn-icon-code {
    background: transparent; color: #8b949e; border: 1px solid transparent; padding: 4px 8px;
    border-radius: 5px; cursor: pointer; font-size: 0.82rem; transition: all var(--transition);
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon-code:hover { background: rgba(255,255,255,0.08); color: #e6edf3; }
.btn-descargar {
    background: rgba(59,130,246,0.15); color: #58a6ff; border: none; padding: 5px 12px; border-radius: 5px;
    cursor: pointer; font-size: 0.78rem; font-weight: 600; font-family: var(--font); transition: all var(--transition);
    display: flex; align-items: center; gap: 5px;
}
.btn-descargar:hover { background: rgba(59,130,246,0.25); }
.code-container pre { margin: 0; padding: 18px; overflow-x: auto; font-size: 0.85rem; line-height: 1.6; white-space: pre; }

/* === IMAGE PREVIEW === */
.img-preview { max-width: 240px; border-radius: var(--radius-sm); margin-bottom: 12px; box-shadow: var(--shadow-md); border: 2px solid rgba(255,255,255,0.15); }
#zonaVistaPrevia {
    display: none; margin: 0 auto 12px auto; max-width: 860px; background: var(--bg-tertiary); padding: 14px;
    border-radius: var(--radius-md); position: relative; border: 2px dashed var(--border-medium);
}
#btnQuitarImg {
    position: absolute; top: -8px; right: -8px; background: var(--danger); color: white; border: none;
    border-radius: 50%; width: 26px; height: 26px; cursor: pointer; display: flex; align-items: center;
    justify-content: center; font-size: 0.7rem; box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}

/* === INPUT AREA === */
.input-wrapper { padding: 0 24px 20px 24px; background: var(--bg-primary); display: flex; flex-direction: column; align-items: center; }
.controles-interior {
    width: 100%; max-width: 860px; display: flex; align-items: flex-end; background: var(--bg-secondary);
    border: 1.5px solid var(--border-light); border-radius: var(--radius-lg); padding: 10px 12px;
    box-shadow: var(--shadow-sm); transition: all 0.3s ease;
}
.controles-interior:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-md); }
.controles-interior.drag-over { border-color: var(--accent); background: var(--accent-glow); }

.controles-interior textarea {
    flex-grow: 1; padding: 10px; border: none; resize: none; font-size: 0.95rem; font-family: var(--font);
    background: transparent; color: var(--text-primary); max-height: 200px; line-height: 1.5; outline: none; width: 100%;
}
.controles-interior textarea::placeholder { color: var(--text-muted); }

.botones-prompt { display: flex; gap: 6px; padding-left: 8px; }
.btn-accion {
    width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
    color: white; border: none; border-radius: var(--radius-md); cursor: pointer; font-size: 1rem; transition: all var(--transition);
}
#btnWeb { background: var(--bg-tertiary); color: var(--text-secondary); }
#btnWeb:hover { background: var(--border-medium); color: var(--text-primary); }
#btnWeb.activo { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid var(--success); }
#btnUbi { background: var(--bg-tertiary); color: var(--text-secondary); }
#btnUbi:hover { background: var(--border-medium); color: var(--text-primary); }
#btnUbi.activo { background: rgba(99,102,241,0.15); color: var(--accent); border: 1px solid var(--accent); }
#btnAdjuntar { background: var(--bg-tertiary); color: var(--text-secondary); }
#btnAdjuntar:hover { background: var(--border-medium); color: var(--text-primary); }
#btnEnviar { background: var(--success); }
#btnEnviar:hover { background: #059669; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
#btnDetener { background: var(--danger); display: none; }
#btnDetener:hover { background: #dc2626; }
button:disabled { background: var(--bg-tertiary) !important; color: var(--text-muted) !important; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.cursor { display: inline-block; width: 7px; height: 17px; background: var(--accent); animation: blink 1s step-end infinite; vertical-align: text-bottom; margin-left: 3px; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.clearfix::after { content: ""; clear: both; display: table; }

.input-footer { margin-top: 8px; width: 100%; max-width: 860px; display: flex; justify-content: space-between; align-items: center; }
.input-hint { font-size: 0.75rem; color: var(--text-muted); }
.input-hint kbd { background: var(--bg-tertiary); border: 1px solid var(--border-light); padding: 1px 5px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.7rem; }

/* === TOKEN COUNTER === */
.token-counter { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--text-muted); flex-shrink: 0; }
.token-counter .token-bar-wrapper { width: 120px; height: 6px; background: var(--bg-tertiary); border-radius: 10px; overflow: hidden; border: 1px solid var(--border-light); }
.token-counter .token-bar { height: 100%; border-radius: 10px; transition: width 0.4s ease, background 0.4s ease; min-width: 0; }
.token-counter .token-bar.level-ok { background: var(--success); }
.token-counter .token-bar.level-warn { background: var(--warning); }
.token-counter .token-bar.level-danger { background: var(--danger); }
.token-counter .token-label { font-family: var(--font-mono); font-size: 0.7rem; white-space: nowrap; }
.token-counter .token-label.level-ok { color: var(--success); }
.token-counter .token-label.level-warn { color: var(--warning); }
.token-counter .token-label.level-danger { color: var(--danger); }

/* === MODALS === */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5);
    display: none; justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(6px);
}
.modal-content {
    background: var(--bg-secondary); padding: 28px; border-radius: var(--radius-lg); width: 90%; max-width: 560px;
    box-shadow: var(--shadow-lg); max-height: 80vh; display: flex; flex-direction: column;
    border: 1px solid var(--border-light); animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-light); padding-bottom: 16px; margin-bottom: 20px; }
.modal-header h3 { font-size: 1.15rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.btn-cerrar-modal { background: transparent; border: none; font-size: 1.3rem; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.btn-cerrar-modal:hover { color: var(--danger); background: rgba(239,68,68,0.08); }

.zona-drop {
    border: 2px dashed var(--border-medium); border-radius: var(--radius-md); padding: 36px 20px;
    text-align: center; background: var(--bg-tertiary); cursor: pointer; transition: all var(--transition); margin-bottom: 16px;
}
.zona-drop:hover { border-color: var(--accent); background: var(--accent-glow); }
.zona-drop i { font-size: 2.4rem; color: var(--text-muted); margin-bottom: 8px; }
.zona-drop h4 { font-weight: 600; color: var(--text-primary); font-size: 0.95rem; margin-bottom: 4px; }
.zona-drop p { font-size: 0.82rem; color: var(--text-muted); }

.lista-archivos { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.archivo-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg-tertiary); border-radius: var(--radius-sm); border: 1px solid var(--border-light); }
.archivo-nombre { font-size: 0.88rem; font-weight: 500; display: flex; align-items: center; gap: 10px; }

.aviso-contexto {
    font-size: 0.82rem; color: var(--warning); background: rgba(245,158,11,0.06); padding: 10px 14px;
    border-radius: var(--radius-sm); border: 1px solid rgba(245,158,11,0.15); margin-top: 14px; display: flex; gap: 10px; align-items: flex-start;
}

.system-prompt-area {
    width: 100%; min-height: 120px; padding: 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    font-family: var(--font-mono); font-size: 0.83rem; background: var(--bg-tertiary); color: var(--text-primary);
    resize: vertical; outline: none; line-height: 1.5;
}
.system-prompt-area:focus { border-color: var(--accent); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.btn-modal {
    padding: 9px 18px; border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.88rem; font-weight: 500;
    cursor: pointer; border: 1px solid var(--border-light); background: var(--bg-tertiary); color: var(--text-primary); transition: all var(--transition);
}
.btn-modal:hover { background: var(--border-light); }
.btn-modal.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-modal.primary:hover { background: var(--accent-hover); }

/* === TOAST === */
.toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--text-primary); color: var(--bg-primary); padding: 10px 20px; border-radius: var(--radius-sm);
    font-size: 0.88rem; font-weight: 500; opacity: 0; transition: all 0.3s ease; z-index: 9999; pointer-events: none;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* === SOURCE BUBBLES === */
.fuentes-bar { display: flex; align-items: center; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-light); flex-wrap: wrap; }
.fuentes-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-right: 4px; }
.fuente-bola {
    width: 28px; height: 28px; border-radius: 50%; background: var(--bg-tertiary); border: 1.5px solid var(--border-light);
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition);
    position: relative; text-decoration: none;
}
.fuente-bola:hover { border-color: var(--accent); transform: scale(1.15); box-shadow: 0 2px 8px var(--accent-glow); }
.fuente-bola img { width: 16px; height: 16px; border-radius: 2px; object-fit: contain; }
.fuente-bola .fuente-fallback { font-size: 0.6rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.fuente-bola[data-tooltip]:hover::after {
    content: attr(data-tooltip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    background: var(--text-primary); color: var(--bg-primary); padding: 4px 10px; border-radius: 5px;
    font-size: 0.72rem; white-space: nowrap; z-index: 50; pointer-events: none; font-weight: 500;
}

/* === DEEP RESEARCH PANEL === */
/* Research block (cot-block style) */
.cot-block.research-active { border-color: var(--success); border-left: 3px solid var(--success); }
.cot-block.research-active summary { color: var(--success); }
.cot-research-icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cot-research-icon svg { width: 20px; height: 20px; }
.cot-research-icon.animado { animation: research-pulse 1.8s ease-in-out infinite; }
.cot-block.research-active .cot-thinking-dots span { background: var(--success); }
@keyframes research-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.85) rotate(0deg); filter: brightness(0.8); }
    50% { opacity: 1; transform: scale(1.15) rotate(-15deg); filter: brightness(1.4); }
}

.research-inner { padding: 0; font-size: 0.8rem; }
.research-agents { display: flex; gap: 4px; padding: 8px 0; flex-wrap: wrap; }
.agent-badge {
    padding: 3px 8px; border-radius: 10px; font-size: 0.68rem; font-weight: 600;
    border: 1px solid var(--border-light); background: var(--bg-secondary); color: var(--text-muted);
    transition: all 0.3s; white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}
.agent-badge.active { border-color: #f59e0b; color: #f59e0b; background: rgba(245,158,11,0.08); }
.agent-badge.done { border-color: var(--success); color: var(--success); background: rgba(16,185,129,0.08); }

.research-stats { display: flex; gap: 14px; padding: 8px 0; font-size: 0.75rem; }
.research-stat { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.research-stat .stat-num { font-size: 1.1rem; font-weight: 700; color: var(--accent); line-height: 1; }
.research-stat .stat-label { color: var(--text-muted); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.5px; }

.research-progress { padding: 4px 0; }
.research-progress-bar { height: 4px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; }
.research-progress-fill { height: 100%; background: linear-gradient(90deg, var(--success), #059669); border-radius: 2px; transition: width 0.3s ease; width: 0%; }
.research-current { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.research-log { overflow-y: auto; max-height: 180px; font-size: 0.72rem; margin-top: 6px; border-top: 1px solid var(--border-light); padding-top: 6px; }
.research-log-entry { padding: 2px 6px; border-radius: 4px; margin-bottom: 2px; display: flex; align-items: flex-start; gap: 5px; line-height: 1.35; }
.research-log-entry.ok { color: var(--success); background: rgba(16,185,129,0.06); }
.research-log-entry.err { color: var(--danger); background: rgba(239,68,68,0.06); }
.research-log-entry.info { color: var(--accent); background: rgba(59,130,246,0.06); }
.research-log-entry.search { color: #f59e0b; background: rgba(245,158,11,0.06); }

.research-sources a { color: var(--accent); text-decoration: none; font-size: 0.8rem; }
.research-sources a:hover { text-decoration: underline; }

/* === ADMIN PAGE === */
.admin-page #app { max-width: 900px; margin: 0 auto; padding: 0 20px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 0; border-bottom: 1px solid var(--border-light); margin-bottom: 20px; }
.admin-header-left { display: flex; align-items: center; gap: 16px; }
.admin-title { font-size: 1.2rem; font-weight: 600; }
.admin-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border-light); }
.tab { padding: 10px 18px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-secondary); font-size: 0.9rem; cursor: pointer; font-family: var(--font); }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-section { margin-bottom: 40px; }
.admin-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }
.config-form { max-width: 600px; }
.config-group { margin-bottom: 18px; }
.config-group label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.config-row { display: flex; gap: 16px; }
.config-row .config-group { flex: 1; }
.config-row.indent { padding-left: 24px; border-left: 2px solid var(--border-light); margin-left: 8px; margin-bottom: 18px; }
.checkbox-label { display: flex !important; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.loading-state { text-align: center; color: var(--text-muted); padding: 40px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat-card { background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 20px; text-align: center; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }
.stats-table-wrap { overflow-x: auto; margin-bottom: 28px; }
.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-light); font-size: 0.85rem; }
.stats-table th { color: var(--text-muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; }
.stats-table code { font-family: var(--font-mono); font-size: 0.8rem; background: var(--bg-tertiary); padding: 2px 8px; border-radius: 4px; }
.truncate { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* === LANDING PAGE === */
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 32px; border-bottom: 1px solid var(--border-light); }
.landing-nav-links { display: flex; gap: 12px; align-items: center; }
.hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 60px 24px; }
.hero-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 16px; border-radius: 20px; font-size: 0.78rem; background: var(--accent-glow); border: 1px solid rgba(99,102,241,0.25); color: var(--accent); margin-bottom: 24px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700; line-height: 1.2; margin-bottom: 16px; letter-spacing: -1px; }
.hero h1 span { color: var(--accent); }
.hero p { font-size: 1.1rem; color: var(--text-secondary); max-width: 560px; margin-bottom: 36px; line-height: 1.7; }
.hero-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hero-buttons .btn { padding: 12px 28px; font-size: 1rem; border-radius: var(--radius-md); }
.btn-outline { background: transparent; color: var(--text-primary); border: 1px solid var(--border-light); }
.btn-outline:hover { background: var(--bg-tertiary); border-color: var(--text-muted); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; padding: 40px 32px 60px; max-width: 1000px; margin: 0 auto; width: 100%; }
.feature-card { background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 28px; }
.feature-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.feature-icon.blue { background: rgba(99,102,241,0.12); color: var(--accent); }
.feature-icon.green { background: rgba(16,185,129,0.12); color: var(--success); }
.feature-icon.yellow { background: rgba(245,158,11,0.12); color: var(--warning); }
.feature-card h3 { font-size: 1rem; margin-bottom: 8px; }
.feature-card p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; }
.landing-footer { text-align: center; padding: 24px; border-top: 1px solid var(--border-light); font-size: 0.8rem; color: var(--text-muted); }
/* === SIDEBAR USER === */
.sidebar-user {
    padding: 12px 16px; border-top: 1px solid var(--sidebar-border); display: flex; align-items: center; gap: 10px;
}
.sidebar-user .user-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 600; color: white; flex-shrink: 0;
}
.sidebar-user .user-name {
    flex-grow: 1; font-size: 0.85rem; color: var(--text-sidebar); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-brand h1 {
    font-size: 1.05rem; font-weight: 600; display: flex; align-items: center; gap: 10px; letter-spacing: -0.02em; color: var(--text-sidebar);
}
.sidebar-brand h1 .brand-icon {
    width: 28px; height: 28px; background: linear-gradient(135deg, #3b82f6, #8b5cf6); border-radius: 8px;
    display: flex; align-items: center; justify-content: center; color: white;
}

.sidebar-search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #4a5568;
}

.btn-footer { text-decoration: none; }
a.btn-footer { text-decoration: none; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar { position: fixed; height: 100vh; transform: translateX(-100%); }
    .sidebar.abierto { transform: translateX(0); box-shadow: 5px 0 30px rgba(0,0,0,0.5); }
    .btn-toggle-sidebar { display: block; }
    .mensaje.user { max-width: 90%; }
    .cabecera select { max-width: 140px; }
    .cabecera-der { flex-wrap: wrap; }
    .research-panel { max-height: 400px; }
    .config-row { flex-direction: column; gap: 0; }
    .admin-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .landing-nav { padding: 12px 16px; }
    .hero { padding: 40px 16px; }
    .features { padding: 20px 16px 40px; }
}
