/*
PCF Climate Chatbot with News Integration - Modern Green Theme
*/

/* General Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    height: 100dvh; /* better on mobile browsers */
    overflow: hidden;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 290px;
    background-color: var(--sidebar-bg); /* unified */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 18px; /* reduced to show more without scroll */
    transition: width 0.3s ease, padding 0.3s ease, transform 0.3s ease;
    flex-shrink: 0;
    overflow: hidden;
}

/* Mobile overlay that appears when sidebar is open */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-color, rgba(0,0,0,0.5));
    z-index: 90; /* below sidebar (100) but above content */
}

/* Enhanced collapsed sidebar styles */
.sidebar.collapsed {
    width: 0 !important;
    padding: 0 !important;
    border-right: 1px solid transparent;
    overflow: hidden;
}

.sidebar.collapsed * {
    opacity: 0;
    visibility: hidden;
}

/* Mobile sidebar styles */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        width: 280px;
        padding: 18px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }
}

.sidebar > * {
    min-width: 242px; /* 290px - 2*24px padding (kept for layout) */
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 20px; /* reduced */
}

.logo {
    display: flex;
    align-items: center;
    font-size: 22px;
    font-weight: 700;
    color: #2f855a;
    margin-bottom: 8px;
}

.logo i { margin-right: 10px; }

.logo-image {
    width: 32px;
    height: 32px;
    margin-right: 10px;
    object-fit: contain;
    border-radius: 4px;
}

.logo-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-align: left;
    line-height: 1.3;
}

.logo-powered-by {
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: left;
    font-style: italic;
}

.new-chat-btn {
    background-color: #38a169;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px; /* reduced */
    font-size: 15px; /* reduced */
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.3s ease;
    width: 100%;
}

.new-chat-btn:hover { background-color: #2f855a; }

.new-chat-btn i { margin-right: 10px; font-size: 1.1em; }

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.news-section, .complaint-section, .chat-history-section { margin-bottom: 20px; }

.news-section h4, .complaint-section h4, .chat-history-section h4 {
    font-size: 16px; /* reduced */
    font-weight: 700;
    margin-bottom: 12px; /* reduced */
    display: flex;
    align-items: center;
    color: var(--text-primary);
}

.news-section h4 i, .complaint-section h4 i, .chat-history-section h4 i { margin-right: 10px; color: var(--text-secondary); }

/* Chat History Styles */
.chat-history-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

.chat-history-item {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px; /* reduced */
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.chat-history-item:hover { background-color: var(--bg-primary); border-color: var(--border-color); transform: translateY(-1px); }

.chat-history-item.active { background-color: #38a169; color: white; border-color: #2f855a; }

.chat-history-item.active .chat-preview { color: rgba(255, 255, 255, 0.8); }

.chat-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; }

.chat-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }

.chat-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-secondary); }

.chat-history-item.active .chat-meta { color: rgba(255, 255, 255, 0.7); }

.chat-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s ease; }

.chat-history-item:hover .chat-actions { opacity: 1; }

.chat-action-btn { background: none; border: none; padding: 4px; border-radius: 4px; cursor: pointer; color: var(--text-secondary); transition: color 0.2s ease; font-size: 12px; }

.chat-action-btn:hover { color: var(--text-primary); }

.loading-history, .no-history { text-align: center; padding: 16px; color: var(--text-secondary); font-size: 14px; }

.loading-history i { margin-right: 8px; }

.no-history i { display: block; font-size: 24px; margin-bottom: 8px; color: var(--text-secondary); opacity: 0.7; }

.news-btn, .complaint-btn {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px; /* compact */
    font-size: 14px; /* compact */
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 6px; /* compact */
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.news-btn:hover, .complaint-btn:hover { background-color: var(--bg-primary); border-color: var(--border-color); }

.news-btn i, .complaint-btn i { margin-right: 10px; font-size: 1em; }

/* Visual state for disabled news buttons */
.news-btn:disabled,
.news-btn.disabled { cursor: not-allowed; opacity: 0.6; }

.language-selector { margin-bottom: 20px; }

.language-selector label { font-size: 14px; font-weight: 700; display: flex; align-items: center; margin-bottom: 8px; }

.language-selector label i { margin-right: 10px; }

.select-container { position: relative; }

.language-dropdown {
    width: 100%;
    padding: 8px 12px; /* compact */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px; /* compact */
    appearance: none;
}

.select-arrow { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-secondary); }

