:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9f9f9;
    --bg-sidebar: #ffffff;
    --bg-message-user: transparent;
    --bg-message-ai: transparent;
    --text-primary: #000000;
    --text-secondary: #666666;
    --border-color: #e5e5e5;
    --accent-color: #000000;
    --accent-hover: #f0f0f0;
    --input-bg: #f4f4f4;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --sidebar-width: 260px;
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-sidebar: #000000;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: #262626;
    --accent-color: #ffffff;
    --accent-hover: #1a1a1a;
    --input-bg: #121212;
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
}

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

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

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.auth-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    width: 400px;
    box-shadow: var(--shadow-md);
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo h1 {
    font-size: 32px;
    font-weight: 700;
}

.auth-form input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.auth-form input:focus {
    border-color: var(--text-secondary);
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background: var(--accent-color);
    border: none;
    border-radius: 8px;
    color: var(--bg-primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.auth-form button:hover {
    opacity: 0.9;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-switch a {
    color: var(--text-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

.error-message {
    background: #ff4444;
    color: white;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    text-align: center;
}

.app-container {
    display: none;
    height: 100vh;
    flex-direction: row;
}

.hidden {
    display: none !important;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 12px;
}

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

.sidebar-logo .logo-icon {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
}

.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--accent-hover);
    color: var(--text-primary);
}

/* Search */
.sidebar-search {
    margin-bottom: 20px;
}

.search-wrapper {
    background: var(--input-bg);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.search-wrapper input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    width: 100%;
}

/* Nav */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 24px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--accent-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-hover);
    color: var(--text-primary);
}

/* History */
.sidebar-section {
    flex: 1;
    overflow-y: auto;
}

.section-title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    padding: 8px 12px;
    margin-bottom: 4px;
}

.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conversation-item {
    font-size: 13.5px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.conversation-item.active {
    background: var(--bg-secondary);
}

.delete-conv-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

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

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 8px 0;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-profile {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: #ff8c00;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.user-name {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--accent-hover);
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20px 180px;
}

.chat-messages {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

/* Messages */
.message {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message-role {
    display: none;
}

.message-content {
    font-size: 15px;
    padding: 10px 16px;
    border-radius: 18px;
    max-width: 80%;
    position: relative;
    line-height: 1.5;
}

.message.user .message-content {
    background: #ae004c;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: #212124;
    color: #ffffff;
    border-bottom-left-radius: 4px;
}

/* Theme overrides */
[data-theme="light"] .message.assistant .message-content {
    background: #e9e9eb;
    color: #000000;
}

[data-theme="light"] .message.user .message-content {
    background: #ae004c;
    color: #ffffff;
}

.message-timestamp {
    font-size: 11px;
    color: #666666;
    margin-top: 4px;
}

.message.user .message-timestamp {
    margin-right: 4px;
}

.message.assistant .message-timestamp {
    margin-left: 4px;
}

/* Right Indicators */
.right-indicator-track {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    height: 80%;
    width: 4px;
    display: flex;
    justify-content: center;
}

.indicator-bar {
    width: 6px;
    height: 100px;
    background: #8e8e93;
    border-radius: 6px;
    opacity: 0.8;
}

/* Special Block Styles (Grok style) */
.content-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
}

/* Code Blocks */
pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    margin: 12px 0;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Input Area */
.input-container {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 800px;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}



.input-wrapper {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

textarea#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    resize: none;
    padding: 8px 0;
    max-height: 200px;
    outline: none;
}

.input-buttons-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-selector {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.send-btn {
    background: var(--accent-color);
    color: var(--bg-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.send-btn:hover {
    opacity: 0.8;
}

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

/* Empty State */
.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.empty-state h2 {
    font-size: 28px;
    margin-bottom: 12px;
    font-weight: 600;
}

.empty-state p {
    color: var(--text-secondary);
}

/* Loading */
.loading {
    display: none;
    padding: 0 20px 20px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.loading-grid {
    display: grid;
    grid-template-columns: repeat(3, 8px);
    grid-gap: 4px;
    padding: 12px;
    width: fit-content;
}

.loading-grid span {
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0.3;
    animation: gridPulse 1.5s infinite ease-in-out;
}

/* Stagger animation for 3x3 grid */
.loading-grid span:nth-child(1) {
    animation-delay: 0s;
}

.loading-grid span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-grid span:nth-child(3) {
    animation-delay: 0.4s;
}

.loading-grid span:nth-child(4) {
    animation-delay: 0.2s;
}

.loading-grid span:nth-child(5) {
    animation-delay: 0.4s;
}

.loading-grid span:nth-child(6) {
    animation-delay: 0.6s;
}

.loading-grid span:nth-child(7) {
    animation-delay: 0.4s;
}

.loading-grid span:nth-child(8) {
    animation-delay: 0.6s;
}

.loading-grid span:nth-child(9) {
    animation-delay: 0.8s;
}

@keyframes gridPulse {

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

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}