/* SmartChat Specific Styles */
:root {
    --primary-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gemini-gradient: linear-gradient(90deg, #4b90ff, #ff5546);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Top Header Overrides */
.top-header {
    background: transparent; /* Chat looks better with transparent header over gradient/dark bg */
    position: absolute;
    width: calc(100% - 260px); /* Adjust for sidebar */
}

@media (max-width: 1024px) {
    .top-header {
        width: 100%;
        position: relative;
        background: var(--bg-dark);
    }
}

/* Model Selector */
.model-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.model-selector:hover {
    background: rgba(255, 255, 255, 0.1);
}

.model-name {
    font-size: 14px;
    color: var(--text-main, #e2e8f0);
    font-weight: 500;
}

/* Chat Area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 70px;
    position: relative;
    height: calc(100vh - 70px);
    max-height: calc(100vh - 70px);
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 20%;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* iOS smooth scroll */
    overscroll-behavior: contain;
    min-height: 0; /* Important for flex scroll */
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

.welcome-text {
    font-size: 48px;
    font-weight: 600;
    margin-bottom: 10px;
    background: linear-gradient(to right, #4facfe, #00f2fe, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    letter-spacing: -1px;
}

.welcome-subtext {
    font-size: 20px;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 40px;
}

.suggestion-chips {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 800px;
}

.chip {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    border-radius: 12px;
    color: var(--text-main, #e2e8f0);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chip:hover {
    background: rgba(56, 189, 248, 0.1);
    border-color: #38bdf8;
    transform: translateY(-2px);
}

.chip i { color: #38bdf8; }

/* Messages */
.message {
    display: flex;
    gap: 16px;
    animation: slideUp 0.4s ease-out;
    max-width: 100%;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-avatar {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
}

.user-avatar-msg {
    background: #334155;
    color: #e2e8f0;
}

.message-content {
    background: transparent;
    color: var(--text-main, #e2e8f0);
    font-size: 16px;
    line-height: 1.6;
    max-width: 80%;
}

.user-message .message-content {
    background: rgba(56, 189, 248, 0.1);
    padding: 12px 20px;
    border-radius: 16px 16px 0 16px;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.ai-message .message-content {
    padding-top: 6px;
}

/* Input Area */
.input-container {
    padding: 20px 20%;
    background: linear-gradient(to top, var(--bg-dark) 80%, transparent);
}

.input-box {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 10px 16px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    backdrop-filter: blur(10px);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-box:focus-within {
    border-color: #38bdf8;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.1);
}

.chat-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    padding: 12px 0;
    resize: none;
    max-height: 200px;
    font-family: inherit;
}

.chat-textarea:focus { outline: none; }

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted, #94a3b8);
    padding: 10px;
    cursor: pointer;
    transition: color 0.2s;
    border-radius: 50%;
}

.action-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.send-btn {
    background: white;
    color: var(--bg-dark, #0f172a);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

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

/* Code Blocks */
pre {
    background: #1e293b !important;
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Disclaimer */
.disclaimer {
    text-align: center;
    font-size: 11px;
    color: #64748b;
    margin-top: 8px;
}

/* History Drawer */
.history-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background: var(--bg-dark);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 200;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
}

.history-drawer.active { right: 0; }

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

.history-title {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.close-history-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 18px;
}

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

.history-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-item:hover { background: rgba(255, 255, 255, 0.05); }
.history-item.active { background: rgba(6, 182, 212, 0.1); }

.history-item-title {
    font-size: 14px;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.history-item-date {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

.delete-session-btn {
    background: none;
    border: none;
    color: #ef4444;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    padding: 4px;
}

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

.new-chat-btn-drawer {
    margin: 20px;
    padding: 12px;
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s;
}

.new-chat-btn-drawer:hover { transform: translateY(-2px); }

/* Responsive */
@media (max-width: 1400px) {
    .messages-area, .input-container { padding-left: 10%; padding-right: 10%; }
}

@media (max-width: 768px) {
    .chat-container {
        padding-top: 60px;
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px); /* Dynamic viewport for mobile */
    }
    
    .messages-area {
        padding: 15px;
        padding-bottom: 10px;
    }
    
    .input-container {
        padding: 10px 15px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    .input-box {
        padding: 8px 12px;
    }
    
    .chat-textarea {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 10px 0;
    }
    
    .welcome-text { font-size: 28px; }
    .welcome-subtext { font-size: 14px; margin-bottom: 24px; }
    
    .suggestion-chips {
        gap: 8px;
    }
    
    .chip {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .message {
        gap: 10px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
    }
    
    .message-content {
        font-size: 15px;
        max-width: 85%;
    }
    
    .grounding-toggle {
        padding: 6px 10px;
        margin-bottom: 8px;
        font-size: 12px;
    }
    
    .history-drawer {
        width: 100%;
        right: -100%;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
    }
}
