/* ==========================================
   NEXUS AI - Gemma 3 4B - Estilos Completos
   ========================================== */
.nexus-container,
.nexus-container * {
    box-sizing: border-box;
}

.nexus-container {
    --bg-primary: #0a0a12;
    --bg-secondary: #151520;
    --bg-tertiary: #1e1e2e;
    --accent-primary: #c084fc;
    --accent-secondary: #e879f9;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.1);
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #ef4444;
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Fondo animado sutil para el contenedor NEXUS */
.nexus-bg-animated {
    position: relative;
    background: radial-gradient(circle at center, rgba(192, 132, 252, 0.03) 0%, transparent 70%);
    animation: gradient 15s ease infinite;
}

.nexus-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
    min-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
}

/* Header Superior */
.nexus-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 8px;
}

.nexus-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 8px;
}

.nexus-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.nexus-status-indicator.online {
    background: rgba(74, 222, 128, 0.1);
    border-color: rgba(74, 222, 128, 0.3);
    color: var(--success);
}

.nexus-status-indicator.offline {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
    color: var(--warning);
}

.nexus-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nexus-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1rem;
}

.nexus-icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateY(-1px);
}

/* Hero Section */
.nexus-hero {
    text-align: center;
    margin-bottom: 50px;
    flex-shrink: 0;
    transition: opacity 0.3s, margin-bottom 0.3s;
}

.nexus-brain-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #c084fc 0%, #e879f9 50%, #f0abfc 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    filter: drop-shadow(0 0 30px rgba(192, 132, 252, 0.4));
    animation: float 6s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.nexus-hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.nexus-gradient-text {
    background: linear-gradient(to right, #fff, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.nexus-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

.nexus-subtitle strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Sugerencias */
.nexus-suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
    flex-shrink: 0;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.nexus-suggestion-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nexus-suggestion-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.nexus-suggestion-card:hover {
    transform: translateY(-2px);
    border-color: rgba(192, 132, 252, 0.3);
    box-shadow: 0 10px 40px -10px rgba(192, 132, 252, 0.2);
}

.nexus-suggestion-card:hover::before {
    transform: translateX(100%);
}

.suggestion-icon {
    font-size: 1.5rem;
    margin-bottom: 12px;
    display: block;
}

.suggestion-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.suggestion-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Modos - Multi-selección con checkboxes */
.nexus-mode-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.nexus-mode-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: var(--text-secondary);
    user-select: none;
    font-weight: 500;
}

.nexus-mode-chip:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.nexus-mode-chip.active {
    border-color: rgba(192, 132, 252, 0.4);
    background: rgba(192, 132, 252, 0.15);
    color: var(--accent-primary);
}

.nexus-mode-chip input[type="checkbox"] {
    display: none;
}

.nexus-mode-chip i {
    font-size: 0.9rem;
}

/* Input Area - Mejorada */
.nexus-input-area {
    margin-top: auto;
    padding-bottom: 20px;
    position: relative;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.nexus-input-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
}

.nexus-input-container:focus-within {
    border-color: rgba(192, 132, 252, 0.4);
    box-shadow: 0 4px 20px rgba(192, 132, 252, 0.1);
}

.nexus-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

.nexus-attach-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
}

.nexus-attach-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nexus-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    padding: 8px 12px;
    outline: none;
    resize: vertical;
    min-height: 60px;
    max-height: 200px;
    font-family: inherit;
    line-height: 1.5;
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.nexus-input::placeholder {
    color: var(--text-tertiary);
}

/* Scroll personalizado para el textarea */
.nexus-input::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.nexus-input::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.nexus-input::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

.nexus-input::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.nexus-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f87171, #ef4444);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    flex-shrink: 0;
}

.nexus-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.nexus-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nexus-input-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px 0;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.nexus-messages {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    margin-bottom: 16px;
    max-width: 100%;
    overflow-wrap: break-word;
}

.message.user {
    text-align: right;
}

.message.ai {
    text-align: left;
}

.message-content {
    display: inline-block;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.ai .message-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
}

/* Scroll horizontal para contenido largo */
.message-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.message-action-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.message-action-btn.copy-btn:hover {
    background: rgba(59, 130, 246, 0.8);
}

.message-action-btn.regenerate-btn:hover {
    background: rgba(16, 185, 129, 0.8);
}

.message-action-btn.edit-btn:hover {
    background: rgba(236, 72, 153, 0.8);
}

/* Ajustar posición relativa para contenedor de mensaje */
.message {
    position: relative;
}

.message-content {
    overflow-x: auto;
    overflow-y: auto;
}

.message-content::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.message-content::-webkit-scrollbar-track {
    background: transparent;
}

