/* ================================
   XYRO — MAIN STYLE
================================ */

:root {
    --bg: #0b0b0b;
    --panel: #111111;
    --panel-2: #161616;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f2f2f2;
    --muted: #8f8f8f;
    --accent: #5ac8fa;
    --user-bg: #1b1b1b;
}

/* ================================
   RESET
================================ */

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;
    overflow: hidden;
}

/* ================================
   APP
================================ */

.app {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* ================================
   HEADER
================================ */

.header {
    height: 64px;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 11, 11, 0.96);
    z-index: 20;
}

.header h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.header p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 11px;
}

/* ================================
   LOGO
================================ */

.xyro-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 1px solid rgba(90, 200, 250, 0.35);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 18px;
    font-weight: 600;
}

/* ================================
   MENU BUTTON
================================ */

.menu-button {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 21px;
    cursor: pointer;
}

.menu-button:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

/* ================================
   SIDEBAR
================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 290px;
    max-width: 85%;
    padding: 18px;
    background: #101010;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
    overflow-y: auto;
}

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

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 18px;
}

.sidebar-header button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
}

.sidebar-header button:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

/* ================================
   NEW CHAT
================================ */

.new-chat {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.new-chat:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ================================
   CHAT HISTORY
================================ */

.history-title {
    margin: 24px 4px 10px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

#chatHistory {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.history-item {
    width: 100%;
    padding: 11px 12px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.history-item.active {
    background: rgba(90, 200, 250, 0.10);
    color: var(--accent);
}

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

#chat {
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 18px 120px;
    scroll-behavior: smooth;
}

/* ================================
   MESSAGE
================================ */

.message {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 22px;
    display: flex;
}

/* ================================
   ASSISTANT MESSAGE
================================ */

.message.assistant {
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    flex-direction: column;
    align-items: flex-start;
}

.message.assistant .bubble {
    width: 100%;
    max-width: 100%;
    padding: 8px 0;
    background: transparent;
    border: none;
    border-radius: 0;
    color: var(--text);
    line-height: 1.65;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* ================================
   USER MESSAGE
================================ */

.message.user {
    width: 100%;
    justify-content: flex-end;
    user-select: none;
    -webkit-user-select: none;
}

.message.user .bubble {
    max-width: min(78%, 620px);
    padding: 11px 15px;
    border-radius: 17px;
    background: var(--user-bg);
    border: 1px solid var(--border);
    color: var(--text);
    line-height: 1.5;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* ================================
   GENERAL BUBBLE
================================ */

.bubble {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* ================================
   ASSISTANT TEXT
================================ */

.message.assistant strong {
    color: #ffffff;
    font-weight: 650;
}

/* ================================
   THINKING
================================ */

.thinking-message {
    margin-bottom: 10px;
}

.thinking-message .bubble {
    width: auto !important;
    padding: 7px 10px !important;
    color: var(--muted);
    font-size: 16px;
    letter-spacing: 3px;
}

/* ================================
   MESSAGE ACTIONS
================================ */

.message-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    margin-top: 4px;
    opacity: 0.75;
    width: 100%;
}

.message-action {
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.15s ease;
}

.message-action:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--accent);
}

.message-action:active {
    transform: scale(0.90);
}

/* ================================
   EDIT MESSAGE
================================ */

.edit-message {
    margin-top: 6px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.edit-message:hover {
    background: rgba(90, 200, 250, 0.12);
    color: var(--accent);
}

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

#chatForm {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: flex-end;
    gap: 9px;
    padding: 12px 16px 16px;
    background:
        linear-gradient(
            to top,
            var(--bg) 65%,
            transparent
        );
    z-index: 10;
}

#messageInput {
    flex: 1;
    min-width: 0;
    max-height: 150px;
    resize: none;
    overflow-y: auto;
    padding: 16px;
    line-height: 24px;
    border: 1px solid var(--border);
    border-radius: 15px;
    outline: none;
    background: #151515;
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
}

#messageInput::placeholder {
    color: #6f6f6f;
}

#messageInput:focus {
    border-color: rgba(90, 200, 250, 0.45);
}

#chatForm button[type="submit"] {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border: none;
    border-radius: 14px;
    background: var(--accent);
    color: #000000;
    font-size: 19px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatForm button[type="submit"]:active {
    transform: scale(0.94);
}

/* ================================
   FEEDBACK TOAST
================================ */

.feedback-toast {
    position: fixed;
    left: 50%;
    bottom: 85px;
    transform: translate(-50%, 15px);
    padding: 11px 18px;
    border-radius: 10px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: #ffffff;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
}

.feedback-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ================================
   FEEDBACK MODAL
================================ */

.feedback-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.70);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9998;
}

.feedback-box {
    width: 100%;
    max-width: 430px;
    padding: 22px;
    border-radius: 18px;
    background: #151515;
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.feedback-box h3 {
    margin: 0 0 7px;
    color: #ffffff;
    font-size: 20px;
}

.feedback-box p {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.feedback-box textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    box-sizing: border-box;
    padding: 13px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
}

.feedback-box textarea:focus {
    border-color: var(--accent);
}

.feedback-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

.feedback-buttons button {
    padding: 10px 17px;
    border-radius: 9px;
    border: none;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
}

.feedback-buttons button:first-child {
    background: rgba(255, 255, 255, 0.07);
    color: var(--muted);
}

.feedback-buttons button:last-child {
    background: var(--accent);
    color: #000000;
}

/* ================================
   SCROLLBAR
================================ */

#chat::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 5px;
}

#chat::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#chat::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}

/* ================================
   MOBILE
================================ */

@media (max-width: 600px) {

    .header {
        height: 60px;
        min-height: 60px;
        padding: 0 12px;
    }

    .jarvis-logo {
        width: 34px;
        height: 34px;
    }

    #chat {
        padding:
            20px
            14px
            110px;
    }

    .message.user .bubble {
        max-width: 82%;
    }

    .message.assistant .bubble {
        width: 100%;
        max-width: 100%;
    }

    #chatForm {
        padding:
            9px
            10px
            12px;
    }

    #messageInput {
        padding: 13px;
        font-size: 15px;
    }

    #chatForm button[type="submit"] {
        width: 45px;
        height: 45px;
    }

    .feedback-modal {
        padding: 14px;
    }

    .feedback-box {
        padding: 18px;
    }
}