/* AI Chat Premium Design System */
:root {
    --ai-primary: #1a73e8;
    --ai-primary-gradient: linear-gradient(135deg, #1a73e8 0%, #61a0ff 100%);
    --ai-gemini-bg: #f8faff;
    --ai-bubble-user: #e3f2fd;
    --ai-bubble-ai: #ffffff;
    --ai-text: #1f1f1f;
    --ai-text-muted: #5f6368;
    --ai-shadow: 0 4px 15px rgba(0,0,0,0.05);
    --ai-border: #e0e0e0;
    --ai-glass: rgba(255, 255, 255, 0.8);
}

.ai-chat-body {
    background-color: var(--ai-gemini-bg);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--ai-text);
    margin: 0;
    height: calc(100vh - 160px); /* Fill space between header and footer */
    display: flex;
    overflow: hidden;
    width: 100%;
}

/* Sidebar */
.ai-sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid var(--ai-border);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 1000;
}

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

.new-chat-btn {
    width: 100%;
    padding: 12px;
    border-radius: 50px;
    background: var(--ai-primary-gradient);
    color: #fff;
    border: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

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

.ai-history-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    padding: 12px 15px;
    border-radius: 12px;
    margin-bottom: 5px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ai-text-muted);
    transition: background 0.2s;
    position: relative;
}

.history-item:hover {
    background: #f1f3f4;
}

.history-item.active {
    background: #e8f0fe;
    color: var(--ai-primary);
    font-weight: 500;
}

.delete-history-btn {
    position: absolute;
    right: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

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

/* Main Content Area */
.ai-main-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

/* Header */
.ai-chat-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ai-glass);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--ai-border);
    position: sticky;
    top: 0;
}

/* Start Screen (Persona Selection) */
#startScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Better for handling scrollable content */
    padding: 60px 20px;
    text-align: center;
    flex-grow: 1;
    max-width: 800px;
    margin: 0 auto;
    overflow-y: auto;
}

.gemini-logo {
    font-size: 40px;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #1a73e8, #9b51e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.persona-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
    margin-top: 30px;
}

.persona-card {
    background: #fff;
    padding: 25px;
    border-radius: 20px;
    border: 1px solid var(--ai-border);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.persona-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-color: var(--ai-primary);
}

.persona-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: #f0f4fe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--ai-primary);
}

.persona-card h3 {
    margin: 0;
    font-size: 16px;
}

.persona-card p {
    margin: 0;
    font-size: 13px;
    color: var(--ai-text-muted);
}

/* Chat Flow */
#chatArea {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: none;
    flex-direction: column;
    gap: 25px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.message {
    display: flex;
    gap: 15px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.message.ai {
    align-self: flex-start;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--ai-border);
    flex-shrink: 0;
}

.message.ai .avatar-circle {
    background: linear-gradient(45deg, #4285f4, #9b51e0);
    color: #fff;
}

.message-content {
    background: #fff;
    padding: 12px 18px;
    border-radius: 18px;
    box-shadow: var(--ai-shadow);
    font-size: 15px;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--ai-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    border-bottom-left-radius: 4px;
    background: #fff;
}

/* Markdown Styles */
.message-content p { margin: 0 0 10px 0; }
.message-content p:last-child { margin-bottom: 0; }
.message-content pre {
    background: #f6f8fa;
    padding: 15px;
    border-radius: 10px;
    overflow-x: auto;
}

/* Input Area */
.ai-input-wrapper {
    padding: 20px;
    background: linear-gradient(to top, #fff 80%, transparent);
    position: sticky;
    bottom: 0;
}

.ai-input-container {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--ai-border);
    border-radius: 28px;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.ai-textarea {
    flex-grow: 1;
    border: none;
    outline: none;
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 15px;
    resize: none;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--ai-primary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #f1f3f4;
}

.send-btn:disabled {
    color: var(--ai-text-muted);
    cursor: not-allowed;
}

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

/* Mobile Responsiveness */
    .ai-chat-body {
        height: calc(100vh - 140px);
    }
    .ai-sidebar {
        position: absolute;
        left: -280px;
        height: 100%;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }
    .ai-sidebar.open {
        left: 0;
    }
    .persona-grid {
        grid-template-columns: 1fr;
        padding-bottom: 80px; /* Ensure space for accessibility and avoid footer overlap */
    }
    .message {
        max-width: 95%;
    }
}
