/* --- THEME VARIABLES --- */
:root {
    /* identify.js will overwrite defaults */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --radius: 24px;
    
    /* Blurs - Controlled by JS now, but defaults here */
    --blur-bg: 4px;
    --blur-panel: 12px;
    --blur-login: 24px;

    /* Dark Mode Defaults (High Contrast) */
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --panel-border: rgba(255, 255, 255, 0.1);
    --panel-highlight: rgba(255, 255, 255, 0.05);
    
    /* Animation Curves */
    --ease-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Light Mode Overrides */
[data-theme="light"] {
    --text-main: #0f172a;
    --text-muted: #64748b;
    --panel-border: rgba(0, 0, 0, 0.08);
    --panel-highlight: rgba(255, 255, 255, 0.8);
    --primary-hover: #4338ca;
}

body {
    color: var(--text-main);
    font-family: var(--font-main, 'Poppins'), sans-serif;
    transition: color 0.5s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
    touch-action: pan-x pan-y;
    -webkit-tap-highlight-color: transparent;
}

/* --- ANIMATED BACKGROUND --- */
#bg-layer {
    background-size: cover;
    background-position: center;
    transition: opacity 0.5s ease;
}

/* --- GLASS UI PANELS --- */
.ui-panel {
    background: linear-gradient(145deg, rgba(30, 30, 35, 0.6), rgba(30, 30, 35, 0.4));
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    box-shadow: inset 0 1px 0 0 var(--panel-highlight), 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--panel-border);
    transition: all 0.3s ease;
    border-radius: var(--radius);
}

[data-theme="light"] .ui-panel {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.5));
}

/* =======================================================
   LOGIN PANEL & STRONG BLUR OVERRIDES 
   =======================================================
*/
#login-panel {
    /* Blur is set directly via JS, this is just a fallback */
    backdrop-filter: blur(var(--glass-blur)) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur)) !important;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 0 30px rgba(255,255,255,0.02);
}

[data-theme="light"] #login-panel {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.6));
}

/* Fix for Square Logos - Auto Squircles */
#login-logo, #app-logo {
    border-radius: 22%; /* Soft squircle shape */
    background-color: rgba(255,255,255,0.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* --- BUTTONS & INTERACTIVE --- */
.btn-icon {
    padding: 0.6rem;
    border-radius: 14px;
    color: var(--text-muted);
    transition: all 0.2s ease;
    background: transparent;
    border: 1px solid transparent;
}

.btn-primary-natural {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
    box-shadow: 0 2px 10px rgba(var(--primary), 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
    border: 1px solid rgba(0,0,0,0.1);
}
.btn-primary-natural:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1), inset 0 2px 4px rgba(0,0,0,0.2);
}

/* --- CREDIT POSITIONING --- */
.credit-badge {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 40;
    pointer-events: none;
    opacity: 0.5;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

/* Mobile Specific Adjustments */
@media (max-width: 640px) {
    /* Fix credit overlap on mobile by moving it into flow or absolute to container */
    .credit-badge {
        position: absolute;
        bottom: 1.5rem;
        right: 0;
        left: 0;
        text-align: center;
        width: 100%;
        opacity: 0.3;
    }
    
    /* Ensure chat area doesn't clip top blur */
    #chat-viewport {
        padding-top: 1rem;
    }
    
    /* Softer shadows on mobile */
    .ui-panel {
        box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    }
}

/* --- SCROLLBAR --- */
.custom-scroll::-webkit-scrollbar { width: 4px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb { 
    background: rgba(255,255,255,0.1); 
    border-radius: 10px; 
}

/* --- MARKDOWN & MESSAGES --- */
.prose p { margin-bottom: 0.75rem; line-height: 1.6; }
.msg-bubble-user {
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.alts-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1);
}
.alts-container.open { max-height: 1200px; }

/* Improved loading animation */
#loader {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Smooth language toggle transition */
#lang-toggle, #login-lang-toggle {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Touch-friendly targets for mobile */
@media (max-width: 640px) {
    .btn-icon, button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better mobile spacing for error messages */
    .msg-card-bot {
        margin-bottom: 1rem;
    }
}

/* Haptic feedback support */
.touch-manipulation {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(var(--primary), 0.2);
}