/* === LUCABE ENERGY - Assistente Comercial === */

:root {
    --lucabe-gray: #34383C;
    --lucabe-gray-medium: #4B5157;
    --lucabe-gray-light: #66696B;
    --lucabe-green: #82A56C;
    --lucabe-green-vibrant: #00A76A;
    --lucabe-green-light: #8DC63F;
    --lucabe-blue: #00A0DE;
    --lucabe-blue-dark: #0097B2;
    --lucabe-blue-light: #61BCF8;
    --lucabe-bg: #EBEBEB;
    --lucabe-bg-alt: #E9E9E9;

    --white: #FFFFFF;
    --shadow: rgba(52, 56, 60, 0.1);
    --shadow-md: rgba(52, 56, 60, 0.15);

    --sidebar-width: 280px;
    --header-height: 56px;
    --input-area-padding: 16px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
    color: var(--lucabe-gray);
    background: var(--lucabe-bg);
    height: 100dvh;
    overflow: hidden;
}

.screen {
    width: 100%;
    height: 100dvh;
}

/* === LOGIN === */

#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--lucabe-bg) 0%, var(--white) 100%);
}

.login-container {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px var(--shadow-md);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    margin-bottom: 16px;
}

.login-logo h1 {
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 1px;
    color: var(--lucabe-gray);
}

.login-subtitle {
    font-size: 14px;
    color: var(--lucabe-gray-light);
    margin-top: 4px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--lucabe-gray-medium);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--lucabe-gray-light);
    border-radius: var(--radius-sm);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    color: var(--lucabe-gray);
    background: var(--white);
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border: 2px solid var(--lucabe-blue);
    padding: 11px 15px;
}

.form-group input::placeholder {
    color: #999;
}

.btn-primary {
    width: 100%;
    padding: 12px 24px;
    background: var(--lucabe-blue);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
}

.btn-primary:hover {
    background: var(--lucabe-blue-dark);
}

.btn-primary:disabled {
    background: var(--lucabe-gray-light);
    cursor: not-allowed;
}

.error-text {
    color: #d32f2f;
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
}

/* Dot pulse loading */
.dot-pulse {
    display: inline-flex;
    gap: 4px;
}

.dot-pulse::before,
.dot-pulse::after,
.dot-pulse span {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--white);
    animation: dotPulse 1.2s infinite ease-in-out;
}

.dot-pulse::after {
    animation-delay: 0.4s;
}

/* reuse ::before for middle dot */
.dot-pulse::before {
    animation-delay: 0.2s;
}

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* === CHAT SCREEN LAYOUT === */

#chat-screen {
    display: flex;
    background: var(--white);
}

/* === SIDEBAR === */

.sidebar {
    width: var(--sidebar-width);
    background: var(--lucabe-gray);
    color: var(--white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100dvh;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--lucabe-gray-medium);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.btn-new-chat {
    background: var(--lucabe-blue);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-new-chat:hover {
    background: var(--lucabe-blue-dark);
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2px;
}

.session-item:hover {
    background: var(--lucabe-gray-medium);
}

.session-item.active {
    background: var(--lucabe-gray-medium);
    color: var(--white);
}

.session-item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
}

.session-item-delete {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.session-item:hover .session-item-delete {
    opacity: 1;
}

.session-item-delete:hover {
    color: #ff6b6b;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--lucabe-gray-medium);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    width: 100%;
    transition: color 0.15s, background 0.15s;
}

.btn-logout:hover {
    color: var(--white);
    background: var(--lucabe-gray-medium);
}

/* Sidebar scrollbar */
.session-list::-webkit-scrollbar {
    width: 4px;
}

.session-list::-webkit-scrollbar-thumb {
    background: var(--lucabe-gray-medium);
    border-radius: 2px;
}

/* === CHAT AREA === */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-width: 0;
}

.chat-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--lucabe-bg);
    flex-shrink: 0;
}

.chat-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--lucabe-gray);
}

