/* ai-chat.css - AI Chat Assistant styling */

/* ==================== AI CHAT NAV ICON (header navbar) ==================== */
#aiChatFab {
    color: #1E6332 !important;
    text-decoration: none !important;
}

#aiChatFab:hover {
    color: #146c43 !important;
}

.ai-chat-nav-badge {
    position: absolute;
    top: -2px;
    right: -6px;
    background: #0d6efd;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    font-family: 'Futura PT', 'Jost', sans-serif;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    border-radius: 6px;
    z-index: 2;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* Buzz animation when response arrives while panel is closed */
#aiChatFab.ai-chat-fab-buzz {
    animation: aiChatBuzz 0.4s ease-in-out 3;
}

@keyframes aiChatBuzz {
    0% { transform: rotate(0deg); }
    15% { transform: rotate(-8deg); }
    30% { transform: rotate(8deg); }
    45% { transform: rotate(-5deg); }
    60% { transform: rotate(5deg); }
    75% { transform: rotate(-2deg); }
    100% { transform: rotate(0deg); }
}

/* ==================== BACKDROP ==================== */
.ai-chat-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 9989;
    animation: aiChatFadeIn 0.2s ease-out;
}

@keyframes aiChatFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==================== CHAT PANEL ==================== */
.ai-chat-panel {
    position: fixed;
    bottom: 44px;
    right: 24px;
    width: 420px;
    height: 80vh;
    max-height: calc(100vh - 60px);
    max-height: calc(100dvh - 60px);
    background: #fff;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0,0,0,0.03);
    z-index: 9992;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Futura PT', 'Jost', sans-serif;
    animation: aiChatSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes aiChatSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-chat-panel.closing {
    animation: aiChatSlideDown 0.25s ease-in forwards;
}

@keyframes aiChatSlideDown {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(20px) scale(0.97); }
}

/* ==================== HEADER ==================== */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, #1E6332 0%, #214A3E 100%);
    color: #fff;
    flex-shrink: 0;
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    backdrop-filter: blur(4px);
}

.ai-chat-header-title {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.2px;
}

.ai-chat-header-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #18A74B;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}

.ai-chat-header-actions {
    display: flex;
    gap: 6px;
}

.ai-chat-header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.ai-chat-header-btn:hover {
    background: rgba(255,255,255,0.28);
}

/* ==================== END CONVERSATION BAR ==================== */
.ai-chat-end-bar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: center;
    margin: -12px -14px 0 -14px;
    padding: 8px 14px 6px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.ai-chat-end-bar button {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 11px;
    font-family: 'Futura PT', 'Jost', sans-serif;
    padding: 4px 14px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-chat-end-bar button:hover {
    background: #fff5f5;
    border-color: #f5c2c7;
    color: #dc3545;
}

.ai-chat-end-bar button i {
    font-size: 10px;
}

/* ==================== MESSAGES AREA ==================== */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.ai-chat-messages::-webkit-scrollbar { width: 5px; }
.ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: #dee2e6; border-radius: 3px; }
.ai-chat-messages::-webkit-scrollbar-thumb:hover { background: #adb5bd; }

/* ==================== MESSAGE BUBBLES ==================== */
.ai-chat-msg {
    display: flex;
    gap: 10px;
    max-width: 92%;
    animation: aiMsgFadeIn 0.3s ease-out;
}

@keyframes aiMsgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-chat-msg.assistant {
    align-self: flex-start;
}

.ai-chat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
}

.ai-chat-msg.user .ai-chat-msg-avatar {
    background: linear-gradient(135deg, #1E6332, #214A3E);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    font-family: 'Futura PT', 'Jost', sans-serif;
}

/* Profile picture avatar */
.ai-chat-msg-avatar-img {
    padding: 0;
    overflow: hidden;
    background: none !important;
}

.ai-chat-msg-avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.ai-chat-msg-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1E6332, #214A3E);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    font-family: 'Futura PT', 'Jost', sans-serif;
    border-radius: 50%;
}

.ai-chat-msg.assistant .ai-chat-msg-avatar {
    background: linear-gradient(135deg, #1E6332, #2F8542);
    color: #fff;
}

.ai-chat-msg-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
}

.ai-chat-msg.user .ai-chat-msg-bubble {
    background: #1E6332;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble {
    background: #f8f9fa;
    color: #212529;
    border: 1px solid #eee;
    border-bottom-left-radius: 4px;
}

/* ==================== WELCOME MESSAGE ==================== */
.ai-chat-welcome {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 6px;
    text-align: left;
}

.ai-chat-welcome-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1E6332, #2F8542);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(30, 99, 50, 0.2);
}

