/* Version Selector Styles (Gemini Style) */
#version-selector {
    min-width: 100px;
    max-width: 200px;
}

#version-selector option {
    background: #1e293b;
    color: #e2e8f0;
    padding: 8px 12px;
}

@media (max-width: 640px) {
    #version-selector {
        min-width: 80px;
        max-width: 120px;
        font-size: 10px;
        padding-left: 8px;
        padding-right: 24px;
    }
}

/* Modern Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Typing Cursor */
.typing-cursor::after {
    content: '▋';
    animation: blink 1s infinite;
    color: #3b82f6;
    margin-left: 2px;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Chat Bubbles */
.user-msg {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.bot-msg {
    color: #e2e8f0;
    line-height: 1.7;
}

/* Markdown Styles */
.prose h1, .prose h2 { color: #f8fafc; font-weight: 700; margin-top: 1.5em; margin-bottom: 0.5em; }
.prose p { margin-bottom: 1em; }
.prose strong { color: #60a5fa; font-weight: 600; }
.prose ul { list-style-type: disc; padding-left: 1.2em; color: #cbd5e1; }
.prose ol { list-style-type: decimal; padding-left: 1.2em; color: #cbd5e1; }
.prose code { 
    background: #1e293b; 
    padding: 2px 6px; 
    border-radius: 6px; 
    color: #f472b6; 
    font-family: 'Courier New', monospace; 
    font-size: 0.9em;
    border: 1px solid #334155;
}
.prose pre { 
    background: #0f172a; 
    padding: 1rem; 
    border-radius: 0.75rem; 
    overflow-x: auto; 
    border: 1px solid #334155;
    margin: 1rem 0;
}

/* Mermaid Flowchart Styles */
.mermaid {
    background: #0f172a;
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid #334155;
    margin: 1.5rem 0;
    text-align: center;
    overflow-x: auto;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
}
.prose blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
    color: #94a3b8;
    font-style: italic;
}

/* ====================================
   MOBILE KEYBOARD HANDLING
   ==================================== */

/* Dynamic viewport height for mobile */
.mobile-safe-height {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height - adjusts for mobile keyboard */
    height: -webkit-fill-available; /* Safari fallback */
}

/* Main container flex layout */
main.flex-1 {
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex child scrolling */
}

/* Chat box takes remaining space */
#chat-box {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* ====================================
   GEMINI-STYLE INPUT AREA
   ==================================== */

/* Input area container */
.input-area-sticky {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: linear-gradient(to top, rgba(15, 23, 42, 1) 80%, transparent);
}

/* Main input container */
.gemini-input-container {
    position: relative;
    transition: all 0.2s ease;
}

.gemini-input-container:hover {
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

.gemini-input-container:focus-within {
    box-shadow: 0 4px 24px rgba(59, 130, 246, 0.15);
}

/* Tool button styling */
.tool-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    min-width: 32px;
    min-height: 32px;
}

.tool-btn:hover {
    transform: scale(1.02);
}

.tool-btn:active {
    transform: scale(0.98);
}

/* Gemini Textarea Styling */
.gemini-textarea {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.4) transparent;
    line-height: 1.6;
}

.gemini-textarea::-webkit-scrollbar {
    width: 4px;
}

.gemini-textarea::-webkit-scrollbar-track {
    background: transparent;
}

.gemini-textarea::-webkit-scrollbar-thumb {
    background-color: rgba(100, 116, 139, 0.4);
    border-radius: 2px;
}

.gemini-textarea:focus {
    outline: none;
}

.gemini-textarea::placeholder {
    color: #6b7280;
}

/* Send Button */
.send-btn {
    transition: all 0.15s ease;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.send-btn:not(:disabled):active {
    transform: scale(0.95);
}

/* Typing Indicator Animation */
.typing-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #6b7280;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Attached Files Styling */
#attached-files {
    background: rgba(30, 41, 59, 0.3);
    border-top: 1px solid rgba(100, 116, 139, 0.2);
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    font-size: 12px;
    color: #93c5fd;
    transition: all 0.2s ease;
}

.file-chip:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
}

.file-chip button {
    padding: 2px;
    color: #9ca3af;
    transition: color 0.2s ease;
}

.file-chip button:hover {
    color: #ef4444;
}

/* When keyboard is open */
.keyboard-open {
    height: 100vh;
    height: 100dvh;
}

.keyboard-open #chat-box {
    padding-bottom: 0;
}

.keyboard-open .input-area-sticky {
    position: sticky;
    bottom: 0;
}

/* Input focused state */
.input-focused #chat-box {
    scroll-behavior: smooth;
}

/* Mobile specific adjustments */
@media screen and (max-width: 768px) {
    .mobile-safe-height {
        height: 100dvh;
        height: -webkit-fill-available;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
    }
    
    main.flex-1 {
        height: 100%;
        display: flex;
        flex-direction: column;
        position: relative;
        overflow: hidden;
    }
    
    header {
        position: sticky;
        top: 0;
        z-index: 30;
        flex-shrink: 0;
    }
    
    #chat-box {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 0.75rem;
    }
    
    .input-area-sticky {
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        z-index: 20;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
        background: linear-gradient(to top, rgba(15, 23, 42, 1) 85%, transparent);
    }
    
    .gemini-input-container {
        border-radius: 16px;
    }
    
    .tool-btn {
        min-width: 32px;
        min-height: 32px;
    }
    
    .gemini-textarea {
        font-size: 16px !important;
        min-height: 20px;
        max-height: 100px !important;
    }
    
    .send-btn {
        width: 38px !important;
        height: 38px !important;
    }
    
    /* Active tool chips mobile */
    #gl-active-chip, #deep-active-chip {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .keyboard-open {
        height: 100dvh !important;
    }
    
    .keyboard-open main.flex-1 {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .keyboard-open #chat-box {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #sidebar {
        height: 100dvh;
        height: -webkit-fill-available;
    }
}

