/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #07090f;
    --surface: #0e1120;
    --surface2: #151a2e;
    --border: rgba(255, 255, 255, .07);
    --accent: #f5c842;
    --accent2: #ff8c42;
    --blue: #4d7cff;
    --purple: #9a5cff;
    --text: #e8eaf0;
    --muted: #687092;
    --green: #22d87a;
    --user-bg: linear-gradient(135deg, #4d7cff 0%, #9a5cff 100%);
    --bot-bg: #151a2e;
    --radius: 16px;
    --sidebar-w: 270px;
}

html,
body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    overflow: hidden;
}

/* ===== LAYOUT ===== */
.chat-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    gap: 16px;
    transition: transform .3s ease;
    z-index: 100;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.swx-icon {
    font-size: 26px;
    line-height: 1;
    filter: drop-shadow(0 0 8px rgba(245, 200, 66, .5));
}

.brand h2 {
    font-family: 'Space Mono', monospace;
    font-size: 17px;
    letter-spacing: .5px;
    color: var(--accent);
}

.status-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
    animation: pulse 2s infinite;
}

.dot.green {
    background: var(--green);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .5;
        transform: scale(1.3);
    }
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #f5c842, #ff8c42);
    color: #07090f;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity .2s, transform .15s;
}

.new-chat-btn:hover {
    opacity: .9;
    transform: translateY(-1px);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    padding: 0 4px;
}

.history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history::-webkit-scrollbar {
    width: 3px;
}

.history::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.history-item {
    padding: 11px 14px;
    background: var(--surface2);
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid transparent;
    transition: border-color .2s, background .2s;
}

.history-item:hover {
    border-color: var(--border);
    background: #1c2340;
}

.history-item.active {
    border-color: rgba(245, 200, 66, .3);
    background: rgba(245, 200, 66, .06);
}

.history-empty {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 20px 0;
}

.sidebar-footer {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.footer-btn {
    flex: 1;
    padding: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    transition: color .2s, border-color .2s;
}

.footer-btn:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, .18);
}

/* ===== MAIN CHAT ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}

/* HEADER */
.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}

.header-avatar {
    width: 40px;
    height: 40px;
    background: rgba(245, 200, 66, .12);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid rgba(245, 200, 66, .2);
}

.header-info h3 {
    font-size: 15px;
    font-weight: 600;
}

.online-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--green);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.hdr-btn {
    width: 36px;
    height: 36px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s, border-color .2s;
}

.hdr-btn:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, .18);
}

/* SEARCH BAR */
.search-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}

.search-bar.visible {
    display: flex;
}

.search-bar i {
    color: var(--muted);
    font-size: 13px;
}

.search-bar input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
}

.search-bar input::placeholder {
    color: var(--muted);
}

.search-bar button {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
}

.search-bar button:hover {
    color: var(--text);
}

/* MESSAGES */
.messages {
    flex: 1;
    padding: 28px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
    width: 4px;
}

.messages::-webkit-scrollbar-thumb {
    background: var(--surface2);
    border-radius: 2px;
}

/* Message bubbles */
.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: fadeUp .3s ease forwards;
    opacity: 0;
}

.msg-row.user {
    flex-direction: row-reverse;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background: rgba(245, 200, 66, .1);
    border: 1px solid rgba(245, 200, 66, .15);
}

.msg-row.user .msg-avatar {
    background: rgba(77, 124, 255, .15);
    border-color: rgba(77, 124, 255, .2);
}