.message-content::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 2px;
    opacity: 0.5;
}

.message-content::-webkit-scrollbar-thumb:hover {
    opacity: 0.8;
}

/* Para tablas y código largos */
.message-content table,
.message-content pre {
    overflow-x: auto;
    display: block;
    max-width: 100%;
}

.message-content code {
    background: rgba(192, 132, 252, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-content pre {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin: 12px 0;
    overflow-x: auto;
}

.message-content pre code {
    background: none;
    padding: 0;
    white-space: pre;
    word-break: normal;
}

/* Chat Area */
.nexus-chat-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    padding-right: 8px;
    scroll-behavior: smooth;
}


.nexus-message {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 20px;
    line-height: 1.6;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: justify;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nexus-message.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

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

/* MARKDOWN STYLES FOR AI MESSAGE */
.nexus-message.ai p {
    margin-bottom: 0.8rem;
}

.nexus-message.ai p:last-child {
    margin-bottom: 0;
}

.nexus-message.ai strong {
    color: var(--accent-primary);
    font-weight: 700;
}

.nexus-message.ai em {
    font-style: italic;
    color: var(--text-secondary);
}

.nexus-message.ai ul,
.nexus-message.ai ol {
    margin-bottom: 0.8rem;
    padding-left: 1.5rem;
}

.nexus-message.ai li {
    margin-bottom: 0.4rem;
}

.nexus-message.ai code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.nexus-message.ai pre {
    background: #0d1117;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    white-space: pre-wrap;
    /* Wrap long lines */
    word-wrap: break-word;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.nexus-message.ai pre code {
    background: transparent;
    padding: 0;
    border: none;
    color: #e6edf3;
    display: block;
}

.nexus-message.ai blockquote {
    border-left: 3px solid var(--accent-primary);
    margin: 0 0 1rem 0;
    padding-left: 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.nexus-message.ai h1,
.nexus-message.ai h2,
.nexus-message.ai h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
}

.nexus-message.ai h1 {
    font-size: 1.4rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.nexus-message.ai h2 {
    font-size: 1.2rem;
}

.message.ai h3 {
    font-size: 1.1rem;
}

.nexus-message.ai a {
    color: var(--accent-primary);
    text-decoration: underline;
}

/* Modal */
.nexus-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    opacity: 1;
    align-items: center;
    justify-content: center;
}

.nexus-modal.active {
    display: flex;
}

.nexus-modal-content {
    background: var(--bg-secondary);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.nexus-modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nexus-modal-body {
    overflow-y: auto;
    padding: 24px;
    max-height: 70vh;
    /* Ensure modal body scrolls if content is too tall */
}

.nexus-modal-close {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
}

.nexus-modal-close:hover {
    color: var(--text-primary);
}

.nexus-settings-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.nexus-settings-section h3 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.selector-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.small-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.small-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.nexus-btn-secondary.mini {
    padding: 6px 12px;
    font-size: 0.8rem;
    margin-top: 8px;
}


.nexus-setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.nexus-setting-item label {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.nexus-setting-item select,
.nexus-setting-item input[type="range"],
.nexus-setting-item input[type="text"],
.nexus-setting-item input[type="password"] {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
}

.nexus-setting-item small {
    color: var(--text-secondary);
    display: block;
    margin-top: 4px;
}

.range-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-value {
    font-size: 0.85rem;
    color: var(--accent-primary);
    font-weight: 600;
    min-width: 90px;
    text-align: right;
}

.nexus-documents-list {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
}

.nexus-doc-item {
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-primary);
}

.nexus-doc-item:hover {
    background: rgba(192, 132, 252, 0.12);
}

.empty-docs {
    margin: 0;
    color: var(--text-secondary);
}

.nexus-modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.nexus-btn-secondary,
.nexus-btn-primary {
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
}

.nexus-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.nexus-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 1.2rem;
    font-weight: 600;
}

/* API Key wrapper */
.api-key-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-key-wrapper input {
    flex: 1;
}

.toggle-visibility {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.toggle-visibility:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Checkbox Style */
.nexus-setting-item.checkbox label {
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    padding-left: 30px;
}

.nexus-setting-item.checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.nexus-setting-item.checkbox input:checked~.checkmark {
    background-color: var(--accent-primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.nexus-setting-item.checkbox input:checked~.checkmark:after {
    display: block;
}

.nexus-setting-item.checkbox .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Toast */
.nexus-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.nexus-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.nexus-toast.error {
    border-color: var(--error);
    color: var(--error);
}

.nexus-toast.success {
    border-color: var(--success);
    color: var(--success);
}