/* =====================================================
   Avi HRP — AI Chat Widget (Phase C)
   Navy theme, compact footprint
   ===================================================== */

:root {
    --chat-accent: #22d3ee;
    --chat-accent-dark: #0891b2;
    --chat-header-bg: linear-gradient(135deg, #0a0e27 0%, #0d1b3e 45%, #137865 100%);
}

.chat-widget {
    position: fixed;
    bottom: 76px;
    inset-inline-end: 20px;
    width: 320px;
    height: 460px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(10, 14, 39, 0.28);
    background: #fff;
    display: none;
    flex-direction: column;
    z-index: 1050;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.chat-widget.active {
    display: flex;
}

.chat-header {
    background: var(--chat-header-bg);
    color: #fff;
    padding: 10px 14px;
    min-height: 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h5 {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.3;
}

.chat-header .btn-close {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.95;
    padding: 0;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chat-header .btn-close:hover {
    background: rgba(255, 255, 255, 0.22);
    opacity: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    display: flex;
    animation: chatSlideIn 0.3s ease-in;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 82%;
    padding: 8px 12px;
    border-radius: 14px;
    word-wrap: break-word;
    line-height: 1.45;
    font-size: 0.85rem;
}

.message.user .message-content {
    background: var(--chat-accent-dark);
    color: #fff;
    border-radius: 14px 14px 4px 14px;
}

.message.assistant .message-content {
    background: #fff;
    color: #334155;
    border-radius: 4px 14px 14px 14px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ai-progress-container {
    padding: 10px 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 10px;
    margin: 8px 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.ai-progress-text {
    font-size: 0.78rem;
    color: #475569;
    margin-bottom: 6px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-progress-bar {
    height: 6px;
    background: #cbd5e1;
    border-radius: 3px;
    overflow: hidden;
}

.ai-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--chat-accent-dark), var(--chat-accent), var(--chat-accent-dark));
    background-size: 200% 100%;
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
    animation: chatProgressShimmer 1.5s infinite linear;
}

@keyframes chatProgressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.typing-indicator {
    display: none;
    gap: 5px;
    padding: 10px 12px;
    align-items: center;
}

.typing-indicator.active {
    display: flex;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: chatTyping 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-6px); }
}

@keyframes chatSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--chat-accent);
}

.chat-input-area button {
    background: var(--chat-accent-dark);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
    transition: background 0.2s;
}

.chat-input-area button:hover {
    background: #0e7490;
}

.chat-input-area button:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.chat-toggle-btn {
    position: fixed;
    bottom: 16px;
    inset-inline-end: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--chat-header-bg);
    color: #fff;
    border: 2px solid rgba(34, 211, 238, 0.35);
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(10, 14, 39, 0.35);
    z-index: 1040;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(10, 14, 39, 0.45);
}

.chat-toggle-btn:active {
    transform: scale(0.96);
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: #f1f5f9; }
.chat-messages::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Language selection — compact */
.language-selection {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #f8fafc;
}

.language-selection-content {
    text-align: center;
    width: 100%;
}

.language-selection-content h6 {
    margin-bottom: 14px;
    color: #334155;
    font-size: 0.88rem;
    font-weight: 600;
}

.language-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.lang-btn {
    background: #fff;
    border: 1.5px solid var(--chat-accent-dark);
    border-radius: 10px;
    padding: 10px 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 110px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--chat-accent-dark);
}

.lang-btn:hover {
    background: var(--chat-accent-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(8, 145, 178, 0.25);
}

.lang-btn .flag {
    font-size: 0.75rem;
    font-weight: 800;
    opacity: 0.85;
}

/* Default questions */
.default-questions {
    padding: 10px 12px;
    background: linear-gradient(to bottom, #f8fafc 0%, #fff 100%);
    border-top: 1px solid #e2e8f0;
    max-height: 160px;
    overflow-y: auto;
}

.default-questions h6 {
    margin: 0 0 10px 0;
    font-size: 0.78rem;
    color: var(--chat-accent-dark);
    font-weight: 600;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.default-questions .questions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.question-chip {
    display: inline-block;
    background: #fff;
    border: 1.5px solid var(--chat-accent-dark);
    border-radius: 20px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--chat-accent-dark);
    transition: all 0.2s ease;
    font-weight: 500;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.question-chip:hover {
    background: var(--chat-accent-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.25);
}

.question-chip:active {
    transform: translateY(0) scale(0.98);
}

.chat-tool-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--chat-accent-dark, #0891b2);
    background: rgba(8, 145, 178, 0.12);
    border-radius: 4px;
    padding: 2px 8px;
    margin-bottom: 6px;
}

@media (max-width: 480px) {
    .chat-widget {
        width: calc(100vw - 24px);
        inset-inline-end: 12px;
        bottom: 70px;
        height: 420px;
    }
}
