/* ===== VARIABLES ===== */
:root {
    --bg-deep: #0a0c14;
    --bg-soft: #11131f;
    --bg-panel: rgba(18,22,33,0.95);
    --accent: #2de38b;
    --accent-soft: rgba(45, 227, 139, 0.2);
    --accent-glow: rgba(45, 227, 139, 0.25);
    --text-main: #f0f3f8;
    --text-soft: #b0b9ce;
    --text-muted: #7e879f;
    --user-msg: #1a4a3a;
    --bot-msg: #1e2230;
    --border-soft: rgba(65, 80, 110, 0.25);
    --border-neon: rgba(45, 227, 139, 0.3);
    --glass: rgba(15, 20, 30, 0.8);
    --shadow-main: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;
}

/* Tema Claro */
[data-theme="light"] {
    --bg-deep: #f5f7fc;
    --bg-soft: #eef2f6;
    --bg-panel: rgba(255,255,255,0.9);
    --accent: #0f8b5c;
    --text-main: #1e2434;
    --text-soft: #3a4055;
    --text-muted: #6b7287;
    --user-msg: #d9f0e6;
    --bot-msg: #e8ecf5;
    --border-soft: rgba(180,190,210,0.4);
    --border-neon: rgba(15,139,92,0.3);
}

/* Tema Neón */
[data-theme="neon"] {
    --bg-deep: #000000;
    --bg-soft: #0a0a0a;
    --bg-panel: #111111;
    --accent: #00ffaa;
    --accent-soft: rgba(0,255,170,0.15);
    --accent-glow: 0 0 20px #00ffaa;
    --text-main: #ffffff;
    --text-soft: #cccccc;
    --text-muted: #888888;
    --user-msg: #003322;
    --bot-msg: #1a1a1a;
    --border-soft: rgba(0,255,170,0.2);
    --border-neon: rgba(0,255,170,0.5);
}

/* Tema Púrpura */
[data-theme="purple"] {
    --bg-deep: #0f0a1f;
    --bg-soft: #1a1033;
    --bg-panel: #221544;
    --accent: #c77dff;
    --accent-soft: rgba(199,125,255,0.15);
    --text-main: #f0e6ff;
    --text-soft: #d0c0e8;
    --text-muted: #9a8ab8;
    --user-msg: #3a2a5a;
    --bot-msg: #2a1e3a;
    --border-soft: rgba(199,125,255,0.2);
    --border-neon: rgba(199,125,255,0.4);
}

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

html, body {
    height: 100%;
    background-color: var(--bg-deep);
    overflow-x: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-deep);
    color: var(--text-main);
    min-height: 100vh;
    position: relative;
    line-height: 1.5;
}

/* ===== BACKGROUND ===== */
#bg-canvas {
    position: fixed;
    inset: 0;
    z-index: -2;
    opacity: 0.3;
    pointer-events: none;
}

/* ===== APP SHELL ===== */
.app-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 12px;
    gap: 12px;
}

/* ===== TOP BAR ===== */
.top-bar {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-neon);
    padding: 0 24px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-neon {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent);
    letter-spacing: 2px;
}

.model-badge {
    background: var(--accent-soft);
    border: 1px solid var(--border-neon);
    padding: 6px 12px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
}

.top-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.weather-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--border-neon);
    cursor: pointer;
    transition: all 0.2s;
}

.weather-widget:hover {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-soft);
}

.weather-icon {
    font-size: 20px;
}

.weather-temp {
    font-weight: 600;
}

.weather-city {
    font-size: 12px;
    color: var(--text-soft);
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-icon {
    font-size: 22px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.settings-icon:hover {
    background: var(--accent-soft);
    transform: rotate(90deg);
}

/* ===== CHAT MAIN ===== */
.chat-main {
    flex: 1;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-neon);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-main);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== MENSAJES ===== */
.message {
    max-width: 75%;
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
    background: var(--user-msg);
    border: 1px solid var(--accent-soft);
    border-bottom-right-radius: 4px;
}

.message.bot {
    align-self: flex-start;
    background: var(--bot-msg);
    border: 1px solid var(--border-soft);
    border-bottom-left-radius: 4px;
}

.message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    margin-top: 8px;
    border: 1px solid var(--border-neon);
}

.message-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    margin-top: 8px;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bot-msg);
    border-radius: 18px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== INPUT AREA ===== */
.input-area {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-soft);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border-neon);
    border-radius: 28px;
    padding: 6px 6px 6px 20px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 14px;
    padding: 12px 0;
    outline: none;
    resize: none;
    max-height: 120px;
    font-family: 'Inter', sans-serif;
}

#userInput::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-soft);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.send-btn {
    background: var(--accent);
    border: none;
    color: #000;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    height: 44px;
}

.send-btn:hover {
    background: var(--accent);
    filter: brightness(1.1);
    transform: scale(1.02);
}

/* ===== SETTINGS PANEL ===== */
.settings-panel {
    position: fixed;
    top: 90px;
    right: 20px;
    width: 320px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid var(--border-neon);
    box-shadow: var(--shadow-main);
    padding: 20px;
    display: none;
    flex-direction: column;
    gap: 18px;
    z-index: 30;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 12px;
}

.settings-header h4 {
    font-family: 'Orbitron';
    color: var(--accent);
    font-size: 16px;
}

.settings-close {
    cursor: pointer;
    font-size: 18px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.settings-close:hover {
    background: rgba(255,255,255,0.1);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.settings-row label {
    color: var(--text-soft);
}

.theme-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.theme-option {
    padding: 4px 8px;
    border-radius: 20px;
    border: 1px solid var(--border-soft);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.theme-option.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.model-select, .unit-select {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    padding: 6px 10px;
    color: var(--text-main);
    font-size: 12px;
    outline: none;
    width: 160px;
}

#tempSlider {
    width: 120px;
    accent-color: var(--accent);
}

#tempValue {
    min-width: 30px;
    text-align: right;
    color: var(--accent);
}

/* ===== BOTTOM BAR ===== */
.bottom-bar {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-neon);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    font-size: 11px;
}

