﻿/* ── Temas ── */
:root[data-theme="light"] {
    --bg-main: #f8f9fa;
    --bg-sidebar: #ffffff;
    --bg-chat: #ffffff;
    --bg-bubble-user: #0d6efd;
    --bg-bubble-bot: #e9ecef;
    --text-main: #212529;
    --text-sidebar: #495057;
    --text-bubble-user: #ffffff;
    --text-bubble-bot: #212529;
    --border-color: #dee2e6;
    --sidebar-width: 280px;
}

:root[data-theme="dark"] {
    --bg-main: #1a1d21;
    --bg-sidebar: #212529;
    --bg-chat: #2b2d31;
    --bg-bubble-user: #0d6efd;
    --bg-bubble-bot: #383a40;
    --text-main: #e9ecef;
    --text-sidebar: #adb5bd;
    --text-bubble-user: #ffffff;
    --text-bubble-bot: #e9ecef;
    --border-color: #373b3e;
    --sidebar-width: 280px;
}

/* ── Base ── */
html, body {
    height: 100%;
    margin: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.2s, color 0.2s;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
}

/* ── Layout ── */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-main);
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-sidebar);
    padding: 1rem 1rem 0.4rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--text-sidebar);
    cursor: pointer;
    border-radius: 6px;
    margin: 0 0.5rem;
    transition: background-color 0.15s;
    border: none;
    background: none;
    width: calc(100% - 1rem);
    text-align: left;
}

    .sidebar-item:hover {
        background-color: var(--border-color);
        color: var(--text-main);
    }

    .sidebar-item.active {
        background-color: #0d6efd20;
        color: #0d6efd;
    }

/* ── KPI Cards ── */
.kpi-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    margin: 0.25rem 0.5rem;
}

    .kpi-card .kpi-value {
        font-size: 1.1rem;
        font-weight: 700;
        color: #0d6efd;
    }

    .kpi-card .kpi-label {
        font-size: 0.7rem;
        color: var(--text-sidebar);
    }

    .kpi-card .kpi-icon {
        min-width: 2.5rem;
        text-align: center;
    }

/* ── Área principal ── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-chat);
}

/* ── Chat ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-bubble {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}

    .chat-bubble.user {
        align-self: flex-end;
        background-color: var(--bg-bubble-user);
        color: var(--text-bubble-user);
        border-bottom-right-radius: 3px;
    }

    .chat-bubble.bot {
        align-self: flex-start;
        background-color: var(--bg-bubble-bot);
        color: var(--text-bubble-bot);
        border-bottom-left-radius: 3px;
        max-width: 90%;
    }

/* ── Input ── */
.chat-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
}

    .chat-input-area .input-group {
        border-radius: 12px;
        overflow: hidden;
    }

.chat-timestamp {
    font-size: 0.65rem;
    opacity: 0.5;
    text-align: right;
    margin-top: 4px;
}

.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1040;
}

.modal-maximize {
    position: fixed;
    top: 3%;
    left: 3%;
    width: 94%;
    height: 94%;
    background: var(--bg-chat);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-maximize-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-sidebar);
}

.modal-maximize-body {
    flex: 1;
    overflow: auto;
    padding: 1.25rem;
}

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 320px;
    pointer-events: all;
}

.toast-item {
    pointer-events: all;
    position: relative;
    z-index: 9999;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast-header {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.toast-body {
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-sidebar);
}

.toast-success .toast-header {
    color: #198754;
}

.toast-error .toast-header {
    color: #dc3545;
}

.toast-running .toast-header {
    color: #0d6efd;
}

.toast-pending .toast-header {
    color: var(--text-sidebar);
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: var(--bg-main);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-header {
    text-align: center;
    padding: 2rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.login-body {
    padding: 1.5rem;
}

.skeleton {
    background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-main) 50%, var(--border-color) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.2s infinite;
    border-radius: 6px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 0.8rem;
    margin-bottom: 0.4rem;
}

.skeleton-value {
    height: 1.2rem;
    width: 70%;
}

.global-error-banner {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: #dc3545;
    color: white;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    max-width: 90%;
}

/* ── Responsive ── */
@media (max-width: 768px) {

    .chat-bubble {
        max-width: 95%;
    }

    .chat-input-area {
        padding: 0.75rem 1rem;
    }

    .modal-maximize {
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100%;
        width: 100% !important;
        transition: left 0.3s;
        z-index: 200;
    }

        .sidebar.open {
            left: 0;
        }
}
