@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ============================================
   AISLAMIENTO CONTRA ELEMENTOR / TEMAS
   ============================================ */
.mlc-layout-wrapper,
.mlc-layout-wrapper *,
.mlc-layout-wrapper *::before,
.mlc-layout-wrapper *::after {
    box-sizing: border-box !important;
    text-decoration: none;
}

.mlc-layout-wrapper {
    all: revert;
    display: flex !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 15px !important;
    line-height: 1.5 !important;
    color: #333 !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
    text-transform: none !important;
    text-indent: 0 !important;
    text-shadow: none !important;
    vertical-align: baseline !important;
}

/* Reset de elementos HTML dentro del plugin */
.mlc-layout-wrapper h1,
.mlc-layout-wrapper h2,
.mlc-layout-wrapper h3,
.mlc-layout-wrapper h4,
.mlc-layout-wrapper h5,
.mlc-layout-wrapper h6 {
    margin: 0 !important;
    padding: 0 !important;
    font-family: inherit !important;
    line-height: 1.3 !important;
    color: inherit !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    border: none !important;
    background: none !important;
}

.mlc-layout-wrapper p {
    margin: 0 0 1em 0 !important;
    padding: 0 !important;
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    color: inherit !important;
}

.mlc-layout-wrapper a {
    color: inherit !important;
    text-decoration: underline;
    font-family: inherit !important;
    font-size: inherit !important;
    background: none !important;
}

.mlc-layout-wrapper button {
    font-family: inherit !important;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    text-align: inherit;
}

.mlc-layout-wrapper input,
.mlc-layout-wrapper textarea,
.mlc-layout-wrapper select {
    font-family: inherit !important;
    font-size: inherit !important;
    color: inherit !important;
    line-height: inherit !important;
    letter-spacing: normal !important;
    border-radius: 0;
    -webkit-appearance: none;
    appearance: none;
}

.mlc-layout-wrapper ul,
.mlc-layout-wrapper ol {
    margin: 0 0 1em 0 !important;
    padding: 0 0 0 1.5em !important;
    font-family: inherit !important;
    font-size: inherit !important;
    color: inherit !important;
}

.mlc-layout-wrapper li {
    margin: 0 0 0.25em 0 !important;
    padding: 0 !important;
    font-family: inherit !important;
    line-height: inherit !important;
}

.mlc-layout-wrapper img {
    max-width: 100% !important;
    height: auto !important;
    border: none !important;
}

.mlc-layout-wrapper label {
    font-family: inherit !important;
    font-size: inherit !important;
    color: inherit !important;
    font-weight: normal !important;
}

.mlc-layout-wrapper span {
    font-family: inherit !important;
    color: inherit;
}

/* --- FIN AISLAMIENTO --- */

/* --- LAYOUT WRAPPER (Minimalist) --- */
.mlc-layout-wrapper {
    display: flex;
    flex-direction: row;
    height: 600px;
    max-height: 80vh;
    border: 1px solid #f0f0f0;
    /* Lighter border */
    border-radius: 8px;
    /* Slightly less rounded */
    overflow: hidden;
    background: #fff;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    /* Very subtle shadow */
}

/* --- SCROLLBAR --- */
.mlc-history-list::-webkit-scrollbar,
.mlc-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.mlc-history-list::-webkit-scrollbar-track,
.mlc-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.mlc-history-list::-webkit-scrollbar-thumb,
.mlc-chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.mlc-history-list::-webkit-scrollbar-thumb:hover,
.mlc-chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* --- SIDEBAR (Clean) --- */
.mlc-sidebar {
    width: 240px;
    background: #fcfcfc;
    /* Almost white */
    border-right: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
}

.mlc-sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mlc-sidebar-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #111;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mlc-close-sidebar-btn {
    background: none !important;
    border: none !important;
    font-size: 18px !important;
    cursor: pointer;
    display: none;
    color: #999 !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
}

.mlc-new-chat-btn {
    margin: 12px 16px !important;
    padding: 9px 16px !important;
    background: transparent !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 8px !important;
    cursor: pointer;
    text-align: center !important;
    font-weight: 500 !important;
    font-size: 13px !important;
    color: #334155 !important;
    transition: all 0.2s ease;
    text-decoration: none !important;
    box-shadow: none !important;
    letter-spacing: 0.01em !important;
}

.mlc-new-chat-btn:hover {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
}

.mlc-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px 10px 10px;
}

.mlc-history-item {
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.1s ease;
}

.mlc-history-item:hover {
    background: #f5f5f5;
}

.mlc-history-item.active {
    background: #f0f0f0;
    font-weight: 600;
}