.msg-body {
    max-width: 65%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-row.user .msg-body {
    align-items: flex-end;
}

.msg {
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 14.5px;
    word-break: break-word;
}

.msg.bot {
    background: var(--bot-bg);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg.user {
    background: var(--user-bg);
    border-bottom-right-radius: 4px;
}

.msg-meta {
    font-size: 11px;
    color: var(--muted);
}

/* Typing indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 6px 4px;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    animation: bounce 1.2s infinite;
}

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

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-7px);
    }
}

/* System / date divider */
.divider {
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    position: relative;
    margin: 4px 0;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--border);
}

.divider::before {
    right: calc(50% + 60px);
}

.divider::after {
    left: calc(50% + 60px);
}

/* Highlight for search */
mark {
    background: rgba(245, 200, 66, .35);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ===== SUGGESTIONS TRAY ===== */
.suggestions-tray {
    padding: 14px 20px 10px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

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

.tray-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tray-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

.nav-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s, border-color .2s;
}

.nav-btn:disabled {
    opacity: .3;
    cursor: default;
}

.nav-btn:not(:disabled):hover {
    color: var(--text);
    border-color: var(--accent);
}

.page-indicator {
    font-size: 11px;
    color: var(--muted);
    font-family: 'Space Mono', monospace;
    min-width: 36px;
    text-align: center;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 36px;
}

.chip {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    transition: border-color .2s, background .2s, transform .15s;
    white-space: nowrap;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chip:hover {
    border-color: var(--accent);
    background: rgba(245, 200, 66, .08);
    transform: translateY(-1px);
}

.chip:active {
    transform: translateY(0);
}

.chips-loading {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== INPUT AREA ===== */
.input-area {
    padding: 16px 20px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px 6px 6px 18px;
    transition: border-color .2s;
}

.input-wrapper:focus-within {
    border-color: rgba(245, 200, 66, .4);
    box-shadow: 0 0 0 3px rgba(245, 200, 66, .06);
}

.input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14.5px;
}

.input-wrapper input::placeholder {
    color: var(--muted);
}

.send-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f5c842, #ff8c42);
    border: none;
    color: #07090f;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .2s, transform .15s;
    flex-shrink: 0;
}

.send-btn:hover {
    opacity: .9;
    transform: scale(1.04);
}

.send-btn:active {
    transform: scale(.97);
}

.send-btn:disabled {
    opacity: .4;
    cursor: default;
    transform: none;
}

.input-hint {
    font-size: 11px;
    color: var(--muted);
    margin-top: 8px;
    padding-left: 4px;
}

kbd {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: 'Space Mono', monospace;
    font-size: 10px;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 22px;
    border-radius: 100px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s, transform .3s;
    z-index: 999;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== FOOTER BUTTON LABELS ===== */
.footer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
}

.footer-btn span {
    font-size: 12px;
}

/* ===== MODAL BACKDROP ===== */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    backdrop-filter: blur(4px);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.open {
    display: flex;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
    animation: modalIn .25s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(.93) translateY(12px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
}

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.modal-body::-webkit-scrollbar {
    width: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Settings sections */
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--accent);
    font-weight: 600;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.setting-label {
    font-size: 14px;
    font-weight: 500;
}

.setting-desc {
    font-size: 12px;
    color: var(--muted);
}

/* Toggle group (theme, size, etc.) */
.toggle-group {
    display: flex;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
    gap: 3px;
    flex-shrink: 0;
}

.tgl-opt {
    padding: 6px 12px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background .2s, color .2s;
    white-space: nowrap;
}

.tgl-opt.active {
    background: var(--accent);
    color: #07090f;
    font-weight: 600;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    border-radius: 100px;
    background: var(--surface2);
    border: 1px solid var(--border);
    transition: background .25s;
}

.slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform .25s, background .25s;
}

input:checked+.slider {
    background: rgba(245, 200, 66, .2);
    border-color: var(--accent);
}

input:checked+.slider::before {
    transform: translateX(18px);
    background: var(--accent);
}

/* Select */
.setting-select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 7px 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    flex-shrink: 0;
}

.setting-select:focus {
    border-color: var(--accent);
}

/* Action buttons in settings */
.action-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: border-color .2s, background .2s;
    flex-shrink: 0;
}

.action-btn:hover {
    border-color: var(--accent);
    background: rgba(245, 200, 66, .08);
}

.action-btn.danger {
    color: #ff5b5b;
}

.action-btn.danger:hover {
    border-color: #ff5b5b;
    background: rgba(255, 91, 91, .08);
}

/* Help modal */
.about-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.about-icon {
    font-size: 32px;
    line-height: 1;
}

.about-card strong {
    display: block;
    margin-bottom: 4px;
}

.about-card p {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.help-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.help-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.help-step strong {
    color: var(--text);
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(245, 200, 66, .15);
    border: 1px solid rgba(245, 200, 66, .25);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.shortcuts-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shortcut-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--muted);
}

.shortcut-row span {
    margin-left: 4px;
}

/* FAQ */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.faq-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.faq-q {
    width: 100%;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px;
    color: var(--text);
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    text-align: left;
}

.faq-q i {
    color: var(--muted);
    font-size: 11px;
    transition: transform .2s;
    flex-shrink: 0;
}

.faq-q.open i {
    transform: rotate(180deg);
}

.faq-a {
    display: none;
    padding: 0 16px 13px;
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.6;
}

.faq-a.open {
    display: block;
}

/* Contact cards */
.contact-cards {
    display: flex;
    gap: 10px;
}

.contact-card {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    transition: border-color .2s, background .2s;
}

.contact-card:hover {
    border-color: var(--accent);
    background: rgba(245, 200, 66, .05);
}

.contact-card i {
    font-size: 20px;
    color: var(--accent);
}

.contact-card span {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}

.contact-card small {
    font-size: 11px;
    color: var(--muted);
}

/* Light theme */
body.light {
    --bg: #f4f5f9;
    --surface: #ffffff;
    --surface2: #edf0f7;
    --border: rgba(0, 0, 0, .08);
    --text: #1a1d2e;
    --muted: #7b839e;
    --bot-bg: #edf0f7;
}

/* Font size variants */
body.font-small .msg {
    font-size: 12.5px;
}

body.font-large .msg {
    font-size: 16.5px;
}

/* Bubble style */
body.bubble-sharp .msg {
    border-radius: 6px;
}

body.bubble-sharp .msg.bot {
    border-bottom-left-radius: 2px;
}

body.bubble-sharp .msg.user {
    border-bottom-right-radius: 2px;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text2);
    font-size: 13px;
    text-decoration: none;
    transition: color .2s;
    padding: 4px 0;
}

.back-link:hover {
    color: var(--text);
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 30px rgba(0, 0, 0, .5);
    }

    .sidebar-close {
        display: flex;
    }

    .menu-toggle {
        display: flex;
    }

    .msg-body {
        max-width: 80%;
    }

    .input-hint {
        display: none;
    }

    .messages {
        padding: 20px 16px;
    }
}