/* Variables CSS para temas */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --bg-color: #ffffff;
    --text-color: #333333;
    --sidebar-bg: #f8f9fa;
    --border-color: #dee2e6;
    --card-bg: #ffffff;
    --hover-color: #e9ecef;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --sidebar-width: 280px;
}

[data-theme="dark"] {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --sidebar-bg: #2d2d2d;
    --border-color: #404040;
    --card-bg: #363636;
    --hover-color: #404040;
    --shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Clases utilitarias */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

/* Topbar */
#topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    height: 60px;
    position: relative;
    z-index: 100;
}

#menu-toggle {
    display: none;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

#nav-buttons {
    display: flex;
    gap: 5px;
}

#nav-buttons button {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#nav-buttons button:hover:not(:disabled) {
    background-color: var(--hover-color);
}

#nav-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#urlInput {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
}

#go-btn, #favorite-btn, #theme-toggle {
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

#go-btn {
    background-color: var(--primary-color);
    color: white;
}

#favorite-btn {
    background-color: var(--success-color);
    color: white;
}

#theme-toggle {
    background-color: var(--secondary-color);
    color: white;
}

#go-btn:hover, #favorite-btn:hover, #theme-toggle:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Contenido principal */
#main-content {
    display: flex;
    height: calc(100vh - 60px);
    position: relative;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    overflow-y: auto;
    position: relative;
    z-index: 50;
    transition: transform 0.3s ease;
}

#sidebar-header {
    margin-bottom: 25px;
    text-align: center;
    position: relative;
}

#sidebar-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

#close-sidebar {
    display: none;
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 16px;
}

.sidebar-section {
    margin-bottom: 30px;
}

.sidebar-section h4 {
    font-size: 14px;
    margin-bottom: 15px;
    color: var(--text-color);
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tarjetas */
.card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    margin-bottom: 8px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateX(5px);
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow);
}

.card-icon {
    font-size: 16px;
}

.card-text {
    font-size: 14px;
    font-weight: 500;
}

/* Área del navegador */
#browser-area {
    flex: 1;
    background-color: var(--bg-color);
    position: relative;
}

#webview {
    width: 100%;
    height: 100%;
    border: none;
}

/* ========== BOT IA ========== */
#bot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
}

#bot-bubble {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    font-size: 24px;
    position: relative;
    z-index: 10001;
}

#bot-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
}

#bot-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 10002;
}

#bot-chat-window.active {
    display: flex;
}

#chat-header {
    padding: 15px 20px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

#close-chat {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-chat:hover {
    opacity: 0.8;
}

#chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.message.user {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 5px;
}

.message.bot {
    align-self: flex-start;
    background-color: var(--hover-color);
    color: var(--text-color);
    border-bottom-left-radius: 5px;
}

#chat-input-container {
    display: flex;
    padding: 15px;
    border-top: 1px solid var(--border-color);
    gap: 10px;
}

#chat-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    background-color: var(--bg-color);
    color: var(--text-color);
    outline: none;
    font-size: 14px;
}

#send-message {
    padding: 12px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
}

#send-message:hover {
    opacity: 0.9;
}

/* Lista de favoritos */
.favorite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 5px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.favorite-item:hover {
    background-color: var(--hover-color);
}

.remove-favorite {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
}

.empty-message {
    text-align: center;
    color: var(--text-color);
    opacity: 0.6;
    font-style: italic;
    padding: 20px;
}

#status {
    font-size: 12px;
    color: var(--success-color);
    margin-top: 5px;
}

.info-box {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    font-size: 13px;
    line-height: 1.4;
}

.info-box p {
    margin-bottom: 8px;
}

.info-box strong {
    color: var(--primary-color);
}

/* Overlay para móvil */
#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45;
}

/* ========== RESPONSIVE PARA MÓVILES ========== */
@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
    
    #menu-toggle {
        display: block;
    }
    
    #topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 10px;
        gap: 8px;
    }
    
    #nav-buttons {
        order: 2;
        flex: 1;
        justify-content: center;
    }
    
    #urlInput {
        order: 3;
        min-width: 100%;
        margin: 5px 0;
        font-size: 16px;
    }
    
    #go-btn, #favorite-btn, #theme-toggle {
        order: 4;
        padding: 8px 12px;
        font-size: 12px;
        flex: 1;
    }
    
    #main-content {
        flex-direction: column;
        height: calc(100vh - 120px);
    }
    
    /* Sidebar móvil - colapsable */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85%;
        max-width: 300px;
        transform: translateX(-100%);
        z-index: 60;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
        padding: 60px 15px 20px 15px;
    }
    
    #sidebar.sidebar-expanded {
        transform: translateX(0);
    }
    
    #sidebar-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        background: var(--sidebar-bg);
        padding: 15px;
        margin-bottom: 15px;
        border-bottom: 1px solid var(--border-color);
    }
    
    #close-sidebar {
        display: block;
    }
    
    #sidebar-overlay {
        display: none;
    }
    
    #sidebar-overlay.sidebar-expanded {
        display: block;
    }
    
    .sidebar-sections-container {
        display: flex;
        flex-direction: column;
        gap: 20px;
        height: calc(100% - 80px);
        overflow-y: auto;
    }
    
    .sidebar-section {
        margin-bottom: 20px;
        min-width: auto;
    }
    
    .sidebar-section h4 {
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    .card {
        padding: 10px 12px;
        margin-bottom: 6px;
        font-size: 13px;
    }
    
    #browser-area {
        flex: 1;
        height: 100%;
    }
    
    /* ========== BOT IA EN MÓVIL - POSICIÓN CORREGIDA ========== */
    #bot-container {
        bottom: 20px;
        right: 20px;
    }
    
    #bot-bubble {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    #bot-chat-window {
        position: fixed;
        width: 95vw;
        height: 70vh;
        bottom: 85px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        max-width: 400px;
    }
    
    /* Ajustes específicos para móvil */
    #favorites-section {
        display: block;
    }
    
    .favorite-item {
        font-size: 12px;
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    #topbar {
        padding: 6px 8px;
    }
    
    #nav-buttons button {
        padding: 6px 8px;
        font-size: 12px;
        min-width: 35px;
    }
    
    #urlInput {
        font-size: 16px;
        padding: 10px 12px;
    }
    
    #go-btn, #favorite-btn, #theme-toggle {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    /* Bot IA en móviles pequeños */
    #bot-chat-window {
        width: 98vw;
        height: 75vh;
        bottom: 80px;
        max-width: none;
    }
    
    #bot-bubble {
        width: 50px;
        height: 50px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }
    
    .card {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    #sidebar {
        width: 90%;
    }
}

/* Scroll suave */
.sidebar-sections-container::-webkit-scrollbar {
    width: 4px;
}

.sidebar-sections-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}
