/* =========================================================
    RESET
========================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #212121;
    --sidebar: #171717;
    --sidebar-hover: #2a2a2a;
    --surface: #2f2f2f;
    --surface-light: #383838;
    --border: #3f3f3f;
    --text: #ececec;
    --text-muted: #a0a0a0;
    --accent: #7c5cff;
    --accent-hover: #8d72ff;
    --input-bg: #2f2f2f;
    --sidebar-width: 260px;
}


/* =========================================================
    BODY
========================================================= */

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
}


/* =========================================================
    APP
========================================================= */

.app {
    width: 100%;
    height: 100vh;
    display: flex;
    overflow: hidden;
}


/* =========================================================
    SIDEBAR
========================================================= */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 10px;
    border-right: 1px solid #242424;
    flex-shrink: 0;
}


/* Logo */

.sidebar-logo {
    height: 46px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.sidebar-logo span {
    color: var(--accent);
    margin-left: 5px;
}
/* New chat */

.new-chat {
    width: 100%;
    height: 44px;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    padding: 0 13px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.new-chat:hover {
    background: var(--sidebar-hover);
}

.new-chat-icon {
    font-size: 20px;
    margin-right: 10px;
}

/* Sidebar sections */

.sidebar-section {
    margin-top: 20px;
}

.sidebar-title {
    padding: 0 10px 8px;
    font-size: 11px;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Chat history */

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.history-item {
    width: 100%;
    padding: 9px 11px;
    border-radius: 7px;
    color: #cfcfcf;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: background 0.15s;
}

.history-item:hover {
    background: var(--sidebar-hover);
}

.history-item.active {
    background: #2b2b2b;
}

/* Model area */

.model-section {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #292929;
}

.model-label {
    display: block;
    padding: 0 10px 7px;
    font-size: 11px;
    color: #777;
    text-transform: uppercase;
}

/* Model selector */

.model-select {
    width: 100%;
    background: #242424;
    border: 1px solid #383838;
    color: #ddd;
    padding: 10px 11px;
    border-radius: 7px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.model-select:hover {
    background: #2b2b2b;
}

.model-select:focus {
    border-color: #555;
}

/* =========================================================
    MAIN
========================================================= */

.main {
    flex: 1;
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg);
}


/* =========================================================
    TOP BAR
========================================================= */

.topbar {
    height: 58px;
    display: flex;
    align-items: center;
    padding: 0 22px;
    border-bottom: 1px solid #2c2c2c;
    flex-shrink: 0;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
}

.topbar-subtitle {
    margin-left: 9px;
    color: #858585;
    font-size: 12px;
}

/* =========================================================
    CHAT AREA
========================================================= */

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 30px 20px 150px;
    scroll-behavior: smooth;
}

/* Scrollbar */

.chat-area::-webkit-scrollbar,
.chat-history::-webkit-scrollbar {
    width: 7px;
}

.chat-area::-webkit-scrollbar-thumb,
.chat-history::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 10px;
}

.chat-area::-webkit-scrollbar-track,
.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

/* Chat content width */

.chat-content {
    width: 100%;
    max-width: 850px;

    margin: 0 auto;
}

/* =========================================================
    MESSAGES
========================================================= */

.message {
    width: 100%;
    display: flex;
    gap: 14px;
    margin-bottom: 28px;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User */

.message.user {
    justify-content: flex-end;
}

/* Assistant */

.message.assistant {
    justify-content: flex-start;
}

/* Avatar */

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #343434;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.assistant .avatar {
    background: var(--accent);
    color: white;
}


/* Message bubble */

.message-bubble {
    max-width: 75%;
    padding: 2px 0;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
    word-wrap: break-word;
}

.user .message-bubble {
    background: #303030;
    padding: 10px 14px;
    border-radius: 16px;
    color: #eee;
}

/* =========================================================
    SEARCH RESULTS
========================================================= */

.result-card {
    background: #292929;
    border: 1px solid #3a3a3a;
    padding: 14px;
    margin: 10px 0;
    border-radius: 9px;
    font-size: 13px;
    transition:
        background 0.15s,
        border-color 0.15s;
}

.result-card:hover {
    background: #303030;
    border-color: #4a4a4a;
}

.result-card .score {
    display: inline-block;
    background: #5140a8;
    color: white;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 7px;
}

.result-card .topic {
    display: inline-block;
    background: #3a3a3a;
    color: #aaa;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
}

.result-card .text {
    margin-top: 9px;
    color: #c5c5c5;
    line-height: 1.55;
    font-size: 12px;
}

.result-card .similarity {
    margin-top: 7px;
    font-size: 10px;
    color: #777;
}

/* =========================================================
    INFO BOX
========================================================= */

.info-box {
    background: #292929;
    border: 1px solid #3b3b3b;
    padding: 13px 15px;
    margin-bottom: 22px;
    border-radius: 8px;
    font-size: 13px;
    color: #aaa;
}

/* =========================================================
    NO RESULTS
========================================================= */

.no-results {
    text-align: center;
    color: #777;
    padding: 20px;
    font-style: italic;
}

/* =========================================================
    INPUT AREA
========================================================= */

.input-container {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 20px 22px;
    background:
        linear-gradient(
            to top,
            var(--bg) 65%,
            rgba(33, 33, 33, 0)
        );
}

.input-inner {
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
}

/* Actual input box */

.input-area {
    width: 100%;
    min-height: 56px;
    display: none;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
}

.real-input-area {
    width: 100%;
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    padding: 8px 9px 8px 15px;
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.25);
}

