/* Lahint Copilot Chat Widget */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #006C35, #004D26);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 108, 53, 0.4);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0, 108, 53, 0.5); }
[dir="ltr"] .chat-fab { right: auto; left: 24px; }

.chat-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 400px;
    max-height: 70vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 9001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}
.chat-panel.open { display: flex; }
[dir="ltr"] .chat-panel { right: auto; left: 24px; }

.chat-header {
    background: linear-gradient(135deg, #006C35, #004D26);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95rem;
}
.chat-header-actions { display: flex; gap: 8px; }
.chat-header-actions button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-header-actions button:hover { background: rgba(255,255,255,0.25); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 300px;
    max-height: calc(70vh - 130px);
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.6;
    word-wrap: break-word;
}
.chat-msg.user {
    align-self: flex-end;
    background: #006C35;
    color: #fff;
    border-bottom-right-radius: 4px;
}
[dir="ltr"] .chat-msg.user { border-bottom-right-radius: 12px; border-bottom-left-radius: 4px; }
.chat-msg.assistant {
    align-self: flex-start;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}
[dir="ltr"] .chat-msg.assistant { border-bottom-left-radius: 12px; border-bottom-right-radius: 4px; }
.chat-msg.assistant .source {
    margin-top: 8px;
    font-size: 0.7rem;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
    padding-top: 4px;
}

/* Structured cards */
.chat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    margin-top: 8px;
}
.chat-card-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 10px;
    color: #374151;
}
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chat-option-btn {
    padding: 6px 14px;
    border: 1px solid #006C35;
    background: #fff;
    color: #006C35;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.15s;
}
.chat-option-btn:hover { background: #006C35; color: #fff; }
.chat-confirm-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
}
.chat-confirm-btn.confirm { background: #006C35; color: #fff; }
.chat-confirm-btn.cancel { background: #f3f4f6; color: #6b7280; }

.chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
}
.chat-chip {
    padding: 6px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #006C35;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    transition: all 0.15s;
}
.chat-chip:hover { background: #006C35; color: #fff; }

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}
.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    background: #fff;
}
.chat-input:focus { border-color: #006C35; }
.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #006C35;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}
.chat-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: chatBounce 1.4s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.16s; }
.chat-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes chatBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Mic Button */
.chat-mic-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f3f4f6;
    color: #374151;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.chat-mic-btn:hover { background: #e5e7eb; }
.chat-mic-btn.recording {
    background: #ef4444;
    color: #fff;
    animation: micPulse 1.5s infinite;
}
@keyframes micPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* Speaker Button */
.chat-speaker-btn {
    padding: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
    border-radius: 4px;
    color: inherit;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.chat-speaker-btn:hover { opacity: 1; background: rgba(0,0,0,0.05); }
.chat-speaker-btn.playing { opacity: 1; color: #006C35; }

/* Audio toggle in header */
.chat-audio-toggle {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.chat-audio-toggle:hover { background: rgba(255,255,255,0.25); }
.chat-audio-toggle.active { background: rgba(255,255,255,0.3); }

@media (max-width: 500px) {
    .chat-panel { width: calc(100vw - 20px); right: 10px; bottom: 80px; }
    [dir="ltr"] .chat-panel { left: 10px; right: auto; }
}
