﻿        /* ==========================================
           ESTILOS PREMIUM - CHAT IA
           Basado en ESTILOS_VISUALES_PREMIUM.md
        ========================================== */

        :root {
            /* Color Principal (Deep Blue) */
            --premium-primary: #0D009E;
            --premium-primary-dark: #07004F;

            /* Acento (Bright Blue) */
            --premium-accent: #4263eb;
            --premium-accent-light: rgba(66, 99, 235, 0.1);

            /* Gradientes */
            --premium-gradient-primary: linear-gradient(135deg, #0D009E 0%, #07004F 100%);
            --premium-gradient-bg: linear-gradient(180deg, #ffffff 0%, #f8faff 50%, #f0f4ff 100%);

            /* Glassmorphism */
            --premium-glass: rgba(255, 255, 255, 0.95);
            --premium-backdrop-blur: 20px;

            /* Textos */
            --premium-text: #1a1a2e;
            --premium-text-light: #6c7a94;
            --premium-text-disabled: #9ca3af;

            /* Bordes y Sombras */
            --premium-border: rgba(13, 0, 158, 0.1);
            --premium-shadow-depth: 0 20px 60px rgba(7, 0, 79, 0.25);
            --premium-shadow-subtle: 0 4px 12px rgba(13, 0, 158, 0.08);
            --premium-shadow-card: 0 8px 32px rgba(7, 0, 79, 0.12);

            /* Sidebar */
            --sidebar-width: 280px;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }

        html,
        body {
            height: 100%;
            overflow: hidden;
            font-family: 'Outfit', sans-serif;
            background: #ffffff;
            color: var(--premium-text);
        }

        /* ==========================================
           SIDEBAR - ESTILO CHATGPT
        ========================================== */
        .sidebar {
            position: fixed;
            top: 0;
            left: 0;
            width: var(--sidebar-width);
            height: 100vh;
            background: var(--premium-gradient-primary);
            transform: translateX(-100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 200;
            display: flex;
            flex-direction: column;
            box-shadow: var(--premium-shadow-depth);
        }

        .sidebar.open {
            transform: translateX(0);
        }

        .sidebar-header {
            padding: 1rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .sidebar-logo {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .sidebar-logo img {
            height: 28px;
        }

        .sidebar-logo span {
            color: white;
            font-weight: 700;
            font-size: 1.1rem;
        }

        .sidebar-close {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.1);
            border: none;
            border-radius: 8px;
            color: white;
            cursor: pointer;
            transition: all 0.2s;
        }

        .sidebar-close:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        .sidebar-actions {
            padding: 1rem;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .sidebar-btn {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.875rem 1rem;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 12px;
            color: white;
            font-size: 0.9rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            font-family: inherit;
            text-decoration: none;
        }

        .sidebar-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            border-color: rgba(255, 255, 255, 0.25);
        }

        .sidebar-btn.primary {
            background: white;
            color: var(--premium-primary);
            border-color: white;
            font-weight: 600;
        }

        .sidebar-btn.primary:hover {
            background: rgba(255, 255, 255, 0.9);
        }

        .sidebar-btn svg {
            width: 18px;
            height: 18px;
            stroke-width: 2;
        }

        .sidebar-divider {
            height: 1px;
            background: rgba(255, 255, 255, 0.1);
            margin: 0.5rem 1rem;
        }

        .sidebar-label {
            color: rgba(255, 255, 255, 0.6);
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            padding: 0 1rem;
            margin-bottom: 0.5rem;
        }

        .sidebar-history {
            flex: 1;
            overflow-y: auto;
            padding: 0 0.75rem 1rem;
        }

        .sidebar-history::-webkit-scrollbar {
            width: 4px;
        }

        .sidebar-history::-webkit-scrollbar-track {
            background: transparent;
        }

        .sidebar-history::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 4px;
        }

        .history-item {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.75rem;
            background: transparent;
            border: none;
            border-radius: 10px;
            color: rgba(255, 255, 255, 0.85);
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.2s;
            width: 100%;
            text-align: left;
            font-family: inherit;
            margin-bottom: 0.25rem;
        }

        .history-item:hover {
            background: rgba(255, 255, 255, 0.1);
            color: white;
        }

        .history-item.active {
            background: rgba(255, 255, 255, 0.15);
            color: white;
        }

        .history-item {
            position: relative;
        }

        .history-item-more {
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            border-radius: 6px;
            color: rgba(255, 255, 255, 0.5);
            cursor: pointer;
            opacity: 0;
            transition: all 0.2s;
            margin-left: 4px;
        }

        .history-item:hover .history-item-more,
        .history-item.active .history-item-more {
            opacity: 1;
        }

        .history-item-more:hover {
            background: rgba(255, 255, 255, 0.2);
            color: white;
        }

        /* Context Menu Styles - Estilo Gemini/ChatGPT */
        .chat-item-menu {
            position: absolute;
            right: 10px;
            top: 40px;
            background: var(--premium-primary-dark);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            padding: 6px;
            z-index: 1000;
            width: 160px;
            display: none;
            animation: menuFadeIn 0.2s ease;
        }

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

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

        .chat-item-menu.active {
            display: block;
        }

        .menu-option {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            color: rgba(255, 255, 255, 0.8);
            font-size: 0.85rem;
            cursor: pointer;
            border-radius: 8px;
            transition: all 0.2s;
        }

        .menu-option:hover {
            background: rgba(255, 255, 255, 0.1);
            color: white;
        }

        .menu-option svg {
            width: 16px !important;
            height: 16px !important;
            opacity: 0.7;
        }

        .menu-option.delete {
            color: #ff4d4d;
        }

        .menu-option.delete:hover {
            background: rgba(255, 77, 77, 0.1);
        }

        .history-item svg {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
            opacity: 0.7;
        }

        .history-item-text {
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }



        .sidebar-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(7, 0, 79, 0.45);
            backdrop-filter: blur(4px);
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s;
            z-index: 150;
        }

        .sidebar-overlay.show {
            opacity: 1;
            visibility: visible;
        }

        /* ==========================================
           HEADER - PREMIUM
        ========================================== */
        .header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 60px;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 255, 0.95) 100%);
            backdrop-filter: blur(var(--premium-backdrop-blur));
            -webkit-backdrop-filter: blur(var(--premium-backdrop-blur));
            border-bottom: 1px solid var(--premium-border);
            box-shadow: 0 2px 12px rgba(7, 0, 79, 0.06);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 1rem;
            z-index: 100;
        }

        .header-left {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .menu-toggle {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: 1px solid var(--premium-border);
            border-radius: 10px;
            cursor: pointer;
            color: var(--premium-text-light);
            transition: all 0.2s;
        }

        .menu-toggle:hover {
            background: var(--premium-accent-light);
            border-color: var(--premium-accent);
            color: var(--premium-primary);
        }

        .menu-toggle svg {
            width: 20px;
            height: 20px;
        }

        .logo-link {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            text-decoration: none;
            color: var(--premium-primary);
            font-weight: 700;
            font-size: 1.125rem;
        }

        .logo-link img {
            height: 28px;
            width: auto;
        }

        .logo-link span {
            color: var(--premium-text);
        }

        .header-title {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.4rem 0.875rem;
            background: linear-gradient(135deg, rgba(13, 0, 158, 0.06) 0%, rgba(66, 99, 235, 0.1) 100%);
            border: 1px solid var(--premium-border);
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--premium-primary);
        }

        .header-title-icon {
            width: 18px;
            height: 18px;
        }

        .header-right {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }


        .header-btn {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: 1px solid var(--premium-border);
            border-radius: 10px;
            cursor: pointer;
            color: var(--premium-text-light);
            transition: all 0.2s;
        }

        .header-btn:hover {
            background: var(--premium-accent-light);
            border-color: var(--premium-accent);
            color: var(--premium-primary);
        }

        #headerAuth {
            display: flex;
            align-items: center;
        }

        /* ==========================================
           MAIN CONTAINER
        ========================================== */
        .main-container {
            height: 100vh;
            padding-top: 60px;
            display: flex;
            flex-direction: column;
            background: #ffffff;
        }

        /* ==========================================
           CHAT AREA
        ========================================== */
        .chat-area {
            flex: 1;
            overflow-y: auto;
            padding: 2rem 1rem;
            display: flex;
            flex-direction: column;
        }

        .chat-area::-webkit-scrollbar {
            width: 6px;
        }

        .chat-area::-webkit-scrollbar-track {
            background: transparent;
        }

        .chat-area::-webkit-scrollbar-thumb {
            background: var(--premium-border);
            border-radius: 6px;
        }

        /* ==========================================
           EMPTY STATE - PREMIUM
        ========================================== */
        .empty-state {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            max-width: 640px;
            margin: 0 auto;
            text-align: center;
            padding: 2rem 1rem;
            animation: fadeInUp 0.5s ease forwards;
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

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

        .empty-icon {
            width: 72px;
            height: 72px;
            background: linear-gradient(135deg, rgba(13, 0, 158, 0.08) 0%, rgba(66, 99, 235, 0.15) 100%);
            border: 2px solid var(--premium-border);
            border-radius: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 1.5rem;
            position: relative;
        }

        .empty-icon svg {
            width: 36px;
            height: 36px;
            stroke: var(--premium-primary);
            stroke-width: 1.5;
        }

        .empty-icon::after {
            content: '';
            position: absolute;
            top: -6px;
            right: -6px;
            width: 16px;
            height: 16px;
            background: var(--premium-gradient-primary);
            border-radius: 50%;
            border: 2px solid white;
        }

        .empty-title {
            font-size: 1.75rem;
            font-weight: 700;
            margin-bottom: 0.5rem;
            background: var(--premium-gradient-primary);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .empty-subtitle {
            font-size: 1rem;
            color: var(--premium-text-light);
            margin-bottom: 2.5rem;
            line-height: 1.6;
        }

        /* ==========================================
           SUGGESTION CARDS - PREMIUM
        ========================================== */
        .suggestions {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 0.875rem;
            width: 100%;
            margin-bottom: 2rem;
        }

        .suggestion-card {
            padding: 1.125rem;
            background: var(--premium-glass);
            border: 2px solid var(--premium-border);
            border-radius: 16px;
            text-align: left;
            cursor: pointer;
            transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
            position: relative;
            overflow: hidden;
        }

        .suggestion-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: var(--card-accent, var(--premium-gradient-primary));
            opacity: 0;
            transition: opacity 0.25s;
        }

        .suggestion-card:hover::before {
            opacity: 1;
        }

        .suggestion-card:hover {
            border-color: var(--premium-accent);
            transform: translateY(-4px);
            box-shadow: var(--premium-shadow-card);
        }

        .suggestion-card:active {
            transform: translateY(-2px);
        }

        .suggestion-icon-container {
            width: 40px;
            height: 40px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 0.75rem;
        }

        .suggestion-icon-container svg {
            width: 20px;
            height: 20px;
            stroke-width: 1.8;
        }

        /* Card colors */
        .suggestion-card.explain {
            --card-accent: linear-gradient(90deg, #3b82f6, #60a5fa);
        }

        .suggestion-card.explain .suggestion-icon-container {
            background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(96, 165, 250, 0.18) 100%);
        }

        .suggestion-card.explain .suggestion-icon-container svg {
            stroke: #2563eb;
        }

        .suggestion-card.mindmap {
            --card-accent: linear-gradient(90deg, #8b5cf6, #a78bfa);
        }

        .suggestion-card.mindmap .suggestion-icon-container {
            background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(167, 139, 250, 0.18) 100%);
        }

        .suggestion-card.mindmap .suggestion-icon-container svg {
            stroke: #7c3aed;
        }

        .suggestion-card.summarize {
            --card-accent: linear-gradient(90deg, #f59e0b, #fbbf24);
        }

        .suggestion-card.summarize .suggestion-icon-container {
            background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(251, 191, 36, 0.18) 100%);
        }

        .suggestion-card.summarize .suggestion-icon-container svg {
            stroke: #d97706;
        }

        .suggestion-card.compare {
            --card-accent: linear-gradient(90deg, #10b981, #34d399);
        }

        .suggestion-card.compare .suggestion-icon-container {
            background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(52, 211, 153, 0.18) 100%);
        }

        .suggestion-card.compare .suggestion-icon-container svg {
            stroke: #059669;
        }

        .suggestion-text {
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--premium-text);
            line-height: 1.4;
        }

        /* ==========================================
           MESSAGES
        ========================================== */
        .messages {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            max-width: 1100px;
            margin: 0 auto;
            width: 100%;
            padding: 0 1.5rem;
        }

        .message {
            display: flex;
            gap: 1rem;
            animation: fadeIn 0.4s ease;
            align-items: flex-start;
            word-break: break-word;
        }

        /* KaTeX Adjustments */
        .katex-display {
            overflow-x: auto;
            overflow-y: hidden;
            padding: 0.5rem 0;
            margin: 0.5rem 0;
        }

        .message-text .katex {
            font-size: 1.1em;
        }

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

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

        .message-avatar {
            width: 40px;
            height: 40px;
            border-radius: 12px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
        }

        .message-avatar.user {
            background: linear-gradient(135deg, rgba(13, 0, 158, 0.1) 0%, rgba(66, 99, 235, 0.15) 100%);
            border: 2px solid var(--premium-border);
        }

        .message-avatar.user svg {
            width: 20px;
            height: 20px;
            stroke: var(--premium-primary);
            stroke-width: 2;
        }

        .message-avatar.ai {
            background: var(--premium-gradient-primary);
            box-shadow: 0 4px 12px rgba(13, 0, 158, 0.2);
        }

        .message-avatar.ai svg {
            width: 20px;
            height: 20px;
            stroke: white;
            stroke-width: 1.5;
        }

        .message-content {
            flex: 1;
            line-height: 1.6;
            color: var(--premium-text);
            word-wrap: break-word;
            overflow-wrap: break-word;
        }

        .message.user {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            justify-content: flex-end;
            width: 100%;
        }

        .message.ai .message-content {
            background: rgba(66, 99, 235, 0.04);
            padding: 1rem 1.25rem;
            border-radius: 12px;
            border-left: 3px solid var(--premium-accent);
            box-shadow: 0 2px 8px rgba(13, 0, 158, 0.06);
        }

        .message.user .message-user-row { display: flex; align-items: center; gap: 0.6rem; justify-content: flex-end; width: auto; align-self: flex-end; position: relative; }

        .message.user .message-content {
            background: var(--premium-primary);
            color: white;
            padding: 0.85rem 1.25rem;
            border-radius: 16px 16px 2px 16px;
            box-shadow: 0 4px 15px rgba(13, 0, 158, 0.15);
            text-align: left;
            max-width: 85%;
            margin-left: 0;
            flex: initial;
        }

        .message.user .message-content p {
            color: white;
        }

        .message.user .message-content strong {
            color: white;
            font-weight: 800;
        }

        .message-avatar-tiny {
            width: 16px;
            height: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .message-avatar-tiny svg {
            width: 100%;
            height: 100%;
            stroke: white !important;
        }

        .message-meta {
            font-size: 0.8rem;
            color: var(--premium-text-disabled);
            margin-top: 0.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 0.75rem;
        }

        .message-meta-left {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            flex-wrap: wrap;
        }

        @media (max-width: 600px) {
            .message-meta {
                flex-direction: column;
                align-items: flex-start;
                gap: 0.6rem;
            }

            .message-paginator-wrapper {
                width: 100%;
                display: flex;
                padding-left: 0.2rem;
            }
        }

        .message-time {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .message-actions {
            display: flex;
            gap: 0.5rem;
        }

        .message-action-btn {
            background: none;
            border: none;
            cursor: pointer;
            padding: 4px 8px;
            border-radius: 6px;
            color: var(--premium-text-light);
            transition: all 0.2s;
            font-size: 0.85rem;
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .message-action-btn:hover {
            background: rgba(13, 0, 158, 0.1);
            color: var(--premium-primary);
        }

        .message-action-btn.copy-btn {
            width: auto;
        }

        .message-action-btn.copy-btn.copied {
            color: #22c55e;
        }

        /* Estilos Markdown */
        .markdown-body p {
            margin-bottom: 0.5rem;
        }

        .markdown-body p:last-child {
            margin-bottom: 0;
        }

        .markdown-body ul,
        .markdown-body ol {
            margin-left: 1.5rem;
            margin-bottom: 0.5rem;
        }

        .markdown-body pre {
            background: #f1f5f9;
            padding: 0.75rem;
            border-radius: 8px;
            overflow-x: auto;
            margin: 0.5rem 0;
            font-family: monospace;
            font-size: 0.85em;
        }

        .markdown-body code {
            background: #f1f5f9;
            padding: 0.1rem 0.3rem;
            border-radius: 4px;
            font-family: monospace;
            font-size: 0.9em;
            color: #d63384;
        }

        .markdown-body pre code {
            background: none;
            color: inherit;
            padding: 0;
        }

        .markdown-body strong {
            font-weight: 700;
            color: var(--premium-primary);
        }

        .message.user .message-user-row { display: flex; align-items: center; gap: 0.6rem; justify-content: flex-end; width: auto; align-self: flex-end; position: relative; }

        .typing-indicator {
            display: flex;
            gap: 0.375rem;
            padding: 0.5rem 0;
        }

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

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

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

        @keyframes typing {

            0%,
            60%,
            100% {
                transform: translateY(0);
                opacity: 0.5;
            }

            30% {
                transform: translateY(-8px);
                opacity: 1;
            }
        }

        .typing-status {
            font-size: 0.85rem;
            color: var(--premium-primary);
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-bottom: 0.4rem;
            opacity: 0.9;
            animation: pulse-status 2s infinite ease-in-out;
        }

        @keyframes pulse-status {
            0% {
                opacity: 0.4;
                transform: translateX(0);
            }

            50% {
                opacity: 1;
                transform: translateX(2px);
            }

            100% {
                opacity: 0.4;
                transform: translateX(0);
            }
        }

        .typing-indicator {
            display: flex;
            gap: 0.35rem;
            padding: 0.2rem 0;
        }

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

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

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

        /* Fuentes / Referencias UI */
        .message-sources {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            margin: 0.75rem 0 0.25rem 0;
            padding-top: 0.75rem;
            border-top: 1px dashed rgba(66, 99, 235, 0.15);
            animation: fadeIn 0.5s ease;
        }

        .source-chip {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.35rem 0.65rem;
            background: white;
            border: 1px solid var(--premium-border);
            border-radius: 8px;
            font-size: 0.75rem;
            color: var(--premium-primary);
            text-decoration: none;
            transition: all 0.2s;
            max-width: 200px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
        }

        .source-chip:hover {
            transform: translateY(-2px);
            border-color: var(--premium-accent);
            box-shadow: 0 4px 8px rgba(13, 0, 158, 0.08);
            background: var(--premium-accent-light);
        }

        .source-chip-icon {
            flex-shrink: 0;
            opacity: 0.7;
        }

        .source-chip-name {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-weight: 600;
        }

        .source-chip-domain {
            font-size: 0.65rem;
            opacity: 0.5;
            font-weight: 400;
        }

        /* AI Response Paginator (Anexit Variant System) */
        .variant-paginator {
            display: flex;
            align-items: center;
            gap: 0.25rem;
            padding: 0.2rem 0.35rem;
            background: rgba(13, 0, 158, 0.04);
            border-radius: 20px;
            border: 1px solid var(--premium-border);
        }

        .variant-btn {
            background: none;
            border: none;
            padding: 0.3rem;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--premium-text-light);
            transition: all 0.2s;
        }

        .variant-btn:hover:not(:disabled) {
            background: white;
            color: var(--premium-primary);
            box-shadow: 0 2px 8px rgba(13, 0, 158, 0.08);
        }

        .variant-btn:disabled {
            opacity: 0.2;
            cursor: not-allowed;
        }

        .variant-counter {
            font-size: 0.7rem;
            font-weight: 600;
            color: var(--premium-primary-dark);
            min-width: 28px;
            text-align: center;
            letter-spacing: 0.5px;
            opacity: 0.8;
        }

        /* ==========================================
           INPUT AREA - PREMIUM MEJORADO
        ========================================== */
        .input-area {
            position: sticky;
            bottom: 0;
            left: 0;
            right: 0;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.98) 15%, #ffffff 100%);
            padding: 1rem 1rem 1.5rem;
            border-top: 1px solid var(--premium-border);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
        }

        .input-wrapper {
            max-width: 900px;
            margin: 0 auto;
            position: relative;
        }

        .input-header-row {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            margin-bottom: 0.75rem;
            flex-wrap: wrap;
        }

        .input-options {
            display: flex;
            gap: 0.5rem;
            flex-wrap: wrap;
        }

        .option-btn {
            display: flex;
            align-items: center;
            gap: 0.375rem;
            padding: 0.5rem 0.875rem;
            background: var(--premium-glass);
            border: 1px solid var(--premium-border);
            border-radius: 10px;
            font-size: 0.8rem;
            font-weight: 500;
            color: var(--premium-text-light);
            cursor: pointer;
            transition: all 0.2s;
            font-family: inherit;
        }

        .option-btn:hover {
            border-color: var(--premium-accent);
            color: var(--premium-primary);
            background: var(--premium-accent-light);
        }

        .option-btn.active {
            background: linear-gradient(135deg, rgba(13, 0, 158, 0.08) 0%, rgba(66, 99, 235, 0.12) 100%);
            border-color: var(--premium-primary);
            color: var(--premium-primary);
            font-weight: 600;
        }

        .option-btn svg {
            width: 14px;
            height: 14px;
        }

        .input-container {
            position: relative;
            display: flex;
            align-items: flex-end;
            gap: 0.75rem;
            background: var(--premium-glass);
            border: 2px solid var(--premium-border);
            border-radius: 16px;
            padding: 0.875rem 1rem;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 4px 12px rgba(13, 0, 158, 0.08);
        }

        .input-container:focus-within {
            border-color: var(--premium-primary);
            box-shadow: 0 0 0 4px rgba(13, 0, 158, 0.12), 0 4px 16px rgba(13, 0, 158, 0.12);
            background: white;
        }

        .message-input {
            flex: 1;
            background: transparent;
            border: none;
            outline: none;
            font-size: 0.975rem;
            font-family: inherit;
            color: var(--premium-text);
            resize: none;
            max-height: 120px;
            min-height: 28px;
            line-height: 1.5;
            font-weight: 500;
        }

        .message-input::placeholder {
            color: var(--premium-text-disabled);
            font-weight: 400;
        }

        .input-counter {
            font-size: 0.75rem;
            color: var(--premium-text-disabled);
            padding: 0 0.5rem;
            display: none;
        }

        .input-counter.visible {
            display: block;
        }

        .input-actions {
            display: flex;
            gap: 0.5rem;
            align-items: center;
        }

        .attach-btn,
        .send-btn {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: 1.5px solid var(--premium-border);
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            color: var(--premium-text-light);
            padding: 0;
        }

        .attach-btn:hover {
            border-color: var(--premium-accent);
            color: var(--premium-accent);
            background: var(--premium-accent-light);
        }

        .send-btn {
            border: none;
            background: var(--premium-primary);
            color: white;
            font-weight: 600;
        }

        .send-btn:not(:disabled):hover {
            background: var(--premium-primary-dark);
            box-shadow: 0 4px 12px rgba(13, 0, 158, 0.25);
            transform: translateY(-2px);
        }

        .send-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            background: var(--premium-text-disabled);
        }

        .attach-btn svg,
        .send-btn svg {
            width: 20px;
            height: 20px;
            stroke-width: 2;
        }

        .attach-btn svg,
        .send-btn svg {
            width: 20px;
            height: 20px;
        }

        .send-btn {
            background: var(--premium-gradient-primary);
            border-color: transparent;
            color: white;
            box-shadow: 0 4px 12px rgba(13, 0, 158, 0.25);
            position: relative;
            overflow: hidden;
        }

        .send-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 200%;
            height: 100%;
            background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
            transition: left 0.4s ease;
        }

        .send-btn:hover::before {
            left: 100%;
        }

        .send-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(13, 0, 158, 0.35);
        }

        .send-btn:active {
            transform: translateY(0);
        }

        .send-btn:disabled {
            background: #e2e8f0;
            border-color: #e2e8f0;
            color: #94a3b8;
            cursor: not-allowed;
            box-shadow: none;
        }

        .send-btn:disabled::before {
            display: none;
        }

        .send-btn:disabled:hover {
            transform: none;
        }

        .input-hint {
            font-size: 0.75rem;
            color: var(--premium-text-light);
            text-align: center;
            margin-top: 0.75rem;
        }

        .input-hint a {
            color: var(--premium-primary);
            text-decoration: none;
            font-weight: 600;
            transition: color 0.2s;
        }

        .input-hint a:hover {
            color: var(--premium-accent);
            text-decoration: underline;
        }

        /* ==========================================
           RESPONSIVE
        ========================================== */
        @media (max-width: 768px) {
            :root {
                --sidebar-width: 240px;
            }

            .header {
                padding: 0.75rem 0.5rem;
                gap: 0.5rem;
            }

            .logo-link {
                gap: 0.35rem;
            }

            .logo-link img {
                height: 28px;
            }

            .logo-link span {
                display: none;
            }

            .header-title span {
                display: none;
            }

            .header-actions {
                gap: 0.5rem;
            }

            .icon-btn {
                width: 32px;
                height: 32px;
                font-size: 0.9rem;
            }

            .empty-title {
                font-size: 1.35rem;
            }

            .chat-area {
                padding: 1rem 0.75rem;
            }

            .input-area {
                padding: 1rem 0.75rem 1.5rem;
            }

            .suggestions {
                grid-template-columns: 1fr;
                gap: 0.5rem;
            }

            .suggestion-card {
                padding: 0.75rem 1rem;
                font-size: 0.85rem;
            }

            .input-options {
                overflow-x: auto;
                scrollbar-width: none;
                padding-bottom: 0.25rem;
                gap: 0.5rem;
            }

            .input-options::-webkit-scrollbar {
                display: none;
            }

            .option-btn {
                white-space: nowrap;
                padding: 0.6rem 0.8rem;
                font-size: 0.8rem;
            }

            .message-input {
                padding: 0.75rem 1rem;
                font-size: 0.9rem;
                border-radius: 8px;
            }

            .message-input-footer {
                gap: 0.5rem;
            }

            .btn-send {
                padding: 0.5rem 0.75rem;
                font-size: 0.85rem;
            }

            .message {
                margin-bottom: 0.75rem;
                padding: 0.75rem 1rem;
                border-radius: 10px;
            }

            .message.user {
                padding: 0 !important;
                background: transparent !important;
                display: flex !important;
                justify-content: flex-end !important;
            }

            .message.user .message-user-row { display: flex; align-items: center; gap: 0.6rem; justify-content: flex-end; width: auto; align-self: flex-end; position: relative; }
        }

        @media (max-width: 480px) {
            :root {
                --sidebar-width: 220px;
            }

            .header {
                padding: 0.5rem 0.35rem;
                gap: 0.35rem;
            }

            .logo-link {
                gap: 0.25rem;
            }

            .logo-link img {
                height: 24px;
            }

            .header-title {
                font-size: 0.9rem;
            }

            .icon-btn {
                width: 28px;
                height: 28px;
                font-size: 0.8rem;
                padding: 0.35rem;
            }

            .sidebar {
                width: var(--sidebar-width);
            }

            .sidebar-header {
                padding: 0.75rem;
            }

            .sidebar-logo img {
                height: 20px;
            }

            .sidebar-logo span {
                display: none;
            }

            .sidebar-btn {
                padding: 0.65rem 0.75rem;
                font-size: 0.8rem;
                gap: 0.5rem;
            }

            .history-item {
                padding: 0.6rem;
                font-size: 0.75rem;
                margin-bottom: 0.15rem;
            }

            .history-item svg {
                width: 14px;
                height: 14px;
            }

            .empty-title {
                font-size: 1.1rem;
            }

            .empty-subtitle {
                font-size: 0.85rem;
            }

            .chat-area {
                padding: 0.75rem 0.5rem;
            }

            .input-area {
                padding: 0.75rem 0.5rem 1rem;
            }

            .suggestions {
                grid-template-columns: 1fr;
                gap: 0.4rem;
            }

            .suggestion-card {
                padding: 0.6rem 0.8rem;
                font-size: 0.75rem;
                border-radius: 8px;
            }

            .input-header-row {
                flex-direction: column;
                align-items: flex-start;
                gap: 0.5rem;
            }

            .input-options {
                gap: 0.35rem;
            }

            .file-chip {
                max-width: 160px;
                padding: 6px 10px;
                font-size: 0.75rem;
            }

            .file-chip-name {
                max-width: 100px;
            }

            .option-btn {
                padding: 0.5rem 0.6rem;
                font-size: 0.7rem;
                border-radius: 6px;
            }

            .message {
                margin-bottom: 0.5rem;
                padding: 0.65rem 0.8rem;
                border-radius: 8px;
            }

            .message-content {
                font-size: 0.85rem;
            }

            .input-wrapper {
                gap: 0.4rem;
            }

            .message-input {
                padding: 0.65rem 0.75rem;
                font-size: 0.9rem;
                border-radius: 6px;
            }

            .btn-send {
                padding: 0.4rem 0.6rem;
                font-size: 0.75rem;
            }

            .toast {
                padding: 0.75rem;
                border-radius: 8px;
                font-size: 0.8rem;
            }
        }

        @media (min-width: 769px) {
            .chat-area {
                padding: 3rem 2rem;
            }

            .input-area {
                padding: 1rem 2rem 1.25rem;
            }

            .empty-title {
                font-size: 2rem;
            }
        }

        @media (min-width: 1024px) {
            /* En desktop, sidebar empieza abierta (se agrega .open via JS) */
            /* pero el usuario puede cerrarla si quiere */

            .sidebar {
                box-shadow: none;
                border-right: 1px solid var(--premium-border);
            }

            .sidebar.open~.main-container {
                margin-left: var(--sidebar-width);
            }

            .sidebar.open~.header {
                left: var(--sidebar-width);
            }

            /* En desktop sin sidebar, contenido ocupa todo */
            .main-container {
                margin-left: 0;
                transition: margin-left 0.3s ease;
            }

            .header {
                left: 0;
                transition: left 0.3s ease;
            }

            /* Overlay no es necesario en desktop */
            .sidebar-overlay {
                display: none;
            }

            .empty-title {
                font-size: 2rem;
            }
        }

        /* ===== NOTIFICACIONES TOAST ===== */
        .toast-container {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 9999;
            display: flex;
            flex-direction: column;
            gap: 10px;
            pointer-events: none;
        }

        .toast {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 14px 16px;
            border-radius: 8px;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
            font-size: 14px;
            font-weight: 500;
            pointer-events: auto;
            cursor: default;
            max-width: 360px;
            min-width: 280px;
            animation: slideInRight 0.3s ease-out;
            opacity: 0;
            transform: translateX(400px);
        }

        .toast.show {
            opacity: 1;
            transform: translateX(0);
            transition: all 0.3s ease-out;
        }

        .toast-success {
            background: linear-gradient(135deg, rgba(34, 197, 94, 0.95) 0%, rgba(22, 163, 74, 0.95) 100%);
            color: white;
            border-left: 4px solid #22c55e;
        }

        .toast-error {
            background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(220, 38, 38, 0.95) 100%);
            color: white;
            border-left: 4px solid #ef4444;
        }

        .toast-info {
            background: linear-gradient(135deg, rgba(59, 130, 246, 0.95) 0%, rgba(37, 99, 235, 0.95) 100%);
            color: white;
            border-left: 4px solid #3b82f6;
        }

        .toast-warning {
            background: linear-gradient(135deg, rgba(245, 158, 11, 0.95) 0%, rgba(217, 119, 6, 0.95) 100%);
            color: white;
            border-left: 4px solid #f59e0b;
        }

        .toast-icon {
            font-weight: 700;
            font-size: 18px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 24px;
            height: 24px;
        }

        .toast-message {
            flex: 1;
            word-wrap: break-word;
            word-break: break-word;
            line-height: 1.4;
        }

        .toast-close {
            background: none;
            border: none;
            color: inherit;
            cursor: pointer;
            font-size: 20px;
            padding: 0;
            width: 24px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            opacity: 0.7;
            transition: opacity 0.2s;
        }

        .toast-close:hover {
            opacity: 1;
        }

        @keyframes slideInRight {
            from {
                opacity: 0;
                transform: translateX(400px);
            }

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

        @media (max-width: 768px) {
            .toast-container {
                top: 10px;
                right: 10px;
                left: 10px;
            }

            .toast {
                min-width: unset;
                width: 100%;
            }

            /* MOBILE CHAT OPTIMIZATION */
            .messages {
                padding: 0 0.75rem;
                gap: 1.5rem;
            }

            .message {
                flex-direction: column;
                gap: 8px;
                align-items: flex-start;
            }

            .message-avatar {
                width: 32px;
                height: 32px;
                border-radius: 10px;
            }

            .message-avatar svg {
                width: 16px;
                height: 16px;
            }

            .message-content {
                width: 100%;
                padding: 1rem !important;
                font-size: 0.95rem;
            }

            .message.ai .message-content {
                border-left: none;
                border-top: 3px solid var(--premium-accent);
            }

            .message-meta {
                flex-direction: column;
                align-items: flex-start;
                gap: 8px;
            }

            .message-actions {
                width: auto;
                flex-wrap: nowrap;
                justify-content: flex-start;
                gap: 8px;
            }

            .message-action-btn {
                padding: 6px 10px;
                font-size: 0.75rem;
            }

            /* Force tables to be wider and scrollable */
            .markdown-body td {
                min-width: 200px;
            }

            .markdown-body td:first-child {
                min-width: 130px;
            }
        }

        /* ========== FASE 2: Chat IA Improvements ========== */

        /* Loading & Sending States */
        .message-sending {
            opacity: 0.7;
            position: relative;
        }

        .typing-indicator {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 8px 12px;
        }

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

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

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

        @keyframes typing-bounce {

            0%,
            60%,
            100% {
                transform: translateY(0);
                opacity: 0.7;
            }

            30% {
                transform: translateY(-10px);
                opacity: 1;
            }
        }

        /* File Chips (Gemini Style - RenglÃ³n Superior) */
        .file-chips-wrapper {
            display: none;
        }

        .file-chips-wrapper.has-files {
            display: block;
            animation: slide-in-top 0.2s ease-out;
        }

        .file-chips-container {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            /* AlineaciÃ³n a la izquierda explÃ­cita para coincidir con botones */
            justify-content: flex-start;
        }

        .file-chip {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            background-color: #ffffff;
            /* Fondo blanco puro */
            border: 1px solid #c7d2fe;
            /* Borde azul suave mÃ¡s visible */
            color: #1e3a8a;
            padding: 8px 14px;
            border-radius: 12px;
            font-size: 0.85rem;
            font-weight: 500;
            /* Sombra mÃ¡s pronunciada para separarlo del fondo */
            box-shadow: 0 4px 6px rgba(13, 0, 158, 0.08), 0 1px 3px rgba(13, 0, 158, 0.05);
            max-width: 100%;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .file-chip:hover {
            border-color: #4263eb;
            /* Azul Anexit al hover */
            box-shadow: 0 6px 12px rgba(13, 0, 158, 0.12);
            transform: translateY(-2px);
        }

        .file-chip-icon {
            color: #ef4444;
            /* PDF Color */
            flex-shrink: 0;
            display: flex;
            align-items: center;
            filter: drop-shadow(0 2px 4px rgba(239, 68, 68, 0.2));
            /* Brillo sutil rojo */
        }

        .file-chip-name {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 200px;
        }

        .file-chip-remove {
            background: rgba(0, 0, 0, 0.05);
            border: none;
            color: #64748b;
            cursor: pointer;
            padding: 4px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            margin-left: 4px;
        }

        .file-chip-remove:hover {
            background-color: #ef4444;
            color: white;
        }

        @keyframes slide-in-top {
            from {
                transform: translateY(5px);
                opacity: 0;
            }

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

        /* Loading Skeleton */
        .skeleton-loader {
            background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
            background-size: 200% 100%;
            animation: skeleton-loading 1.5s infinite;
            border-radius: 4px;
        }

        .skeleton-text {
            height: 16px;
            margin: 8px 0;
            border-radius: 4px;
        }

        .skeleton-message {
            height: 60px;
            margin: 12px 0;
            border-radius: 8px;
        }

        @keyframes skeleton-loading {
            0% {
                background-position: 200% 0;
            }

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

        /* Error Banner */
        .error-banner {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background-color: #FEE2E2;
            border-left: 4px solid #EF4444;
            padding: 12px 16px;
            border-radius: 6px;
            margin: 12px 0;
            color: #B91C1C;
            animation: slide-in-top 0.3s ease-out;
        }

        .error-banner-content {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
        }

        .error-banner-icon {
            width: 20px;
            height: 20px;
            flex-shrink: 0;
        }

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

        .error-banner-retry {
            background-color: #EF4444;
            color: white;
            border: none;
            padding: 6px 12px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 600;
            transition: background-color 0.2s;
        }

        .error-banner-retry:hover {
            background-color: #DC2626;
        }

        .error-banner-close {
            background: none;
            border: none;
            color: #B91C1C;
            cursor: pointer;
            font-size: 18px;
            padding: 0 8px;
        }

        /* Success Banner */
        .success-banner {
            background-color: #DCFCE7;
            border-left: 4px solid #22C55E;
            padding: 12px 16px;
            border-radius: 6px;
            margin: 12px 0;
            color: #166534;
            animation: slide-in-top 0.3s ease-out;
        }

        /* Credit Warning */
        .credit-warning {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            background-color: #FEF3C7;
            border-left: 4px solid #F59E0B;
            border-radius: 4px;
            font-size: 13px;
            color: #92400E;
            margin: 8px 0;
        }

        /* Tablas y Cuadros Comparativos Premium */
        .markdown-body table {
            display: block;
            width: 100%;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            border-collapse: separate;
            border-spacing: 0;
            margin: 1.5rem 0;
            border: 1px solid var(--premium-border);
            border-radius: 12px;
            font-size: 0.9rem;
            box-shadow: var(--premium-shadow-subtle);
        }

        .markdown-body th {
            background-color: var(--premium-accent-light);
            color: var(--premium-primary);
            font-weight: 600;
            padding: 12px 16px;
            text-align: left;
            border-bottom: 2px solid var(--premium-border);
            white-space: nowrap;
        }

        .markdown-body td:first-child {
            font-weight: 600;
            color: var(--premium-primary);
            background-color: rgba(66, 99, 235, 0.01);
            min-width: 140px;
        }

        .markdown-body td {
            padding: 12px 16px;
            border-bottom: 1px solid var(--premium-border);
            vertical-align: top;
            color: var(--premium-text);
        }

        .markdown-body tr:last-child td {
            border-bottom: none;
        }

        .markdown-body tr:nth-child(even) {
            background-color: rgba(66, 99, 235, 0.02);
        }

        .markdown-body tr:hover {
            background-color: rgba(66, 99, 235, 0.04);
        }

        /* Responsive adjustments */
        .message.ai .message-content {
            overflow-x: visible;
        }

        /* LÃ­mite de 5 columnas: Si supera 5 cosas a comparar (6 columnas total), volver a texto/tabla normal */
        .markdown-body table:has(tr *:nth-child(6)) {
            display: table !important;
            overflow-x: visible !important;
            min-width: unset !important;
            border: none !important;
            box-shadow: none !important;
            border-radius: 0 !important;
        }

        .markdown-body table:has(tr *:nth-child(6)) th,
        .markdown-body table:has(tr *:nth-child(6)) td {
            min-width: unset !important;
            white-space: normal !important;
            background: none !important;
            border: none !important;
            padding: 4px 8px !important;
            font-weight: normal !important;
            color: inherit !important;
        }

        .chat-message-markdown code {
            background-color: #f3f4f6;
            padding: 2px 6px;
            border-radius: 3px;
            font-family: 'Courier New', monospace;
            font-size: 0.9em;
        }

        .chat-message-markdown pre {
            background-color: #1f2937;
            color: #f3f4f6;
            padding: 12px;
            border-radius: 6px;
            overflow-x: auto;
            margin: 8px 0;
        }

        .chat-message-markdown pre code {
            background-color: transparent;
            color: inherit;
            padding: 0;
        }

        /* Auto-scroll indicator */
        .auto-scroll-indicator {
            position: fixed;
            bottom: 80px;
            right: 20px;
            background-color: var(--premium-primary);
            color: white;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
            z-index: 100;
        }

        .auto-scroll-indicator.visible {
            opacity: 1;
            pointer-events: auto;
        }

        .auto-scroll-indicator:hover {
            background-color: var(--premium-primary-dark);
        }

        /* Cost indicator */
        .cost-indicator {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 12px;
            color: #6B7280;
            background-color: #F3F4F6;
            padding: 4px 8px;
            border-radius: 4px;
        }

        /* Mode selector styling */
        /* Mode selector styling */
        .mode-selector {
            display: flex;
            gap: 8px;
            margin-bottom: 12px;
            flex-wrap: wrap;
        }

        .mode-option {
            padding: 6px 12px;
            border: 2px solid #E5E7EB;
            background-color: white;
            border-radius: 20px;
            cursor: pointer;
            font-size: 13px;
            font-weight: 500;
            transition: all 0.2s;
        }

        .mode-option:hover {
            border-color: var(--premium-accent);
            background-color: var(--premium-accent-light);
        }

        .mode-option.active {
            background-color: var(--premium-accent);
            color: white;
            border-color: var(--premium-accent);
        }

        @keyframes slide-in-top {
            from {
                transform: translateY(-20px);
                opacity: 0;
            }

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

        /* Menu de opciones de copiado */
        .message-action-wrapper {
            position: relative;
            display: inline-block;
        }

        .copy-options-menu {
            position: absolute;
            bottom: calc(100% + 8px);
            left: 0;
            background: var(--premium-glass);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1.5px solid var(--premium-border);
            border-radius: 14px;
            box-shadow: 0 12px 36px rgba(13, 0, 158, 0.15);
            padding: 8px;
            display: none;
            flex-direction: column;
            gap: 4px;
            z-index: 1000;
            min-width: 220px;
            width: max-content;
            animation: menuFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            transform-origin: bottom left;
        }

        .copy-options-menu.active {
            display: flex;
        }

        .copy-option {
            padding: 8px 12px;
            font-size: 0.8rem;
            color: var(--premium-text);
            cursor: pointer;
            border-radius: 8px;
            transition: all 0.2s;
            white-space: nowrap;
        }

        .copy-option:hover {
            background: var(--premium-accent-light);
            color: var(--premium-primary);
        }

        .spinner-small {
            width: 12px;
            height: 12px;
            border: 2px solid rgba(0, 0, 0, 0.1);
            border-top-color: var(--premium-primary);
            border-radius: 50%;
            display: inline-block;
            animation: spin 1s linear infinite;
            margin-right: 5px;
            vertical-align: middle;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

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

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

        /* Modal Styles */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(5px);
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
        }

        .modal-overlay.active {
            opacity: 1;
            pointer-events: all;
        }

        .modal-card {
            background: white;
            width: 90%;
            max-width: 600px;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
            position: relative;
            transform: translateY(20px);
            transition: transform 0.3s;
            max-height: 90vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* Variantes pequeÃ±as para renombrar/eliminar */
        .modal-card.modal-small {
            max-width: 400px;
        }

        .modal-input {
            width: 100%;
            padding: 0.75rem 1rem;
            border: 1px solid var(--premium-border);
            border-radius: 12px;
            font-family: inherit;
            font-size: 0.95rem;
            color: var(--premium-text);
            background: #f8faff;
            outline: none;
            transition: border-color 0.2s;
        }

        .modal-input:focus {
            border-color: var(--premium-accent);
            background: white;
        }

        .modal-body.centered-text {
            text-align: center;
            padding: 2rem 1.5rem;
        }

        .btn-danger {
            background: #ff4d4d;
            color: white;
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 10px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }

        .btn-danger:hover {
            background: #e60000;
            transform: translateY(-2px);
        }

        .btn-secondary {
            background: #f3f4f6;
            color: #4b5563;
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 10px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            margin-right: 0.5rem;
        }

        .btn-secondary:hover {
            background: #e5e7eb;
        }

        .modal-overlay.active .modal-card {
            transform: translateY(0);
        }

        .modal-header {
            padding: 1.5rem;
            border-bottom: 1px solid var(--premium-border);
            background: linear-gradient(135deg, #f8faff 0%, #ffffff 100%);
            border-radius: 20px 20px 0 0;
        }

        .modal-header h2 {
            font-size: 1.25rem;
            color: var(--premium-primary);
            margin: 0;
        }

        .modal-body {
            padding: 2rem;
            overflow-y: auto;
            font-size: 0.95rem;
            line-height: 1.6;
            color: var(--premium-text);
        }

        .modal-body h3 {
            font-size: 1rem;
            color: var(--premium-primary);
            margin-top: 1.5rem;
            margin-bottom: 0.5rem;
        }

        .modal-body h3:first-child {
            margin-top: 0;
        }

        .modal-footer {
            padding: 1.5rem;
            border-top: 1px solid var(--premium-border);
            text-align: right;
        }

        .modal-close {
            position: absolute;
            top: 1rem;
            right: 1rem;
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: var(--premium-text-light);
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: background 0.2s;
        }

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

        .btn-primary {
            background: var(--premium-gradient-primary);
            color: white;
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 10px;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
        }






        /* ==========================================
   FILE CHIP - User Message Attachment
   Matches the style of the input file chip
========================================== */
        .message-file-attachment {
            margin-top: 0.5rem;
            margin-left: 0;
            padding-left: 0;
        }

        .message .file-chip {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.75rem;
            background: rgba(13, 0, 158, 0.05);
            border: 1px solid rgba(13, 0, 158, 0.12);
            border-radius: 8px;
            font-size: 0.85rem;
            color: var(--premium-primary);
            transition: all 0.2s ease;
            max-width: fit-content;
        }

        .message .file-chip-icon {
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .message .file-chip-icon svg {
            opacity: 0.7;
        }

        .message .file-chip-name {
            font-weight: 500;
            max-width: 250px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            line-height: 1.4;
        }

        .message .file-chip:hover {
            background: rgba(13, 0, 158, 0.08);
            border-color: rgba(13, 0, 158, 0.2);
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(13, 0, 158, 0.1);
        }

        /* ==========================================

/* ==========================================
   USER MESSAGE ACTIONS - FINAL STYLES FIX
========================================== */
.message.user .message-user-row {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    justify-content: flex-end !important;
    width: auto !important;
    margin-left: auto !important;
    position: relative !important;
}

.user-message-actions {
    display: flex !important;
    gap: 6px !important;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease !important;
    pointer-events: none !important;
    filter: none !important;
    mix-blend-mode: normal !important;
}

.message.user:hover .user-message-actions {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.user-action-btn {
    background: #f0f2ff !important;
    border: 1px solid #c9d1ff !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    padding: 0 !important;
    box-shadow: 0 2px 5px rgba(13, 0, 158, 0.1) !important;
    filter: none !important;
    transition: all 0.2s ease !important;
    outline: none !important;
}

.user-action-btn svg {
    width: 16px !important;
    height: 16px !important;
    fill: none !important;
    stroke: #0D009E !important;
    stroke-width: 2.2 !important;
    display: block !important;
    pointer-events: none !important;
    filter: none !important;
}

.user-action-btn:hover {
    background: #0D009E !important;
    border-color: #0D009E !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(13, 0, 158, 0.25) !important;
}

.user-action-btn:hover svg {
    stroke: #ffffff !important;
}

/* Edit Mode Styling */
.message-content.editing {
    background: #ffffff !important;
    color: #1a1a1a !important;
    border: 2px solid #0D009E !important;
    border-radius: 12px !important;
    padding: 16px !important;
    width: 100% !important;
}

.edit-textarea {
    width: 100%;
    min-height: 80px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    color: #333 !important;
    background: #fafafa !important;
    font-family: inherit;
    resize: none;
    outline: none;
}
