/* Enhanced styles with sidebar and better UX */

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

:root {
    --primary: #667eea;
    --primary-dark: #764ba2;
    --bg: #f8f9fa;
    --surface: white;
    --text: #333;
    --text-light: #666;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    min-height: 100vh;
}

/* Login Screen */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 60px 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-card h1 {
    color: var(--text);
    margin-bottom: 12px;
    font-size: 28px;
}

.login-card p {
    color: var(--text-light);
    margin-bottom: 40px;
    font-size: 16px;
}

.google-signin-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s;
}

.google-signin-btn:hover {
    border-color: #4285f4;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
    transform: translateY(-2px);
}

.google-icon {
    width: 24px;
    height: 24px;
}

/* Chat Interface */
.chat-interface {
    display: none;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    height: 100vh;
}

.chat-interface {
    display: none;
    grid-template-columns: 300px 1fr;
}

@media (max-width: 768px) {
    .chat-interface {
        grid-template-columns: 1fr;
    }
}

/* Sidebar */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        width: 300px;
        z-index: 100;
        transition: left 0.3s;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        left: 0;
    }
}

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

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.new-chat-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

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

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

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

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

.session-item.active {
    background: var(--bg);
    border-left: 3px solid var(--primary);
}

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

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

/* Main Chat Area */
.chat-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg);
}

/* Header */
.chat-header {
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    z-index: 10;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

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

@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.user-email {
    font-size: 14px;
    color: var(--text-light);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.logout-btn {
    padding: 8px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--border);
}

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

.welcome-message {
    max-width: 600px;
    margin: 80px auto;
    text-align: center;
}

.welcome-message h2 {
    font-size: 28px;
    color: var(--text);
    margin-bottom: 12px;
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 32px;
}

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.quick-prompt {
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.quick-prompt:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s;
}

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

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #34A853, #0F9D58);
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 15px;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--surface);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

/* Markdown formatting */
.message-content code {
    background: rgba(0,0,0,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 13px;
}

.message.user .message-content code {
    background: rgba(255,255,255,0.2);
}

.message-content pre {
    background: rgba(0,0,0,0.05);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content a {
    color: var(--primary);
    text-decoration: underline;
}

.message.user .message-content a {
    color: white;
}

.message-content strong {
    font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: 12px;
    width: fit-content;
    box-shadow: var(--shadow);
}

.typing-indicator.active {
    display: block;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Input Container */
.input-container {
    padding: 20px 24px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

#messageInput:focus {
    border-color: var(--primary);
}

#sendButton {
    width: 44px;
    height: 44px;
    padding: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

#sendButton:hover:not(:disabled) {
    transform: scale(1.05);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Error Message */
.error-message {
    background: #fee;
    color: #c33;
    padding: 12px 24px;
    margin: 0 24px;
    margin-top: 12px;
    border-radius: 8px;
    display: none;
    border-left: 4px solid #c33;
}

.error-message.active {
    display: block;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--text);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .chat-header h1 {
        font-size: 16px;
    }

    .user-email {
        display: none;
    }

    .message-content {
        max-width: 85%;
    }

    .welcome-message {
        margin: 40px auto;
    }

    .welcome-message h2 {
        font-size: 24px;
    }
}
