:root {
    --bg-dark: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.7);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-primary: #38bdf8;
    --accent-secondary: #818cf8;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --user-msg-bg: linear-gradient(135deg, #3b82f6, #2563eb);
    --ai-msg-bg: rgba(255, 255, 255, 0.1);
    --radius-lg: 16px;
    --radius-md: 12px;
}

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

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

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 24px;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 600;
}

.sidebar-header p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.settings-section, .model-selection {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input, select {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 12px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s ease;
}

input:focus, select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.history-section {
    flex: 1;
    overflow-y: auto;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: var(--glass-bg);
    border-color: var(--accent-primary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.05), transparent 40%),
                radial-gradient(circle at bottom left, rgba(129, 140, 248, 0.05), transparent 40%);
}

.chat-header {
    padding: 20px 40px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
}

.current-model-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #64748b;
}

.status-indicator.online { background-color: #10b981; }
.status-indicator.loading { background-color: #f59e0b; animation: pulse 1.5s infinite; }

@keyframes pulse {
    0% { opacity: 0.4; scale: 0.8; }
    50% { opacity: 1; scale: 1.1; }
    100% { opacity: 0.4; scale: 0.8; }
}

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

.welcome-message {
    text-align: center;
    margin-top: 100px;
    color: var(--text-secondary);
}

.welcome-message h2 {
    color: var(--text-primary);
    margin-bottom: 16px;
}

.message {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.ai-message {
    align-self: flex-start;
    background: var(--ai-msg-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* Input Area */
.input-area {
    padding: 20px 40px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.input-wrapper {
    width: 100%;
    max-width: 800px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    display: flex;
    align-items: flex-end;
    padding: 12px 16px;
    gap: 12px;
    backdrop-filter: blur(12px);
    transition: border-color 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    resize: none;
    padding: 8px 0;
    max-height: 200px;
    outline: none;
    font-size: 1rem;
}

#send-btn {
    background: var(--accent-primary);
    color: var(--bg-dark);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

#send-btn:disabled {
    background: #475569;
    cursor: not-allowed;
    opacity: 0.5;
}

#send-btn:hover:not(:disabled) {
    scale: 1.05;
    filter: brightness(1.1);
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Estilos para Archivos */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.05);
}

.file-preview-area {
    display: flex;
    gap: 12px;
    padding: 0 40px;
    overflow-x: auto;
    max-height: 120px;
}

.file-preview-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 150px;
    max-width: 200px;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.file-preview-card img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.file-info {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-file {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message img, .message video {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin-top: 8px;
    display: block;
}

.message .file-attachment {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Estilos Responsive y Móvil */
.mobile-only {
    display: none;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99;
    animation: fadeIn 0.3s ease;
}

.overlay.active {
    display: block;
}

.sidebar-header .header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#close-menu {
    font-size: 2rem;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -320px;
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        transform: translateX(320px);
    }

    .chat-header {
        padding: 15px 20px;
        gap: 15px;
    }

    .messages-container {
        padding: 20px;
    }

    .message {
        max-width: 90%;
    }

    .input-area {
        padding: 15px 15px 25px;
    }

    .input-wrapper {
        padding: 8px 12px;
    }

    .menu-icon {
        margin-right: 10px;
    }
}