.bottom-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.bottom-links {
    display: flex;
    gap: 20px;
}

.bottom-links a {
    color: var(--text-soft);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 10px;
    cursor: pointer;
    transition: color 0.2s;
}

.bottom-links a:hover {
    color: var(--accent);
}

/* ===== MODALES ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: rgba(12, 17, 27, 0.98);
    border-radius: 28px;
    border: 1px solid var(--border-neon);
    box-shadow: var(--shadow-main);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 26px 12px;
    border-bottom: 1px solid var(--border-soft);
    background: rgba(12,17,27,0.98);
}

.modal-header h3 {
    font-family: 'Orbitron';
    color: var(--accent);
    font-size: 16px;
}

.modal-close {
    cursor: pointer;
    font-size: 18px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: rgba(255,255,255,0.05);
}

.modal-body {
    color: var(--text-soft);
    line-height: 1.6;
    font-size: 13px;
    padding: 0 26px 20px;
    overflow-y: auto;
}

.modal-body strong {
    color: var(--accent);
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
}

.modal-body p {
    margin-bottom: 10px;
}

/* ===== UTILS ===== */
.badge-ip {
    padding: 4px 10px;
    border-radius: 30px;
    border: 1px solid var(--border-soft);
    font-size: 9px;
    color: var(--text-soft);
}

/* ===== SCROLL PERSONALIZADO ===== */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(160,160,160,0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(120,120,120,0.4);
}
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(160,160,160,0.2) transparent;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
    .weather-city { display: none; }
    .model-badge { display: none; }
    .bottom-links { gap: 10px; flex-wrap: wrap; }
    .settings-panel { width: 280px; }
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 12px;
    top: 12px;
    bottom: 12px;
    width: 280px;
    background: var(--bg-panel);
    border: 1px solid var(--border-neon);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 40;
    box-shadow: var(--shadow-main);
}

.sidebar.closed {
    transform: translateX(-300px);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-title {
    font-family: 'Orbitron';
    font-size: 18px;
    color: var(--accent);
}

.close-sidebar {
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-neon);
}

.sidebar-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    margin-bottom: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conversation-item {
    padding: 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.conversation-item:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.conversation-item.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.conversation-preview {
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-date {
    font-size: 10px;
    color: var(--text-muted);
}

.delete-conv {
    position: absolute;
    right: 8px;
    top: 8px;
    opacity: 0;
    transition: opacity 0.2s;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.conversation-item:hover .delete-conv {
    opacity: 1;
}

.toggle-sidebar-btn {
    position: fixed;
    left: 20px;
    top: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #000;
    font-size: 18px;
    cursor: pointer;
    z-index: 41;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.toggle-sidebar-btn.hidden {
    display: none;
}

/* Ajustar el main cuando la sidebar está abierta */
.app-shell {
    margin-left: 300px;
    transition: margin-left 0.3s ease;
}

.sidebar.closed + .app-shell {
    margin-left: 12px;
}

/* ===== SELECTOR DE MODELOS LEGIBLE ===== */
.model-select, .unit-select {
    background: var(--bg-deep);
    border: 1px solid var(--border-neon);
    border-radius: 20px;
    padding: 8px 12px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    width: 180px;
}

.model-select option, .unit-select option {
    background: var(--bg-panel);
    color: var(--text-main);
    padding: 8px;
}

.model-select optgroup {
    background: var(--bg-deep);
    color: var(--accent);
    font-weight: 600;
}
/* ===== RESPONSIVE MÓVIL MEJORADO ===== */
@media (max-width: 700px) {
    .logo-neon { font-size: 22px; }
    .model-badge { display: none; }
    .weather-city { display: none; }
    .input-wrapper { flex-direction: column; border-radius: 30px; padding: 10px; }
    .input-wrapper textarea { width: 100%; margin-bottom: 10px; }
    .input-actions { justify-content: center; }
    .send-btn { width: 100%; margin-left: 0; }
    .bottom-links { gap: 10px; flex-wrap: wrap; justify-content: center; }
    .settings-panel { width: 280px; right: 10px; }
    .sidebar { width: 240px; }
    .message { max-width: 85%; }
}

/* ===== WIDGET DE CLIMA MEJORADO ===== */
.weather-widget {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 4px 12px !important;
    border-radius: 30px !important;
    background: var(--bg-soft) !important;
    border: 1px solid var(--border-neon) !important;
    cursor: pointer !important;
    min-width: 90px !important;
    justify-content: center !important;
}

.weather-icon {
    font-size: 18px !important;
    line-height: 1 !important;
}

.weather-temp {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--accent) !important;
    white-space: nowrap !important;
}

.weather-city {
    font-size: 11px !important;
    color: var(--text-soft) !important;
    max-width: 60px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* Responsive */
@media (max-width: 700px) {
    .weather-city {
        display: none !important;
    }
    .weather-widget {
        min-width: 60px !important;
        padding: 4px 8px !important;
    }
}

/* ===== SIDEBAR QUE ACOMPAÑA AL CONTENIDO ===== */
.app-shell {
    margin-left: 300px;
    transition: margin-left 0.3s ease;
    width: calc(100% - 300px);
}

.sidebar.closed + .app-shell {
    margin-left: 12px !important;
    width: calc(100% - 24px) !important;
}

/* Ajuste para móvil */
@media (max-width: 700px) {
    .app-shell {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .sidebar.closed + .app-shell {
        margin-left: 0 !important;
        width: 100% !important;
    }
}