.sidebar-info { font-size: 13px; color: var(--text-secondary); }

.sidebar-info h4 { font-size: 15px; font-weight: 700; margin-bottom: 12px; }

.user-info { margin-top: 12px; }

.user-badge, .time-badge { display: flex; align-items: center; margin-bottom: 8px; }

.user-badge i, .time-badge i { margin-right: 10px; }

/* Main Content */
.main-content { flex-grow: 1; display: flex; flex-direction: column; background-color: var(--bg-secondary); }

/* Header */
.header {
    position: relative; /* Changed from sticky to relative */
    top: auto; /* Remove fixed top positioning */
    z-index: 10; /* Reduced z-index */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    padding: 12px 16px;
    flex-shrink: 0;
}

/* Mobile-specific refinements to avoid horizontal scroll and keep controls visible */
@media (max-width: 600px) {
    .header { height: auto; padding: 10px 12px; }
    .header h1 { font-size: 18px; text-align: left; margin: 0 0 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .header-actions { gap: 8px; align-items: center; }
    /* Hide verbose language text to save space */
    .header-language, #currentLanguageDisplay { display: none !important; }
    /* Make action buttons icon-only on small screens */
    .header-action-btn { padding: 6px 8px; font-size: 0; }
    .header-action-btn i { font-size: 18px; margin: 0; }
    /* Compact coin badge and redeem button */
    #coinBadge .coin-badge { font-size: 12px; padding: 4px 6px; }
    #coinBadge .header-action-btn { font-size: 0; padding: 6px 8px; }

    .sidebar-toggle { margin-right: 8px; width: 32px; height: 32px; }

    .chat-container { padding: 12px; }
    .input-area { padding: 12px; }

    /* Prevent any stray horizontal overflow inside main app */
    .main-content { overflow-x: hidden; }
}

.header h1 { font-size: 22px; font-weight: 700; color: #2f855a; margin: 0; flex-grow: 1; text-align: center; }

.header-actions { display: flex; align-items: center; gap: 12px; }

.header-language { font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }

/* Header User Status */
.header-user-status { display: flex; align-items: center; }

.header-user-guest,
.header-user-auth {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 !important;           /* prevent oval due to asymmetric padding */
    border-radius: 9999px !important; /* ensure fully rounded regardless of utility order */
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    transition: background-color 0.2s ease;
}

.header-user-guest:hover,
.header-user-auth:hover { background-color: var(--bg-primary); border-color: var(--border-color); }

.header-user-avatar { width: 100%; height: 100%; border-radius: 50%; background-color: #38a169; color: white; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; overflow: hidden; }

.header-user-text { font-size: 14px; font-weight: 500; color: var(--text-primary); }

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    margin-right: 16px; /* reduced */
    color: var(--text-secondary);
    transition: all 0.3s ease;
    padding: 5px;
    width: 34px;
    height: 34px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.sidebar-toggle .bar { display: block; width: 100%; height: 3px; background-color: var(--text-secondary); border-radius: 2px; transition: all 0.3s ease-in-out; }

.sidebar-toggle:hover .bar { background-color: #2f855a; }

.sidebar-toggle.open .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); }

.sidebar-toggle.open .bar:nth-child(2) { opacity: 0; }

.sidebar-toggle.open .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

.chat-container { flex-grow: 1; padding: 24px; overflow-y: auto; overflow-x: hidden; }

.welcome-message { text-align: center; margin-top: 60px; }

.welcome-icon { display: flex; justify-content: center; margin-bottom: 16px; }

.welcome-icon img { width: 80px; height: 80px; object-fit: contain; }

.welcome-message h2 { font-size: 28px; font-weight: 800; margin-bottom: 10px; }

.welcome-message p { font-size: 16px; color: var(--text-secondary); margin-bottom: 24px; }

.example-questions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }

.example-card { background-color: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 10px; padding: 12px 16px; display: flex; align-items: center; cursor: pointer; transition: all 0.2s ease; }

.example-card:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }

.example-card i { margin-right: 10px; color: #38a169; }

.input-area { padding: 24px; border-top: 1px solid var(--border-color); background-color: var(--bg-primary); }

.input-container { display: flex; align-items: center; background-color: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 24px; padding: 8px 16px; }

#voiceButton { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-secondary); transition: color 0.2s ease; }

#voiceButton:hover { color: #38a169; }

#messageInput { flex-grow: 1; border: none; background: none; resize: none; font-size: 17px; padding: 8px; outline: none; max-height: 120px; overflow-y: auto; color: var(--text-primary); }

#sendButton { background: none; border: none; font-size: 22px; cursor: pointer; color: #38a169; transition: color 0.2s ease; }

#sendButton:disabled { color: var(--text-secondary); opacity: 0.6; cursor: not-allowed; }

.input-footer { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 10px; }

/* Messages */
.message {
    display: flex;
    margin-bottom: 20px;
}

.message.user {
    justify-content: flex-end;
}

.message-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 16px;
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Fill bubble avatar without distortion */
    border-radius: 50%;
}

.message.user .message-avatar {
    order: 2;
    margin-left: 16px;
    margin-right: 0;
    background-color: #38a169;
    color: #fff;
}

.message-content {
    max-width: 75%;
    padding: 14px 20px 35px 20px; /* Increased padding-bottom for icons */
    border-radius: 22px;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    position: relative; /* Crucial for absolute positioning of actions */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    word-break: break-word;          /* ensure long words wrap */
    overflow-wrap: anywhere;         /* handle very long URLs */
}

.message.user .message-content {
    background-color: #38a169;
    color: #fff;
    border: none;
}

.message-actions {
    position: absolute;
    bottom: 8px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.message-content:hover .message-actions {
    opacity: 1;
}

.tts-icon, .copy-icon, .edit-icon {
    cursor: pointer;
    color: #a0aec0;
    transition: color 0.3s ease;
    font-size: 1.1em;
}

.tts-icon:hover, .copy-icon:hover, .edit-icon:hover {
    color: #4a5568;
}

.message.user .tts-icon, .message.user .copy-icon, .message.user .edit-icon {
    color: #fff;
}

.tts-icon.disabled {
    cursor: not-allowed;
    color: #cbd5e0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fff;
    border-radius: 12px;
    padding: 32px;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.close-btn {
    background: rgba(15, 23, 42, 0.06); /* slate-800/10 */
    border: 1px solid var(--border-color);
    color: #1f2937; /* slate-800 */
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.close-btn:hover {
    background: rgba(15, 23, 42, 0.12);
}

.close-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35); /* emerald ring */
}

.modal-body input {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    font-size: 16px;
}

.search-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.suggestion-chip {
    background-color: #f7fafc;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.suggestion-chip:hover {
    background-color: #e2e8f0;
}

#executeSearchBtn {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    border: none;
    background-color: #38a169;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#executeSearchBtn:hover {
    background-color: #2f855a;
}

/* Notification */
.notification-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2002; /* Raised above .modal-overlay (1000) to ensure visibility */
}

.notification {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.notification i {
    margin-right: 16px;
    font-size: 24px;
}

.exit-button {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
    border-radius: 12px;
}

/* Highlight */
.highlight {
    background-color: #c6f6d5;
    color: #22543d;
    padding: 2px 4px;
    border-radius: 4px;
}

/* News Article Styling */
.news-articles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.news-article-card {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
}

.news-article-card:hover {
    transform: translateY(-5px);
}

.news-image-container {
    width: 100%;
    height: 180px; /* Fixed height for images */
    overflow: hidden;
    background-color: #f0f4f8; /* Placeholder background */
    display: flex;
    align-items: center;
    justify-content: center;
}

.news-article-image {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cover the container */
    display: block;
}

.news-card-content {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.news-article-title {
    font-size: 1.1em;
    font-weight: 700;
    margin-bottom: 8px;
    color: #2d3748;
    line-height: 1.4;
}

.news-article-meta {
    font-size: 0.85em;
    color: #718096;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.news-article-meta span {
    display: flex;
    align-items: center;
}

.news-article-meta i {
    margin-right: 5px;
    font-size: 0.9em;
}

.news-credibility {
    padding: 3px 8px;
    border-radius: 5px;
    font-weight: 600;
    font-size: 0.75em;
    text-transform: uppercase;
}

.credibility-high {
    background-color: #d4edda;
    color: #155724;
}

.credibility-medium {
    background-color: #fff3cd;
    color: #856404;
}

.credibility-low {
    background-color: #f8d7da;
    color: #721c24;
}

.news-article-summary {
    font-size: 0.95em;
    color: #4a5568;
    line-height: 1.5;
    margin-bottom: 16px;
    flex-grow: 1;
}

.news-article-link {
    display: inline-flex;
    align-items: center;
    color: #38a169;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    transition: color 0.2s ease;
    margin-top: auto; /* Pushes link to the bottom */
}

.news-article-link:hover {
    color: #2f855a;
}

.news-article-link i {
    margin-left: 8px;
    font-size: 0.8em;
}


@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 100;
        background-color: var(--sidebar-bg);
        background-color: var(--bg-primary); /* Fixed: Use defined variable instead of --sidebar-bg */
        -webkit-backdrop-filter: blur(16px);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }
}

.modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

/* Animation for newly added chat */
@keyframes popIn {
    0% { transform: scale(0.95); opacity: 0; }
    60% { transform: scale(1.02); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.chat-history-item.newly-added {
    animation: popIn 300ms ease-out;
    box-shadow: 0 8px 20px rgba(56, 161, 105, 0.25);
    border-color: #38a169;
}

/* Minimal chat history list (title only) */
.chat-history-item .chat-preview,
.chat-history-item .chat-meta {
    display: none;
}

/* Chat edit/delete modals */
.chat-modal {
    position: fixed;
    inset: 0;
    display: none; /* toggled to flex via JS */
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    z-index: 10050;
    padding: 16px;
}

.chat-modal-content {
    width: 100%;
    max-width: 480px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    overflow: hidden;
    animation: modalIn 200ms ease-out;
}

.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.chat-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
}

.chat-modal-close {
    background: rgba(15, 23, 42, 0.06); /* slate-800/10 */
    border: 1px solid var(--border-color);
    color: #1f2937; /* slate-800 */
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.chat-modal-close:hover {
    background: rgba(15, 23, 42, 0.12);
}

.chat-modal-close:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35); /* emerald ring */
}

.chat-modal-body {
    padding: 16px 20px;
}

.chat-modal-body label {
    display: block;
    font-size: 13px;
    color: #718096;
    margin-bottom: 8px;
}

#chatEditInput {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 15px;
}

.chat-modal-hint {
    display: block;
    margin-top: 8px;
    color: #a0aec0;
    font-size: 12px;
}

.chat-modal-warning {
    display: block;
    margin-top: 12px;
    color: #b45309; /* amber-700 */
    font-size: 12px;
}

.chat-delete-preview {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f7fafc;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: #4a5568;
    font-size: 14px;
}

.chat-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px 20px;
}

.chat-btn {
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.05s ease, filter 0.2s ease;
}

.chat-btn:active { transform: translateY(1px); }

.chat-btn.primary { background: #38a169; color: #fff; }
.chat-btn.primary:hover { filter: brightness(0.95); }

.chat-btn.secondary { background: #edf2f7; color: #2d3748; }
.chat-btn.secondary:hover { filter: brightness(0.98); }

.chat-btn.danger { background: #ef4444; color: #fff; }
.chat-btn.danger:hover { filter: brightness(0.95); }

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

/* Global mobile and layout safeguards */
html { width: 100%; max-width: 100%; overflow-x: hidden; }
*, *::before, *::after { box-sizing: border-box; }
img, video { max-width: 100%; height: auto; }

/* Ensure flex children can shrink without causing overflow */
.app-container, .main-content, .header, .chat-container, .input-area { min-width: 0; }

/* Consistent avatar image styling */
#headerUserAvatar img, #sidebarUserAvatar img, .avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover; /* Fill container while preserving aspect ratio */
    object-position: center;
    display: block;
    background-color: transparent;
}

/* Ensure avatar containers are circular and clip overflow */
#headerUserAvatar, #sidebarUserAvatar { border-radius: 50%; overflow: hidden; display: block; }

/* Transparent background when an image is present */
#headerUserAvatar.has-img, #sidebarUserAvatar.has-img, .header-user-avatar.has-img {
    background-color: transparent !important;
}

.example-questions {
    display: grid !important; /* override previous flex */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px; /* keep existing spacing */
    max-width: 640px; /* centers nicely */
    margin: 0 auto; /* center within welcome section */
}
.example-card {
    width: 100%; /* full width inside grid cell */
    justify-content: flex-start; /* align content */
}
@media (max-width: 520px) {
    .example-questions { grid-template-columns: 1fr; }
}
/* --- End added block --- */
