/* === PEOPLEAI CHAT FRONTEND (DARK GLASS REDESIGN) === */
/* Google Material Symbols (Ensure the link in PHP is correct: material-symbols-outlined) */
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght@400;500;600");

/* --- CONFIG VARS (DARK GLASS PALETTE) --- */
:root {
    /* Base Colors for Dark Theme */
    --dark-bg-primary: #121212; /* Deep background (similar to the image) */
    --dark-bg-secondary: #1E1E1E; /* Slightly lighter for main app container */
    --glass-bg-low-opacity: rgba(25, 25, 25, 0.6); /* Subtle glass for input area/borders */
    --glass-bg-high-opacity: rgba(30, 30, 30, 0.8); /* Darker glass for AI bubbles (will be overridden for transparency) */
    /* Text & Border Colors */
    --text-color-primary: #E0E0E0; /* Light grey for main text */
    --text-color-secondary: #AAAAAA; /* Subtler grey */
    --thin-border-color: #333333; /* Thin, subtle dark border (crucial for the input area) */
    /* Action & Indicator Colors (Keeping Gemini Blue/Grey/Yellow style) */
    --gemini-blue: #8AB4F8; /* Lighter Blue for Send/Action (suitable for dark mode) */
    --gemini-action-color: #9AA0A6; /* Light Grey for attachment/mic icons (USED FOR ALL ICONS NOW) */
    --thinking-color: #FDD663; /* Google Yellow/Gold for thinking dots (suitable for dark mode) */
    /* Element Specific Backgrounds */
    --assistant-bg: var(--glass-bg-high-opacity); /* AI response background */
    --user-bubble-bg: #333639; /* Darker background for user messages */
    --input-bg: var(--dark-bg-secondary); /* Input background */
    /* Action button hover background (Subtle white overlay on dark background) */
    --action-bg-subtle: rgba(255, 255, 255, 0.08);
}

/* --- ROOT & CHAT AREA --- */
.peopleai-widget {
    display: flex;
    flex-direction: column;
    height: 100vh;
    /* Set root background to transparent to allow the body background/results background to show */
    background: transparent;
    color: var(--text-color-primary);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    position: relative;
}

.peopleai-results {
    flex: 1;
    overflow-y: auto;
    /* Increased top/bottom padding to match the taller composer area */
    padding: 80px 16px 160px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* UPDATED: Removed background image for a solid dark theme background */
    background-image: none;
    background-color: var(--dark-bg-primary); 
}

/* --- SCROLLBAR SPACING FIX (Ensures scrollbar is further from content) --- */
.peopleai-results {
    padding-right: 25px; /* Add extra padding on the right */
    margin-right: -10px; /* Offset the padding slightly */
}

/* Scrollbar Customization (for the dark theme) */
.peopleai-results::-webkit-scrollbar {
    width: 10px;
}
.peopleai-results::-webkit-scrollbar-track {
    background: var(--dark-bg-primary);
}
.peopleai-results::-webkit-scrollbar-thumb {
    background-color: #444444; /* Darker thumb */
    border-radius: 5px;
    border: 2px solid var(--dark-bg-primary); /* Separates thumb from content */
}
.peopleai-results::-webkit-scrollbar-thumb:hover {
    background-color: #666666;
}

/* --- MESSAGES & COLORS --- */
.peopleai-message {
    display: flex;
    margin-bottom: 16px;
    width: 100%;
    /* Retain original max-width */
    max-width: 780px;
}

/* Explicitly align user bubble to the right side of the container */
.peopleai-user {
    justify-content: flex-end;
}

/* Explicitly align assistant bubble to the left side of the container */
.peopleai-assistant {
    justify-content: flex-start;
    width: 100%; /* Allows the message container to stretch */
}

.peopleai-system {
    margin: 5px 5px 16px 5px;
    color: var(--text-color-secondary); /* Subtle color for system messages */
}

.peopleai-bubble {
    /* Kept at 80% max-width generally, primarily affecting the user bubble */
    max-width: 80%;
    padding: 14px 18px;
    /* FONT SIZE: Confirmed 16px to match Gemini style */
    font-size: 16px;
    border-radius: 20px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
    /* Glass Effect Base */
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.peopleai-user .peopleai-bubble {
    background: var(--user-bubble-bg); /* Dark, non-glassy background for user */
    color: var(--text-color-primary);
    border-bottom-right-radius: 4px;
}

/* AI Assistant Bubble: The Glassy Look */
.peopleai-assistant .peopleai-bubble {
    /* Allow AI bubble to fill the .peopleai-message container for full width */
    max-width: 100%;
    /* Make AI background transparent as requested */
    background: transparent;
    color: var(--text-color-primary);
    border: 1px solid var(--thin-border-color); /* Thin border added */
    border-bottom-left-radius: 4px;
    padding-left: 18px;
}

/* ---------------------------------------------------- */
/* --- INPUT AREA (COMPOSER) - REDESIGN & FIXES --- */
/* ---------------------------------------------------- */
.peopleai-input-area {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    /* FIXED: Desktop Sizing - Reduced from 780px to 600px for smaller desktop footprint */
    width: min(600px, 96%);
    display: flex;
    flex-direction: column;
    /* Dark Glass Styling */
    background: var(--glass-bg-low-opacity);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Requested Changes: Thin Border & No Shadow */
    border: 1px solid var(--thin-border-color); /* Thin border line */
    border-radius: 28px;
    box-shadow: none; /* Shadow removed */
    padding: 10px 18px 8px 18px;
    margin-bottom: 16px;
    z-index: 100;
}

/* 1. Text Input Area (The Prompt Box) */
.peopleai-textbox-wrapper {
    flex: 1;
    display: flex;
    margin: 0;
    padding-bottom: 8px;
}

#peopleai-text {
    flex-grow: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 0;
    resize: none;
    background: transparent;
    max-height: 160px;
    line-height: 1.5;
    color: var(--text-color-primary); /* Light text on dark background */
    min-height: 24px;
}