.input-area:focus-within {
    border-color: #555;
}

/* Text input */

.input-wrapper {
    flex: 1;
    display: flex;
    min-width: 0;
}

input[type="text"] {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #eee;
    font-size: 14px;
    padding: 8px 0;
}

input[type="text"]::placeholder {
    color: #858585;
}

/* Search button */

#searchBtn {
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: #555;
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        background 0.15s,
        transform 0.1s;
}

#searchBtn:hover {
    background: #666;
    transform: none;
    box-shadow: none;
}

#searchBtn:active {
    transform: scale(0.94);
}

#searchBtn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* =========================================================
    FILE INPUT
========================================================= */

.file-input-wrapper {
    display: none;
}

.file-status {
    margin-top: 7px;
    padding-left: 5px;
    font-size: 10px;
    color: #666;
}

/* =========================================================
    LOADING
========================================================= */

.loading {
    text-align: center;
    color: #777;
    font-style: italic;
    font-size: 12px;
    padding: 15px;
}

/* =========================================================
    MOBILE
========================================================= */

@media (max-width: 700px) {

    :root {
        --sidebar-width: 220px;
    }

    .sidebar {
        width: 220px;
    }

    .message-bubble {
        max-width: 85%;
    }

    .chat-area {
        padding-left: 14px;
        padding-right: 14px;
    }

    .input-container {
        padding-left: 12px;
        padding-right: 12px;
    }
}


@media (max-width: 550px) {

    .sidebar {
        display: none;
    }

    .topbar {
        padding: 0 15px;
    }

    .chat-area {
        padding-top: 20px;
    }

    .message-bubble {
        max-width: 90%;
    }
}

.hide {
    background: transparent;
    border: none;
    border-color: transparent;
}

/* =========================================================
LOGIN MODAL
========================================================= */

.login-panel {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: 9999;
}

/* Show login modal */

.login-panel.show {
    display: flex;
}

/* =========================================================
LOGIN BOX
========================================================= */

.login-box {
    width: 100%;
    max-width: 390px;
    background: #202020;
    border: 1px solid #3a3a3a;
    border-radius: 14px;
    padding: 30px;
    box-shadow:
        0 25px 70px rgba(0, 0, 0, 0.55);
    animation: loginAppear 0.18s ease-out;
}

/* Animation */

@keyframes loginAppear {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* =========================================================
TITLE
========================================================= */

.login-box h2 {
    color: #f2f2f2;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 7px;
}

.login-box::before {
    content: "WolfAI";
    display: block;
    text-align: center;
    color: #8d72ff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 18px;
}

/* =========================================================
INPUTS
========================================================= */

.login-box input {
    width: 100%;
    height: 46px;
    padding: 0 13px;
    margin-top: 10px;
    background: #2b2b2b;
    border: 1px solid #414141;
    border-radius: 8px;
    outline: none;
    color: #eee;
    font-size: 14px;
    transition:
        border-color 0.15s,
        background 0.15s;
}

.login-box input::placeholder {
    color: #858585;
}

.login-box input:focus {
    background: #303030;
    border-color: #666;
}

/* =========================================================
LOGIN BUTTON
========================================================= */

#loginBtn {
    width: 100%;
    height: 45px;
    margin-top: 18px;
    border: none;
    border-radius: 8px;
    background: #7c5cff;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background 0.15s,
        transform 0.1s;
}

#loginBtn:hover {
    background: #8d72ff;
    transform: none;
    box-shadow: none;
}

#loginBtn:active {
    transform: scale(0.98);
}

/* =========================================================
STATUS
========================================================= */

#loginStatus {
    min-height: 18px;
    margin-top: 12px;
    text-align: center;
    font-size: 12px;
    color: #888;
}

/* =========================================================
CLOSE BUTTON
========================================================= */

.login-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #999;
    font-size: 22px;
    cursor: pointer;
}

.login-close:hover {
    background: #333;
    color: #eee;
    box-shadow: none;
    transform: none;
}