:root {
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-soft: #f8fafb;

    --text: #18202a;
    --text-soft: #687481;

    --border: #dde3e8;

    --primary: #173b35;
    --primary-hover: #0f2f2a;
    --primary-soft: #e9f2ef;

    --accent: #b29058;

    --danger: #b42318;
    --danger-bg: #fff0ee;

    --shadow:
        0 20px 60px rgba(22, 32, 42, 0.10);

    --radius: 16px;
}


* {
    box-sizing: border-box;
}


html,
body {
    margin: 0;
    min-height: 100%;
}


body {
    min-height: 100vh;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: var(--bg);
    color: var(--text);

    -webkit-font-smoothing: antialiased;
}


button,
input,
select,
textarea {
    font: inherit;
}


button {
    cursor: pointer;
}


.hidden {
    display: none !important;
}


/* ======================================================
   LOGIN
====================================================== */

.login-page {
    min-height: 100vh;

    display: grid;
    place-items: center;

    padding: 24px;

    background:
        radial-gradient(
            circle at top left,
            rgba(178, 144, 88, 0.15),
            transparent 32%
        ),
        linear-gradient(
            145deg,
            #102b27 0%,
            #173b35 45%,
            #0d201e 100%
        );
}


.login-card {
    width: min(100%, 440px);

    padding: 42px;

    border-radius: 24px;

    background: rgba(255, 255, 255, 0.98);

    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.28);
}


.brand-mark {
    width: 62px;
    height: 62px;

    display: grid;
    place-items: center;

    border-radius: 18px;

    background: var(--primary);

    color: white;

    font-weight: 800;
    font-size: 21px;

    letter-spacing: -1px;

    border:
        1px solid rgba(178, 144, 88, 0.7);

    box-shadow:
        inset 0 0 0 3px rgba(255, 255, 255, 0.06);

    margin-bottom: 28px;
}


.brand-mark.small {
    width: 42px;
    height: 42px;

    border-radius: 12px;

    font-size: 15px;

    margin: 0;
}


.login-heading {
    margin-bottom: 28px;
}


.eyebrow {
    margin: 0 0 7px;

    color: var(--accent);

    font-size: 11px;
    font-weight: 800;

    letter-spacing: 0.13em;
}


.login-heading h1 {
    margin:
        0 0 12px;

    font-size: 28px;
    line-height: 1.15;
}


.login-heading > p:last-child {
    margin: 0;

    color: var(--text-soft);

    line-height: 1.55;
}


#loginForm {
    display: grid;

    gap: 9px;
}


#loginForm label {
    margin-top: 8px;

    font-size: 13px;
    font-weight: 700;

    color: #3c4853;
}


#loginForm input {
    width: 100%;

    padding:
        13px 14px;

    border:
        1px solid var(--border);

    border-radius: 11px;

    outline: none;

    background: white;

    color: var(--text);

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


#loginForm input:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(23, 59, 53, 0.10);
}


.password-wrapper {
    position: relative;
}


.password-wrapper input {
    padding-right: 78px !important;
}


.password-toggle {
    position: absolute;

    right: 10px;
    top: 50%;

    transform: translateY(-50%);

    border: 0;

    background: transparent;

    color: var(--primary);

    font-size: 12px;
    font-weight: 700;
}


.primary-button {
    margin-top: 15px;

    width: 100%;

    min-height: 48px;

    border: 0;
    border-radius: 11px;

    background: var(--primary);
    color: white;

    font-weight: 750;

    transition:
        background 0.15s ease,
        transform 0.15s ease;
}


.primary-button:hover {
    background: var(--primary-hover);
}


.primary-button:active {
    transform: translateY(1px);
}


.primary-button:disabled {
    opacity: 0.65;
    cursor: wait;
}


.form-message {
    margin-top: 8px;

    padding: 11px 12px;

    border-radius: 10px;

    font-size: 13px;

    line-height: 1.45;
}


.error-message {
    background: var(--danger-bg);

    color: var(--danger);

    border:
        1px solid rgba(180, 35, 24, 0.15);
}


.login-footer {
    margin:
        28px 0 0;

    text-align: center;

    color: #87919a;

    font-size: 12px;
}


/* ======================================================
   APP
====================================================== */

.app-page {
    min-height: 100vh;
}


.topbar {
    height: 70px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding:
        0 28px;

    background: var(--surface);

    border-bottom:
        1px solid var(--border);
}