/* Tablet adjustments (iPad, Android tablets) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    #chat-box {
        padding: 1.25rem;
    }
    
    .gemini-input-container {
        border-radius: 24px;
    }
    
    .tools-layer {
        padding: 10px;
    }
    
    .tool-btn {
        min-width: 40px;
        min-height: 40px;
    }
    
    .input-layer {
        padding: 14px;
    }
    
    .gemini-textarea {
        font-size: 15px;
        max-height: 160px !important;
    }
    
    .send-btn {
        min-width: 42px;
        min-height: 42px;
    }
}

/* Desktop - standard behavior */
@media screen and (min-width: 1025px) {
    .mobile-safe-height {
        height: 100vh;
    }
    
    .gemini-input-container {
        border-radius: 28px;
    }
    
    .gemini-textarea {
        font-size: 16px;
    }
    
    .send-btn {
        min-width: 48px;
        min-height: 48px;
    }
}

/* Safe area insets for notched devices (iPhone X+, etc.) */
@supports (padding: max(0px)) {
    .input-area-sticky {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    @media screen and (max-width: 768px) {
        .input-area-sticky {
            padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        }
        
        .input-layer {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

/* Landscape mode adjustments for mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .gemini-textarea {
        max-height: 80px !important;
    }
    
    .tools-layer {
        padding: 6px;
    }
    
    .input-layer {
        padding: 10px !important;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .gemini-input-container {
        border-width: 0.5px;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .gemini-input-container,
    .tool-btn,
    .send-btn,
    .gemini-textarea {
        transition: none !important;
        animation: none !important;
    }
}

/* ====================================
   SEND BUTTON STATES
   ==================================== */

/* Send button disabled state during generation */
#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #4b5563 !important; /* Gray when disabled */
    box-shadow: none;
}

#send-btn:disabled:hover {
    background-color: #4b5563 !important;
    transform: none;
}

/* Spinner animation for loading state */
#send-btn .fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* History list styling */
#history-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

#history-list button {
    transition: all 0.2s ease;
}

#history-list button:hover {
    background-color: rgba(51, 65, 85, 0.5);
}

#history-list button.active {
    background-color: rgba(59, 130, 246, 0.2);
    border-left: 2px solid #3b82f6;
}

/* Empty history state */
#history-list:empty::after {
    content: "No chat history yet";
    display: block;
    padding: 1rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.75rem;
}

/* Account Page Responsive Styles */
@media (max-width: 1023px) {
    /* Ensure sidebar doesn't block content on mobile */
    #account-sidebar {
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }
    
    /* Account content padding adjustments */
    #account-content {
        padding: 0;
    }
    
    /* Form inputs responsive */
    #account-content input,
    #account-content textarea,
    #account-content select {
        width: 100%;
        min-width: 0;
    }
    
    /* Grid layouts stack on mobile */
    #account-content .grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Table responsive */
    #account-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Button spacing */
    #account-content .flex.gap-4 {
        flex-direction: column;
    }
    
    #account-content .flex.gap-4 > * {
        width: 100%;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
    #account-sidebar {
        width: 240px;
    }
}

/* Desktop optimizations */
@media (min-width: 1024px) {
    #account-sidebar {
        position: sticky;
        top: 4rem;
        height: calc(100vh - 4rem);
        overflow-y: auto;
    }
}

/* Laptop (1025px - 1440px) */
@media (min-width: 1025px) and (max-width: 1440px) {
    #account-content {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Large Desktop (1441px+) */
@media (min-width: 1441px) {
    #account-content {
        max-width: 72rem;
    }
}