.mlc-history-info {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.mlc-history-title {
    display: block;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mlc-history-date {
    display: block;
    font-size: 10px;
    color: #999;
    margin-top: 2px;
}

.mlc-history-actions {
    display: none;
    gap: 4px;
}

.mlc-history-item:hover .mlc-history-actions {
    display: flex;
}

.mlc-action-btn {
    background: none !important;
    border: none !important;
    font-size: 12px !important;
    cursor: pointer;
    opacity: 0.4;
    padding: 4px !important;
    box-shadow: none !important;
    text-decoration: none !important;
}

.mlc-action-btn:hover {
    opacity: 1;
    color: #000;
}

/* --- MAIN CHAT AREA (Minimalist) --- */
.mlc-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
}

/* HEADER */
.mlc-chat-header {
    height: 60px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: #fff;
}

.mlc-sidebar-toggle {
    display: none;
    background: none !important;
    border: none !important;
    font-size: 20px !important;
    cursor: pointer;
    margin-right: 16px !important;
    color: #333 !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.mlc-chat-title {
    display: none;
    font-weight: 600;
    font-size: 15px;
    color: #000;
    text-align: center;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.mlc-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.mlc-download-chat-btn {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    cursor: pointer;
    font-size: 14px !important;
    color: #64748b !important;
    padding: 6px !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none !important;
    text-decoration: none !important;
}

.mlc-download-chat-btn:hover {
    border-color: #cbd5e1 !important;
    color: #334155 !important;
    background: #f1f5f9 !important;
    transform: translateY(-1px);
}

.mlc-quota-display {
    font-size: 11px !important;
    font-weight: 500 !important;
    color: #64748b !important;
    background: #f8fafc !important;
    padding: 4px 10px !important;
    border-radius: 6px !important;
    border: 1px solid #e2e8f0 !important;
}

/* MESSAGES */
.mlc-chat-messages {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.mlc-message {
    max-width: 100%;
    margin-bottom: 0;
    line-height: 1.6;
    font-size: 15px;
    color: #333;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mlc-message-header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.mlc-role-label {
    font-weight: 600;
    font-size: 12px;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* User Message: Minimal, nice spacing */
.mlc-message.user {
    padding-bottom: 24px;
    border-bottom: 1px solid #f5f5f5;
}

.mlc-message.user .mlc-role-label {
    color: #666;
}

/* AI Message: Minimal, no bubble, just text block */
.mlc-message.assistant {
    padding: 24px;
    background: #fafafa;
    /* Extremely subtle gray box */
    border-radius: 8px;
}

.mlc-message.assistant .mlc-role-label {
    color: #000;
}

/* Markdown Styles */
.markdown-body strong {
    font-weight: 600;
    color: #000;
}

.markdown-body pre {
    background: #f4f4f4;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: 'Consolas', monospace;
    font-size: 13px;
    color: #333;
    border: 1px solid #eee;
}

.markdown-body code {
    background: #f4f4f4;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
    font-size: 90%;
}

.markdown-body a {
    color: #000;
    text-decoration: underline;
}

.markdown-body a:hover {
    text-decoration: none;
    opacity: 0.7;
}

/* INPUT AREA */
.mlc-input-area {
    padding: 24px 32px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mlc-attachments-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 10px;
}

.mlc-attachment-item {
    background: #f9f9f9;
    color: #333;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mlc-att-remove {
    cursor: pointer;
    color: #999;
}

.mlc-att-remove:hover {
    color: #d00;
}

.mlc-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #fff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 12px 16px !important;
    transition: box-shadow 0.2s, border-color 0.2s;
    box-shadow: none !important;
}

.mlc-input-wrapper:focus-within {
    border-color: #000 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

.mlc-input-wrapper textarea {
    flex: 1;
    border: none !important;
    outline: none !important;
    resize: none;
    max-height: 200px;
    font-family: inherit !important;
    font-size: 15px !important;
    line-height: 1.5 !important;
    padding: 0 !important;
    color: #333 !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.mlc-attach-btn {
    background: none !important;
    border: none !important;
    cursor: pointer;
    color: #999 !important;
    padding: 4px !important;
    transition: color 0.2s;
    box-shadow: none !important;
    text-decoration: none !important;
}

.mlc-attach-btn:hover {
    color: #000 !important;
    background: none !important;
}

.mlc-send-btn {
    background: #6366f1 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 50% !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3) !important;
    text-decoration: none !important;
    padding: 0 !important;
}

.mlc-send-btn:hover {
    background: #4f46e5 !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4) !important;
    transform: scale(1.05);
    color: #fff !important;
}

.mlc-send-btn svg {
    width: 16px !important;
    height: 16px !important;
    fill: currentColor !important;
}

.mlc-send-btn:disabled {
    background: #e2e8f0 !important;
    color: #94a3b8 !important;
    cursor: not-allowed;
    box-shadow: none !important;
    transform: none !important;
}

/* ERROR OVERLAY */
.mlc-quota-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    text-align: center;
}

.mlc-quota-exceeded-card {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid #eee;
    max-width: 300px;
}

.mlc-btn-request-tokens {
    display: inline-block !important;
    margin-top: 15px !important;
    padding: 10px 24px !important;
    background: #6366f1 !important;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3) !important;
    font-weight: 500 !important;
    transition: all 0.2s ease;
}

.mlc-btn-request-tokens:hover {
    background: #4f46e5 !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4) !important;
    color: #fff !important;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .mlc-sidebar {
        position: absolute;
        left: -100%;
        top: 0;
        bottom: 0;
        height: 100%;
        width: 280px;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease;
    }

    .mlc-sidebar.open {
        left: 0;
    }

    .mlc-sidebar-toggle {
        display: block;
    }

    .mlc-close-sidebar-btn {
        display: block;
    }

    .mlc-chat-messages {
        padding: 16px 20px;
    }

    .mlc-input-area {
        padding: 16px 20px;
    }
}

/* Spinner */
.mlc-spinner-small {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: #000;
    border-radius: 50%;
    animation: mlc-spin 0.8s linear infinite;
}

@keyframes mlc-spin {
    to {
        transform: rotate(360deg);
    }
}

.mlc-attachment-item.mlc-uploading {
    opacity: 0.6;
}