.topbar-brand {
    display: flex;
    align-items: center;

    gap: 12px;
}


.topbar-brand > div:last-child {
    display: grid;

    gap: 1px;
}


.topbar-brand strong {
    font-size: 15px;
}


.topbar-brand span {
    color: var(--text-soft);

    font-size: 12px;
}


.topbar-user {
    display: flex;
    align-items: center;

    gap: 18px;
}


.user-data {
    display: grid;

    text-align: right;
}


.user-data span {
    color: var(--text-soft);

    font-size: 10px;

    text-transform: uppercase;

    letter-spacing: 0.08em;
}


.user-data strong {
    max-width: 270px;

    overflow: hidden;
    text-overflow: ellipsis;

    font-size: 12px;
}


.logout-button {
    min-height: 37px;

    padding:
        0 15px;

    border:
        1px solid var(--border);

    border-radius: 9px;

    background: white;

    color: #45515d;

    font-weight: 700;

    font-size: 12px;
}


.logout-button:hover {
    background: #f7f8f9;
}


.app-layout {
    height:
        calc(100vh - 70px);

    display: grid;

    grid-template-columns:
        280px minmax(0, 1fr);
}


/* ======================================================
   SIDEBAR
====================================================== */

.sidebar {
    padding: 26px 20px;

    background: #eef2f3;

    border-right:
        1px solid var(--border);

    overflow-y: auto;
}


.sidebar-section {
    display: grid;

    gap: 8px;
}


.sidebar-section label {
    font-size: 11px;
    font-weight: 800;

    letter-spacing: 0.06em;

    color: #56616c;

    text-transform: uppercase;
}


.sidebar select {
    width: 100%;

    min-height: 43px;

    padding:
        0 11px;

    border:
        1px solid #d4dade;

    border-radius: 10px;

    outline: none;

    background: white;

    color: var(--text);
}


.sidebar-info {
    display: flex;

    gap: 10px;

    margin-top: 18px;

    padding: 13px;

    border-radius: 11px;

    background: var(--surface);
}


.sidebar-info > div {
    display: grid;

    gap: 2px;
}


.sidebar-info strong {
    font-size: 12px;
}


.sidebar-info span {
    color: var(--text-soft);

    font-size: 11px;

    line-height: 1.4;
}


.status-dot {
    flex: 0 0 auto;

    width: 9px;
    height: 9px;

    margin-top: 4px;

    border-radius: 999px;

    background: #2b9e63;

    box-shadow:
        0 0 0 4px rgba(43, 158, 99, 0.12);
}


.sidebar-tip {
    display: grid;

    gap: 8px;

    margin-top: 30px;
}


.sidebar-tip > strong {
    margin-bottom: 3px;

    color: #6c7781;

    font-size: 10px;

    text-transform: uppercase;

    letter-spacing: 0.08em;
}


.suggestion {
    width: 100%;

    padding:
        10px 11px;

    border:
        1px solid transparent;

    border-radius: 9px;

    background: transparent;

    color: #44505a;

    text-align: left;

    font-size: 12px;

    transition:
        background 0.15s ease,
        border-color 0.15s ease;
}


.suggestion:hover {
    background: white;

    border-color: #d8dee2;
}


/* ======================================================
   CHAT
====================================================== */

.chat-panel {
    min-width: 0;

    display: flex;
    flex-direction: column;

    background: var(--surface);
}


.chat-header {
    min-height: 82px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding:
        17px 30px;

    border-bottom:
        1px solid var(--border);
}


.chat-header h2 {
    margin: 0;

    font-size: 19px;
}


.rag-badge {
    padding:
        6px 9px;

    border-radius: 7px;

    background: var(--primary-soft);

    color: var(--primary);

    font-size: 10px;
    font-weight: 800;

    letter-spacing: 0.05em;
}


.chat-messages {
    flex: 1;

    overflow-y: auto;

    padding:
        28px max(30px, calc((100% - 900px) / 2));

    scroll-behavior: smooth;
}


.message {
    display: flex;

    gap: 12px;

    margin-bottom: 25px;
}


.user-message {
    flex-direction: row-reverse;
}


.avatar {
    flex:
        0 0 34px;

    width: 34px;
    height: 34px;

    display: grid;
    place-items: center;

    border-radius: 10px;

    background: var(--primary);

    color: white;

    font-size: 10px;
    font-weight: 800;
}