.ai-chat-welcome-text h4 {
    font-size: 14px;
    font-weight: 600;
    color: #212529;
    margin: 0 0 1px;
}

.ai-chat-welcome-text p {
    font-size: 11.5px;
    color: #6c757d;
    margin: 0;
    line-height: 1.35;
}

/* ==================== SUGGESTED PROMPTS ==================== */
.ai-chat-prompts-section {
    padding: 4px 0 0;
}

.ai-chat-prompts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    padding: 0 2px;
}

.ai-chat-prompts-title {
    font-size: 10.5px;
    font-weight: 600;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.ai-chat-prompts-refresh {
    background: none;
    border: none;
    color: #adb5bd;
    font-size: 12px;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 6px;
    transition: all 0.2s;
}

.ai-chat-prompts-refresh:hover {
    color: #1E6332;
    background: #f0fff4;
}

.ai-chat-prompt-cards {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-chat-prompt-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.ai-chat-prompt-card:hover {
    border-color: #1E6332;
    background: #f0fff4;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(30, 99, 50, 0.08);
}

.ai-chat-prompt-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.ai-chat-prompt-icon.analytics { background: #e7f1ff; color: #0d6efd; }
.ai-chat-prompt-icon.reports { background: #fce4e4; color: #dc3545; }
.ai-chat-prompt-icon.support { background: #F4F0E9; color: #1E6332; }
.ai-chat-prompt-icon.industry { background: #fff3cd; color: #cc9a06; }

.ai-chat-prompt-text {
    font-size: 12.5px;
    color: #495057;
    line-height: 1.35;
}

/* ==================== THINKING INDICATOR ==================== */
.ai-chat-thinking-text {
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 4px 6px;
    font-size: 13px;
    color: #6c757d;
    font-style: italic;
}

.ai-chat-thinking-phrase {
    opacity: 0.85;
}

.ai-chat-thinking-dots span {
    animation: aiThinkingDot 1.4s infinite ease-in-out;
    opacity: 0;
    font-weight: 700;
    font-size: 16px;
}

.ai-chat-thinking-dots span:nth-child(1) { animation-delay: 0s; }
.ai-chat-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiThinkingDot {
    0%, 60%, 100% { opacity: 0; }
    30% { opacity: 1; }
}

/* ==================== INPUT AREA ==================== */
.ai-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    flex-shrink: 0;
}

.ai-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f8f9fa;
    border: 1.5px solid #dee2e6;
    border-radius: 14px;
    padding: 6px 6px 6px 16px;
    transition: all 0.2s;
}

.ai-chat-input-wrap:focus-within {
    border-color: #1E6332;
    box-shadow: 0 0 0 3px rgba(30, 99, 50, 0.08);
    background: #fff;
}

.ai-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: 'Futura PT', 'Jost', sans-serif;
    font-size: 14px;
    color: #212529;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.5;
    padding: 5px 0;
}

.ai-chat-input::placeholder {
    color: #adb5bd;
}

.ai-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #1E6332, #2F8542);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(30, 99, 50, 0.3);
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-chat-input-hint {
    display: flex;
    justify-content: space-between;
    padding: 5px 6px 0;
    font-size: 10px;
    color: #c4c9ce;
}

/* ==================== CHART CONTAINER ==================== */
.ai-chat-chart-wrap {
    margin: 10px 0 4px;
    padding: 14px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
}

.ai-chat-chart-wrap canvas {
    max-height: 200px;
}

/* ==================== EXPORT BAR ==================== */
.ai-chat-export-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
}

.ai-chat-export-label {
    font-size: 10px;
    color: #adb5bd;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-chat-export-label i {
    font-size: 10px;
}

.ai-chat-export-btns {
    display: flex;
    gap: 4px;
}

.ai-chat-export-btns button {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 10.5px;
    font-family: 'Futura PT', 'Jost', sans-serif;
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-chat-export-btns button:hover {
    background: #e9ecef;
    border-color: #ced4da;
    color: #212529;
}

.ai-chat-export-btns button.success {
    background: #F4F0E9;
    border-color: #badbcc;
    color: #1E6332;
}

.ai-chat-export-btns button:first-child {
    background: #fff0f0;
    border-color: #fdd;
    color: #dc3545;
}

.ai-chat-export-btns button:first-child:hover {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

.ai-chat-export-btns button i {
    font-size: 10px;
}

/* Locked export (IC data protection) */
.ai-chat-export-locked {
    width: 100%;
}

.ai-chat-export-locked-header {
    font-size: 11px;
    font-weight: 700;
    color: #dc3545;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.ai-chat-export-locked-header i {
    font-size: 11px;
}

.ai-chat-export-locked-fields {
    font-size: 10.5px;
    color: #6c757d;
    margin-bottom: 4px;
    line-height: 1.4;
}

.ai-chat-export-locked-fields strong {
    color: #495057;
}

.ai-chat-export-locked-hint {
    font-size: 10px;
    color: #adb5bd;
    line-height: 1.35;
    margin-bottom: 6px;
}

.ai-chat-export-locked-actions {
    display: flex;
}

.ai-chat-export-regen-btn {
    background: #fff5f5;
    border: 1px solid #f5c2c7;
    color: #dc3545;
    font-size: 10.5px;
    font-family: 'Futura PT', 'Jost', sans-serif;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.ai-chat-export-regen-btn:hover {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

.ai-chat-export-regen-btn i {
    font-size: 10px;
}

/* ==================== MARKDOWN IN ASSISTANT BUBBLES ==================== */
.ai-chat-msg.assistant .ai-chat-msg-bubble p {
    margin: 0 0 8px;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble p:last-child {
    margin-bottom: 0;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble h3 {
    font-size: 14px;
    font-weight: 700;
    color: #1E6332;
    margin: 14px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e9ecef;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble h3:first-child {
    margin-top: 0;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble h4 {
    font-size: 13px;
    font-weight: 600;
    color: #212529;
    margin: 10px 0 4px;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble ul,
.ai-chat-msg.assistant .ai-chat-msg-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble li {
    margin-bottom: 3px;
    font-size: 13px;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble code {
    background: #e9ecef;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    overflow-x: auto;
    margin: 8px 0;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12px;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble th {
    background: #f0fff4;
    padding: 7px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #1E6332;
    font-size: 11px;
    color: #1E6332;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble tr:hover td {
    background: #fafffe;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble strong {
    color: #1E6332;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble hr {
    border: none;
    border-top: 1px solid #e9ecef;
    margin: 10px 0;
}

/* ==================== LONG CONTENT TRUNCATION ==================== */
.ai-chat-bubble-inner {
    /* wrapper inside bubble for collapsible content */
}

.ai-chat-bubble-collapsed {
    overflow: hidden;
    position: relative;
}

.ai-chat-bubble-collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(transparent, #f0f4f0);
    pointer-events: none;
}

.ai-chat-show-more-bar {
    text-align: center;
    padding-top: 8px;
}

.ai-chat-show-more-bar button {
    background: none;
    border: 1.5px solid #dee2e6;
    color: #1E6332;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Futura PT', 'Jost', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chat-show-more-bar button:hover {
    background: #F4F0E9;
    border-color: #1E6332;
}

.ai-chat-truncated-notice {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 11.5px;
    color: #6d5600;
    margin-top: 6px;
    line-height: 1.4;
}

.ai-chat-truncated-notice i {
    color: #f9a825;
}

/* ==================== INTERACTIVE PROMPT CARDS ==================== */
.ai-chat-prompt-form {
    margin-top: 12px;
    border-top: 1px solid #e9ecef;
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-chat-prompt-form-submitted {
    opacity: 0.6;
    pointer-events: none;
}

.ai-chat-prompt-qcard {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    transition: all 0.2s;
}

.ai-chat-prompt-qcard:hover {
    border-color: #c6d0dc;
}

.ai-chat-prompt-qcard-shake {
    animation: aiPromptShake 0.4s ease-in-out;
}

@keyframes aiPromptShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

.ai-chat-prompt-qheader {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

.ai-chat-prompt-qnum {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    transition: all 0.3s;
}

.ai-chat-prompt-qnum.answered {
    background: #1E6332;
    color: #fff;
}

.ai-chat-prompt-qtext {
    font-size: 13px;
    font-weight: 600;
    color: #212529;
    line-height: 1.4;
    padding-top: 1px;
}

.ai-chat-prompt-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 30px;
}

.ai-chat-prompt-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 1.5px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: 'Futura PT', 'Jost', sans-serif;
    width: 100%;
}

.ai-chat-prompt-option:hover {
    background: #f0fff4;
    border-color: #a3d9b1;
}

.ai-chat-prompt-option.selected {
    background: #F4F0E9;
    border-color: #1E6332;
    box-shadow: 0 0 0 1px rgba(30, 99, 50, 0.15);
}

.ai-chat-prompt-option.recommended {
    border-color: #c3e6cb;
    background: #f8fff9;
}

.ai-chat-prompt-option.recommended:hover {
    background: #e8f5e9;
}

.ai-chat-prompt-opt-radio {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 50%;
    border: 2px solid #ced4da;
    margin-top: 1px;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}

.ai-chat-prompt-option.selected .ai-chat-prompt-opt-radio {
    border-color: #1E6332;
    background: #1E6332;
}

.ai-chat-prompt-option.selected .ai-chat-prompt-opt-radio::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
}

.ai-chat-prompt-opt-content {
    flex: 1;
    min-width: 0;
}

.ai-chat-prompt-opt-label {
    font-size: 12.5px;
    font-weight: 600;
    color: #212529;
    display: inline;
}

.ai-chat-prompt-opt-rec {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    color: #1E6332;
    background: #F4F0E9;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    vertical-align: middle;
}

.ai-chat-prompt-opt-desc {
    display: block;
    font-size: 11px;
    color: #6c757d;
    line-height: 1.35;
    margin-top: 2px;
}

/* Other option */
.ai-chat-prompt-other {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ai-chat-prompt-option-other {
    border-style: dashed;
    background: #fff;
}

.ai-chat-prompt-option-other:hover {
    border-style: dashed;
}

.ai-chat-prompt-option-other.selected {
    border-style: solid;
}

.ai-chat-prompt-other-input {
    margin-top: 4px;
    margin-left: 26px;
    padding: 8px 12px;
    font-size: 12.5px;
    font-family: 'Futura PT', 'Jost', sans-serif;
    border: 1.5px solid #ced4da;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s;
    color: #212529;
    background: #fff;
}

.ai-chat-prompt-other-input:focus {
    border-color: #1E6332;
    box-shadow: 0 0 0 3px rgba(30, 99, 50, 0.08);
}

.ai-chat-prompt-input-shake {
    animation: aiPromptShake 0.4s ease-in-out;
    border-color: #dc3545 !important;
}

/* Submit row */
.ai-chat-prompt-submit-row {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

.ai-chat-prompt-submit {
    background: linear-gradient(135deg, #1E6332, #2F8542);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 600;
    font-family: 'Futura PT', 'Jost', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(30, 99, 50, 0.2);
}

.ai-chat-prompt-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(30, 99, 50, 0.3);
}

.ai-chat-prompt-submit:disabled {
    background: #F4F0E9;
    color: #1E6332;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.ai-chat-prompt-submit i {
    font-size: 11px;
}

/* ==================== EXPANDED MODE ==================== */
.ai-chat-panel {
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-panel.expanded {
    width: min(900px, calc(100vw - 60px));
    height: calc(100dvh - 80px);
    max-height: calc(100dvh - 80px);
    bottom: 30px;
    right: 30px;
}

@media (min-width: 1400px) {
    .ai-chat-panel.expanded {
        width: 1000px;
    }
}

.ai-chat-panel.expanded .ai-chat-msg {
    max-width: 80%;
}

.ai-chat-panel.expanded .ai-chat-chart-wrap canvas {
    max-height: 300px;
}

/* ==================== RECENT CONVERSATIONS (Welcome Screen) ==================== */
.ai-chat-recent-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.ai-chat-recent-header {
    font-size: 10.5px;
    font-weight: 600;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
    padding: 0 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-chat-recent-header i {
    font-size: 10px;
}

.ai-chat-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-chat-recent-item:hover {
    background: #f0fff4;
}

.ai-chat-recent-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #6c757d;
    flex-shrink: 0;
}

.ai-chat-recent-content {
    flex: 1;
    min-width: 0;
}

.ai-chat-recent-title {
    font-size: 12.5px;
    color: #343a40;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-recent-meta {
    font-size: 10.5px;
    color: #adb5bd;
    margin-top: 1px;
}

.ai-chat-recent-more {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: #1E6332;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ai-chat-recent-more:hover {
    background: #f0fff4;
}

/* ==================== CONVERSATION HISTORY VIEW ==================== */
.ai-chat-history-view {
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-chat-history-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.ai-chat-history-top h4 {
    font-size: 14px;
    font-weight: 600;
    color: #212529;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-history-top h4 i {
    color: #1E6332;
    font-size: 14px;
}

.ai-chat-history-back {
    background: #f0f0f0;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 13px;
    transition: all 0.2s;
}

.ai-chat-history-back:hover {
    background: #e9ecef;
    color: #212529;
}

.ai-chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.ai-chat-history-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px;
    border-radius: 10px;
    transition: background 0.2s;
}

.ai-chat-history-item:hover {
    background: #f8f9fa;
}

.ai-chat-history-item.active {
    background: #f0fff4;
}

.ai-chat-history-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    padding: 10px;
    cursor: pointer;
    border-radius: 8px;
    min-width: 0;
}

.ai-chat-history-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #6c757d;
    flex-shrink: 0;
}

.ai-chat-history-item.active .ai-chat-history-item-icon {
    background: #F4F0E9;
    color: #1E6332;
}

.ai-chat-history-item-content {
    flex: 1;
    min-width: 0;
}

.ai-chat-history-item-title {
    font-size: 13px;
    color: #343a40;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-history-item-meta {
    font-size: 11px;
    color: #adb5bd;
    margin-top: 2px;
}

.ai-chat-history-item-delete {
    background: none;
    border: none;
    color: #dee2e6;
    font-size: 12px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-chat-history-item-delete:hover {
    color: #dc3545;
    background: #fff5f5;
}

.ai-chat-history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #adb5bd;
}

.ai-chat-history-empty i {
    font-size: 36px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}

.ai-chat-history-empty p {
    margin: 0 0 4px;
    font-size: 14px;
}

.ai-chat-history-empty p.small {
    font-size: 12px;
    opacity: 0.7;
}

/* ==================== IMPERSONATING OFFSET ==================== */
body.impersonating .ai-chat-panel {
    bottom: 76px;
    max-height: calc(100dvh - 92px);
}

/* ==================== MOBILE RESPONSIVE ==================== */
/* Note: Full mobile overrides are in mobile.css (@media max-width: 768px).
   This section handles the intermediate range (577px–768px) as a fallback. */
@media (max-width: 768px) {
    .ai-chat-panel,
    .ai-chat-panel.expanded {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
    }
}
