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

:root {
    --bg-dark: #0a0a0f;
    --bg-panel: #12121a;
    --bg-card: #1a1a25;
    --bg-input: #22222f;
    --text: #e8e8e8;
    --text-dim: #888;
    --accent: #ff6b35;
    --accent-glow: rgba(255, 107, 53, 0.3);
    --green: #4ade80;
    --blue: #60a5fa;
    --border: #2a2a3a;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

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

.logo-badge {
    background: linear-gradient(135deg, var(--accent) 0%, #ff8c5a 100%);
    color: #000;
    font-weight: 800;
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: 4px;
    letter-spacing: 1px;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dim);
}

.new-chat-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: var(--bg-input);
    border-color: var(--accent);
}

/* Conversations */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.conv-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    padding: 8px 12px;
    margin-top: 8px;
}

.conversation-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
    transition: background 0.15s;
    font-size: 0.85rem;
}

.conversation-item:hover {
    background: var(--bg-card);
}

.conversation-item.active {
    background: var(--bg-card);
    border-left: 2px solid var(--accent);
}

.conversation-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
}

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

/* User section */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.credits-box {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.credits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.credits-label {
    color: var(--text-dim);
}

.credits-count {
    font-weight: 600;
    color: var(--green);
}

.credits-count.warning {
    color: var(--accent);
}

.credits-count.danger {
    color: #ef4444;
}

.credits-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.credits-fill {
    height: 100%;
    background: var(--green);
    transition: width 0.3s;
}

.credits-fill.warning {
    background: var(--accent);
}

.credits-fill.danger {
    background: #ef4444;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.user-card:hover {
    background: var(--bg-card);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 6px;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.user-rp {
    font-size: 0.75rem;
    color: var(--accent);
}

.user-dropdown {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    display: none;
    overflow: hidden;
}

.user-dropdown.open {
    display: block;
}

.dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: var(--bg-input);
}

.dropdown-item.danger {
    color: #ef4444;
}

.dropdown-item.admin {
    color: #8b5cf6;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid var(--border);
}

.dropdown-item.admin:hover {
    background: rgba(139, 92, 246, 0.1);
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

/* Header */
.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
}

.header-title {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
}

.header-badge {
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Messages */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.messages-inner {
    max-width: 800px;
    margin: 0 auto;
}

.message {
    margin-bottom: 24px;
    animation: slideIn 0.2s ease;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.msg-avatar.user {
    background: var(--blue);
    color: #000;
}

.msg-avatar.assistant {
    background: var(--accent);
    color: #000;
}

.msg-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.msg-name.assistant {
    color: var(--accent);
}

.message-body {
    padding-left: 38px;
    line-height: 1.6;
    font-size: 0.9rem;
}

.message-body p {
    margin-bottom: 10px;
}

.message-body code {
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.message-body strong {
    color: var(--accent);
}

/* Empty state */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 24px;
}

.welcome-badge {
    background: linear-gradient(135deg, var(--accent) 0%, #ff8c5a 100%);
    color: #000;
    font-weight: 800;
    font-size: 1.5rem;
    padding: 16px 24px;
    border-radius: 8px;
    letter-spacing: 2px;
    margin-bottom: 24px;
}

.welcome h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.welcome p {
    color: var(--text-dim);
    margin-bottom: 32px;
    max-width: 400px;
}

.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 600px;
}

.quick-btn {
    padding: 10px 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.quick-btn:hover {
    border-color: var(--accent);
    background: var(--bg-card);
}

/* Typing */
.typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-panel);
    border-radius: 12px;
    width: fit-content;
}

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

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

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Input */
.input-area {
    padding: 16px 24px 24px;
    background: var(--bg-dark);
}

.input-box {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.chat-input {
    width: 100%;
    padding: 14px 50px 14px 18px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 0.9rem;
    resize: none;
    outline: none;
    min-height: 50px;
    max-height: 150px;
}

.chat-input:focus {
    border-color: var(--accent);
}

.chat-input::placeholder {
    color: var(--text-dim);
}

.send-btn {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 34px;
    height: 34px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, opacity 0.15s;
}

.send-btn:hover {
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #0f0f18 100%);
}

.login-box {
    background: var(--bg-panel);
    padding: 48px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    border: 1px solid var(--border);
}

.login-badge {
    background: linear-gradient(135deg, var(--accent) 0%, #ff8c5a 100%);
    color: #000;
    font-weight: 800;
    font-size: 1.25rem;
    padding: 12px 20px;
    border-radius: 8px;
    letter-spacing: 2px;
    display: inline-block;
    margin-bottom: 24px;
}

.login-box h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.login-box p {
    color: var(--text-dim);
    margin-bottom: 32px;
    font-size: 0.9rem;
}

.steam-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    background: #1b2838;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.steam-btn:hover {
    background: #2a475e;
}

.login-note {
    margin-top: 20px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.error-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 0.85rem;
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.2s;
    }

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

    .mobile-menu {
        display: block;
    }

    .overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 99;
    }

    .overlay.open {
        display: block;
    }

    .messages-area {
        padding: 16px;
    }

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

    .login-box {
        padding: 32px 24px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.user-menu {
    position: relative;
}