.user-message .avatar {
    background: #e8ecef;

    color: #39444d;
}


.message-body {
    max-width:
        min(760px, 85%);
}


.user-message .message-body {
    display: flex;

    justify-content: flex-end;
}


.message-content {
    padding:
        14px 16px;

    border:
        1px solid var(--border);

    border-radius:
        4px 15px 15px 15px;

    background: var(--surface-soft);

    line-height: 1.65;

    font-size: 14px;

    overflow-wrap: anywhere;
}


.user-message .message-content {
    background: var(--primary);

    border-color: var(--primary);

    color: white;

    border-radius:
        15px 4px 15px 15px;

    white-space: pre-wrap;
}


.source-ref {
    display: inline-block;

    margin:
        0 2px;

    padding:
        2px 5px;

    border-radius: 5px;

    background: var(--primary-soft);

    color: var(--primary);

    font-size: 10px;
    font-weight: 800;

    vertical-align: 1px;
}


/* ======================================================
   FONTES
====================================================== */

.sources {
    margin-top: 10px;
}


.sources-title {
    margin:
        0 0 7px;

    color: var(--text-soft);

    font-size: 10px;
    font-weight: 800;

    text-transform: uppercase;

    letter-spacing: 0.08em;
}


.source-card {
    margin-bottom: 7px;

    padding:
        10px 12px;

    border:
        1px solid var(--border);

    border-radius: 9px;

    background: white;
}


.source-card strong {
    display: block;

    margin-bottom: 3px;

    font-size: 11px;
}


.source-card span {
    display: block;

    color: var(--text-soft);

    font-size: 11px;

    line-height: 1.45;
}


/* ======================================================
   LOADING
====================================================== */

.loading-content {
    display: flex;
    align-items: center;

    gap: 8px;
}


.loading-dots {
    display: inline-flex;

    gap: 4px;
}


.loading-dots i {
    width: 6px;
    height: 6px;

    border-radius: 999px;

    background: #7b878f;

    animation:
        pulse 1s infinite ease-in-out;
}


.loading-dots i:nth-child(2) {
    animation-delay: 0.15s;
}


.loading-dots i:nth-child(3) {
    animation-delay: 0.3s;
}


@keyframes pulse {

    0%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }

    50% {
        opacity: 1;
        transform: translateY(-2px);
    }
}


/* ======================================================
   COMPOSER
====================================================== */

.composer-area {
    padding:
        15px max(30px, calc((100% - 900px) / 2)) 18px;

    border-top:
        1px solid var(--border);

    background: rgba(255, 255, 255, 0.98);
}


.composer {
    display: flex;
    align-items: flex-end;

    gap: 9px;

    padding:
        8px 8px 8px 14px;

    border:
        1px solid #d3dade;

    border-radius: 14px;

    background: white;

    box-shadow:
        0 4px 20px rgba(20, 30, 40, 0.05);
}


.composer:focus-within {
    border-color: #aebcb8;

    box-shadow:
        0 0 0 3px rgba(23, 59, 53, 0.07);
}


.composer textarea {
    flex: 1;

    min-height: 38px;
    max-height: 140px;

    padding:
        8px 0;

    resize: none;

    border: 0;

    outline: 0;

    color: var(--text);

    line-height: 1.4;
}


.send-button {
    flex:
        0 0 40px;

    width: 40px;
    height: 40px;

    display: grid;
    place-items: center;

    border: 0;

    border-radius: 10px;

    background: var(--primary);

    color: white;

    font-size: 17px;
}


.send-button:disabled {
    opacity: 0.45;

    cursor: not-allowed;
}


.composer-footer {
    display: flex;
    justify-content: space-between;

    gap: 10px;

    margin-top: 6px;

    padding:
        0 4px;

    color: #9099a1;

    font-size: 10px;
}


/* ======================================================
   MOBILE
====================================================== */

@media (
    max-width: 800px
) {

    .topbar {
        padding:
            0 15px;
    }


    .user-data {
        display: none;
    }


    .app-layout {
        grid-template-columns:
            1fr;
    }


    .sidebar {
        display: none;
    }


    .chat-header {
        padding:
            15px 18px;
    }


    .chat-messages {
        padding:
            20px 15px;
    }


    .composer-area {
        padding:
            12px 12px 14px;
    }


    .message-body {
        max-width: 90%;
    }


    .login-card {
        padding:
            30px 23px;
    }

}