/* 2. Action Buttons (The Bottom Row) - Logic Preserved */
.peopleai-action-buttons {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 4px; /* ALIGNMENT FIX: Added small top margin for vertical spacing */
}

/* Icon Buttons (Attach, Mic) */
.peopleai-icon-btn {
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, transform 0.1s;
    margin-right: 4px;
}

.peopleai-icon-btn:hover {
    background: var(--action-bg-subtle); /* Subtle background for hover */
}

.peopleai-icon-btn .material-symbols-outlined {
    font-size: 24px;
    color: var(--gemini-action-color); /* Light grey action icons */
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ------------------------------------------- */
/* --- DUAL-FUNCTION BUTTON STYLES (ADJUSTED) --- */
/* ------------------------------------------- */
/* Send Button (The Circle Base) */
#peopleai-submit-btn {
    /* ADDED: Flex properties to ensure the icon is perfectly centered within the circular background */
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--action-bg-subtle); /* Subtle dark background */
    border: none;
    border-radius: 50%;
    padding: 8px;
    box-shadow: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin: 0;
}

#peopleai-submit-btn:hover {
    background: rgba(255, 255, 255, 0.15); /* Slightly brighter subtle hover */
    transform: scale(1.02);
}

/* Send Icon State (MATCHES ATTACH: Grey, UNFILLED icon inside the subtle circle) */
#peopleai-submit-btn:not(.peopleai-mic-mode) {
    background: var(--action-bg-subtle) !important;
}

#peopleai-submit-btn:not(.peopleai-mic-mode) .material-symbols-outlined {
    /* Use the light grey action color to match the attach button */
    color: var(--gemini-action-color) !important;
    font-size: 24px;
    /* UNFILLED, REGULAR WEIGHT to match other icons */
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Default (Mic) State: Grey icon inside the subtle circle (Already correct) */
.peopleai-submit.peopleai-mic-mode {
    background: var(--action-bg-subtle) !important;
    border: none !important;
    padding: 8px !important;
    transition: all 0.2s;
    box-shadow: none !important;
}

.peopleai-submit.peopleai-mic-mode .material-symbols-outlined {
    font-size: 24px;
    color: var(--gemini-action-color) !important; /* Mic icon is light grey */
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24 !important;
}

.peopleai-submit.peopleai-mic-mode:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: none !important;
}

/* Recording State (Uses the red pulse) */
.peopleai-submit.recording {
    background: rgba(255, 0, 0, 0.1) !important;
    animation: pulse-mic 1.5s infinite;
}

.peopleai-submit.recording .material-symbols-outlined {
    color: #cc0000 !important;
}

/* --- AI THINKING INDICATOR --- */
.peopleai-assistant.peopleai-thinking .peopleai-bubble {
    color: var(--thinking-color); /* Light yellow/gold */
    font-weight: 500;
}

/* --- ANIMATIONS (PRESERVED) --- */
@keyframes pulse-mic {
    0% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 0, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
}

/* --------------------------------------- */
/* --- MOBILE RESPONSIVENESS (PRESERVED) --- */
/* --------------------------------------- */
@media (max-width: 840px) {
    /* FIX: We ensure the full width is taken, then add the margin on the sides */
    .peopleai-input-area {
        /* Remove max-width and set width to 100% of the screen, then apply margins */
        width: 100%;
        padding: 10px 18px 8px 18px;
        margin-left: 0;
        margin-right: 0;
        /* Use padding on the container itself to create the margin-like effect */
        box-sizing: border-box; /* Crucial: ensures padding is included in the 100% width */
    }
    /* NEW FIX: Create the buffer by adjusting the wrapper's left/right to ensure it doesn't touch the edge */
    .peopleai-widget > .peopleai-input-area {
        width: calc(100% - 32px); /* Use calc to set 16px margin on each side */
        left: 16px;
        transform: translateX(0); /* Remove the 50% transform for fixed left margin */
    }
    .peopleai-results {
        /* Reset scrollbar fix padding for mobile view to prevent layout issues */
        padding-right: 16px;
        margin-right: 0;
        padding-left: 16px;
        padding-right: 16px;
    }
    .peopleai-message {
        max-width: 100%;
    }
}