.btn-menu {
    display: none;
    background: none;
    border: none;
    color: var(--lucabe-gray);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.btn-menu:hover {
    background: var(--lucabe-bg);
}

/* === MESSAGES === */

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

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    flex: 1;
}

.welcome-icon {
    margin-bottom: 16px;
}

.welcome-message h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--lucabe-gray);
}

.welcome-message p {
    font-size: 14px;
    color: var(--lucabe-gray-light);
    max-width: 380px;
}

/* Message bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: fadeIn 0.2s ease;
}

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

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--lucabe-blue);
    color: var(--white);
    border-bottom-right-radius: 6px;
}

.message.assistant .message-bubble {
    background: var(--lucabe-bg);
    color: var(--lucabe-gray);
    border-bottom-left-radius: 6px;
}

/* Markdown inside assistant bubbles */
.message.assistant .message-bubble h1,
.message.assistant .message-bubble h2,
.message.assistant .message-bubble h3,
.message.assistant .message-bubble h4 {
    font-weight: 600;
    margin: 12px 0 6px 0;
}

.message.assistant .message-bubble h1:first-child,
.message.assistant .message-bubble h2:first-child,
.message.assistant .message-bubble h3:first-child {
    margin-top: 0;
}

.message.assistant .message-bubble h1 { font-size: 18px; }
.message.assistant .message-bubble h2 { font-size: 16px; }
.message.assistant .message-bubble h3 { font-size: 15px; }

.message.assistant .message-bubble p {
    margin: 6px 0;
}

.message.assistant .message-bubble p:first-child {
    margin-top: 0;
}

.message.assistant .message-bubble p:last-child {
    margin-bottom: 0;
}

.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.message.assistant .message-bubble li {
    margin: 3px 0;
}

.message.assistant .message-bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.message.assistant .message-bubble pre {
    background: var(--lucabe-gray);
    color: #e0e0e0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}

.message.assistant .message-bubble pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 13px;
}

.message.assistant .message-bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 13px;
}

.message.assistant .message-bubble th,
.message.assistant .message-bubble td {
    border: 1px solid #ccc;
    padding: 8px 10px;
    text-align: left;
}

.message.assistant .message-bubble th {
    background: var(--lucabe-bg-alt);
    font-weight: 600;
}

.message.assistant .message-bubble blockquote {
    border-left: 3px solid var(--lucabe-blue);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--lucabe-gray-medium);
}

.message.assistant .message-bubble a {
    color: var(--lucabe-blue);
    text-decoration: none;
}

.message.assistant .message-bubble a:hover {
    text-decoration: underline;
}

.message.assistant .message-bubble strong {
    font-weight: 600;
}

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--lucabe-bg);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 6px;
    align-self: flex-start;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--lucabe-gray-light);
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}

/* === INPUT AREA === */

.input-area {
    padding: var(--input-area-padding);
    border-top: 1px solid var(--lucabe-bg);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--lucabe-bg);
    border-radius: var(--radius-md);
    padding: 8px 12px;
}

#message-input {
    flex: 1;
    border: none;
    background: none;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    color: var(--lucabe-gray);
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    padding: 4px 0;
}

#message-input:focus {
    outline: none;
}

#message-input::placeholder {
    color: #999;
}

#message-input:disabled::placeholder {
    color: #bbb;
}

.btn-send {
    background: var(--lucabe-blue);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.btn-send:hover:not(:disabled) {
    background: var(--lucabe-blue-dark);
}

.btn-send:disabled {
    background: var(--lucabe-gray-light);
    cursor: not-allowed;
}

/* Messages scrollbar */
.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* === SIDEBAR OVERLAY (mobile) === */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9;
}

/* === RESPONSIVE === */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 10;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

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

    .btn-menu {
        display: flex;
    }

    .message {
        max-width: 90%;
    }

    .login-container {
        margin: 16px;
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
    }

    .messages {
        padding: 16px 12px;
    }

    .input-area {
        padding: 12px;
    }
}
