/* Reset and Base Styles */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #141414;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent-color: #ffffff;
    --border-color: #2a2a2a;
    --input-bg: #1a1a1a;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Stars Background */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0;
    animation: starTwinkle var(--duration) ease-in-out infinite;
    animation-delay: var(--delay);
}

.star::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
    border-radius: 50%;
}

@keyframes starTwinkle {

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

    50% {
        opacity: var(--max-opacity);
        transform: translateY(var(--drift)) scale(1);
    }
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 60px;
    height: 100vh;
    background: var(--bg-primary);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px 0;
    z-index: 100;
}

.sidebar-top,
.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sidebar-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.sidebar-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.sidebar-btn svg {
    width: 20px;
    height: 20px;
}

/* History Panel */
.history-panel {
    position: fixed;
    left: 60px;
    top: 0;
    width: 280px;
    height: 100vh;
    background: var(--bg-primary);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 99;
    transform: translateX(-100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
}

.history-panel.open {
    transform: translateX(0);
    opacity: 1;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-history-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.close-history-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.close-history-btn svg {
    width: 16px;
    height: 16px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.history-item {
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 4px;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.history-item.active {
    background: rgba(255, 255, 255, 0.12);
}

.history-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.no-history {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Main Container - adjusted for sidebar */
.main-container {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin-left: calc(60px + (100% - 60px - 900px) / 2);
    padding: 0 20px;
    width: 100%;
}

/* Media query calculation removed here as it is handled in the main responsive block at the bottom */

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    flex-shrink: 0;
}

.header.hidden {
    visibility: hidden;
    opacity: 0;
}

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

.logo-icon {
    height: 90px;
    width: auto;
    color: var(--text-primary);
    opacity: 0.9;
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.logo-icon img {
    height: 100%;
    width: auto;
}

.header-right {
    display: flex;
    align-items: center;
}

.private-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 6px 12px;
    border-radius: 20px;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Welcome Screen */
.welcome-screen {
    position: fixed;
    top: 50%;
    left: calc(60px + (100% - 60px) / 2);
    transform: translate(-50%, -50%);
    text-align: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    z-index: 10;
}

.welcome-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-img {
    height: 240px;
    width: auto;
}

.logo-svg {
    width: 48px;
    height: 48px;
    color: var(--text-primary);
}

.logo-text {
    font-size: 42px;
    font-weight: 600;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #ffffff 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

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

/* Message Styles - Messenger Style */
.message {
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.3s ease;
    max-width: 75%;
}

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

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

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

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

/* Hide avatars for Messenger style */
.message-avatar {
    display: none;
}

.message-content {
    padding: 0;
}

.message-text {
    font-size: 15px;
    line-height: 1.5;
    padding: 10px 16px;
    border-radius: 18px;
    display: inline-block;
}

/* User messages - Transparent with white border */
.message.user .message-text {
    background: transparent;
    color: #ffffff;
    border: 1px solid #666666;
    border-bottom-right-radius: 4px;
}

/* AI messages - Transparent with no border */
.message.assistant .message-text {
    background: transparent;
    color: #ffffff;
    border: none;
    border-bottom-left-radius: 4px;
}

/* Word fade animation */
.word {
    display: inline;
    opacity: 0;
    animation: wordFadeIn 0.4s ease forwards;
}

@keyframes wordFadeIn {
    from {
        opacity: 0;
        filter: blur(2px);
    }

    to {
        opacity: 1;
        filter: blur(0);
    }
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Input Wrapper */
.input-wrapper {
    padding: 20px 0 24px;
    flex-shrink: 0;
    /* transition removed */
}

/* Input centered on welcome screen */
.input-wrapper.centered {
    position: fixed;
    bottom: 50%;
    left: calc(60px + (100% - 60px) / 2);
    transform: translate(-50%, 80px);
    /* Positioned under logo */
    width: 100%;
    max-width: 700px;
    padding: 0 20px;
    z-index: 11;
}

.input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    padding: 12px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-container:focus-within {
    border-color: #404040;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.thinking-icon {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.thinking-icon svg {
    width: 100%;
    height: 100%;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
}

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

.send-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--text-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

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

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-button svg {
    width: 18px;
    height: 18px;
    color: #000000;
}

/* Responsive */
/* Responsive */
@media (max-width: 1024px) {
    .main-container {
        max-width: 100%;
        margin-left: 60px;
        width: calc(100% - 60px);
        padding: 0 16px;
    }
}

@media (max-width: 768px) {

    /* Main Layout */
    .main-container {
        margin-left: 0;
        width: 100%;
        height: 100vh;
        padding-bottom: 0px;
        /* No bottom nav */
    }

    /* Hide Sidebar/Menu on Mobile */
    .sidebar {
        display: none;
    }

    /* History Panel - Full screen overlay on mobile */
    .history-panel {
        top: 0;
        left: 0;
        width: 100%;
        height: calc(100vh - 60px);
        z-index: 1001;
        background: var(--bg-primary);
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .history-panel.open {
        transform: translateY(0);
        opacity: 1;
    }

    /* Header */
    .header {
        padding: 12px 16px;
        /* Add horizontal padding */
        height: 60px;
        background: var(--bg-primary);
        z-index: 10;
    }

    .logo-icon {
        height: 48px;
        /* Increased from 32px as requested */
        width: auto;
    }

    /* Welcome Screen */
    .welcome-screen {
        left: 50%;
        top: 40%;
        /* Move up slightly to avoid keyboard/input overlap */
        width: 100%;
        padding: 0 20px;
        z-index: 5;
        /* Ensure visibility */
    }

    .logo-img {
        height: 120px;
        /* Adjusted for better proportion */
    }

    .logo-text {
        font-size: 28px;
    }

    /* Input Area */
    .input-wrapper {
        padding: 12px 16px 40px;
        /* Increased bottom padding to move input up */
        background: linear-gradient(to top, var(--bg-primary) 80%, transparent);
        position: relative;
        z-index: 20;
    }

    /* Fix for input being too low in welcome screen */
    .input-wrapper.centered {
        left: 50%;
        bottom: auto;
        top: 60%;
        /* Adjusted to be under the logo which is at 40% top + 150px height */
        transform: translate(-50%, -20px);
        /* Move up 20px */
        width: 100%;
        padding: 0 16px;
    }

    .input-container {
        padding: 10px 14px;
        background: var(--bg-secondary);
    }

    /* Messages */
    .message {
        max-width: 85%;
    }

    .message.user {
        margin-right: 8px;
        /* Ensure it doesn't touch the right edge */
    }

    .message.assistant {
        margin-left: 0;
        /* Keep aligned to left */
    }
}