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

:root {
    /* GitHub/ChatGPT inspired dark theme colors */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --border-color: #30363d;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-blue: #58a6ff;
    --accent-purple: #bc8cff;
    --accent-green: #3fb950;
    --sidebar-width: 280px;
    --header-height: 60px;
    --input-height: 80px;
}

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

/* Authentication Screen */
.auth-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.auth-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 48px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.auth-header {
    margin-bottom: 32px;
}

.auth-logo {
    color: var(--accent-blue);
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.auth-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 16px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.google-signin-btn {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.google-signin-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

.google-signin-btn:active {
    transform: translateY(0);
}

.google-signin-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--bg-hover);
    border-top: 2px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Hide main app initially */
.app-container.hidden {
    display: none;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 1000;
}

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

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

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

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.session-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    background-color: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.session-item:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
}

.session-item.active {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-blue);
}

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

.session-time {
    font-size: 12px;
    color: var(--text-muted);
}

.session-delete {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: none;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.session-item:hover .session-delete {
    display: block;
}

.session-delete:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    overflow: hidden;
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.menu-toggle:hover {
    background-color: var(--bg-hover);
}

.chat-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: var(--bg-tertiary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

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

.logout-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

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

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

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    min-height: 400px;
}

.welcome-icon {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.welcome-screen h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome-screen p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Message Styles */
.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.message-avatar.user {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
}

.message-avatar.assistant {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--accent-green);
}

.message-content {
    flex: 1;
    min-width: 0;
}

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

.message-sender {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.message-time {
    font-size: 12px;
    color: var(--text-muted);
}

.message-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Chat Input Container */
.chat-input-container {
    padding: 16px 24px 24px;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    transition: border-color 0.2s ease;
}

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

.chat-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
}

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

.send-btn {
    background-color: var(--accent-blue);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    background-color: #4a8fd8;
    transform: scale(1.05);
}

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

.send-btn:disabled {
    background-color: var(--bg-tertiary);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Scrollbar Styles */
.messages-container::-webkit-scrollbar,
.sessions-list::-webkit-scrollbar {
    width: 8px;
}

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

.messages-container::-webkit-scrollbar-thumb,
.sessions-list::-webkit-scrollbar-thumb {
    background-color: var(--bg-hover);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.sessions-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
    }

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

    .menu-toggle {
        display: flex;
    }

    .chat-header {
        padding: 0 16px;
    }

    .messages-container {
        padding: 16px;
    }

    .chat-input-container {
        padding: 12px 16px 16px;
    }

    .welcome-screen {
        min-height: 300px;
        padding: 32px 16px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }

    .messages-container {
        padding: 20px;
    }
}

/* Overlay for mobile sidebar */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 999;
}

.overlay.active {
    display: block;
}

@media (max-width: 768px) {
    body.sidebar-open {
        overflow: hidden;
    }
}
