/* ── INCOR AI Chat Widget ── */

.incor-ai {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 2147483647;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Bubble ── */
.incor-ai__bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00502F, #007A45);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 80, 47, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.incor-ai__bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 80, 47, 0.5);
}

.incor-ai__icon,
.incor-ai__close {
    width: 28px;
    height: 28px;
    transition: opacity 0.2s, transform 0.2s;
    position: absolute;
}

.incor-ai__close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.incor-ai--open .incor-ai__icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.incor-ai--open .incor-ai__close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* ── Window ── */
.incor-ai__window {
    position: absolute;
    bottom: 72px;
    left: 0;
    width: 370px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

.incor-ai--open .incor-ai__window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ── */
.incor-ai__header {
    background: linear-gradient(135deg, #00502F, #007A45);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.incor-ai__header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.incor-ai__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.incor-ai__header-info strong {
    display: block;
    font-size: 15px;
}

.incor-ai__status {
    font-size: 12px;
    opacity: 0.85;
}

.incor-ai__close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.incor-ai__close-btn:hover {
    opacity: 1;
}

.incor-ai__close-btn svg {
    width: 20px;
    height: 20px;
}

/* ── Messages ── */
.incor-ai__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.incor-ai__msg {
    display: flex;
    max-width: 85%;
}

.incor-ai__msg--user {
    align-self: flex-end;
}

.incor-ai__msg--bot {
    align-self: flex-start;
}

.incor-ai__msg-content {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.incor-ai__msg--user .incor-ai__msg-content {
    background: #00502F;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.incor-ai__msg--bot .incor-ai__msg-content {
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.incor-ai__msg-content a {
    color: #FFC425;
    text-decoration: underline;
}

.incor-ai__msg--user .incor-ai__msg-content a {
    color: #FFC425;
}

/* ── Rich content inside bot messages ── */
.incor-ai__msg-content p { margin: 0 0 8px; }
.incor-ai__msg-content p:last-child { margin-bottom: 0; }
.incor-ai__msg-content ul,
.incor-ai__msg-content ol { margin: 0 0 8px; padding-left: 20px; }
.incor-ai__msg-content li { margin: 3px 0; }
.incor-ai__msg-content h3,
.incor-ai__msg-content h4,
.incor-ai__msg-content h5,
.incor-ai__msg-content h6 { margin: 6px 0 4px; font-size: 14px; font-weight: 700; }
.incor-ai__msg-content code {
    background: #f1f1f4;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    font-family: Consolas, Monaco, monospace;
}

/* ── Tables ── */
.incor-ai__table {
    border-collapse: collapse;
    width: 100%;
    margin: 6px 0 8px;
    font-size: 13px;
}
.incor-ai__table th,
.incor-ai__table td {
    border: 1px solid #e5e7eb;
    padding: 6px 9px;
    text-align: left;
    vertical-align: top;
}
.incor-ai__table th {
    background: #e8f5e9;
    font-weight: 700;
}
.incor-ai__table tbody tr:nth-child(even) {
    background: #fafbfc;
}

/* ── Typing indicator ── */
.incor-ai__typing {
    padding: 8px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
    background: #f8f9fa;
}

.incor-ai__typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: incor-ai-bounce 1.4s infinite both;
}

.incor-ai__typing span:nth-child(2) { animation-delay: 0.16s; }
.incor-ai__typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes incor-ai-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Input ── */
.incor-ai__input-area {
    display: flex;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

.incor-ai__input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.incor-ai__input:focus {
    border-color: #00502F;
}

.incor-ai__send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #00502F;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.incor-ai__send:hover {
    background: #003D24;
}

.incor-ai__send svg {
    width: 18px;
    height: 18px;
}

.incor-ai__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── WhatsApp fallback ── */
.incor-ai__fallback {
    text-align: center;
    padding: 20px;
}

.incor-ai__fallback p {
    margin: 0 0 16px;
    color: #6b7280;
    font-size: 14px;
}

.incor-ai__fallback-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #25D366;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.incor-ai__fallback-btn:hover {
    background: #1ebe57;
}

.incor-ai__fallback-btn svg {
    width: 20px;
    height: 20px;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .incor-ai {
        bottom: 16px;
        left: 16px;
    }

    .incor-ai__window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        bottom: 68px;
    }

    .incor-ai__bubble {
        width: 54px;
        height: 54px;
    }
}

/* ── Scrollbar ── */
.incor-ai__messages::-webkit-scrollbar {
    width: 5px;
}

.incor-ai__messages::-webkit-scrollbar-track {
    background: transparent;
}

.incor-ai__messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ── Gate form ── */
.incor-ai__gate {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    background: #f8f9fa;
}

.incor-ai__gate-inner {
    width: 100%;
    max-width: 280px;
    text-align: center;
}

.incor-ai__gate-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #00502F, #007A45);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.incor-ai__gate-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
}

.incor-ai__gate-subtitle {
    margin: 0 0 20px;
    font-size: 13px;
    color: #6b7280;
}

.incor-ai__gate-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.incor-ai__gate-field {
    text-align: left;
}

.incor-ai__gate-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}

.incor-ai__gate-field input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    box-sizing: border-box;
}

.incor-ai__gate-field input:focus {
    border-color: #00502F;
    box-shadow: 0 0 0 2px rgba(0, 80, 47, 0.1);
}

.incor-ai__gate-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #00502F, #007A45);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 4px;
}

.incor-ai__gate-submit:hover {
    opacity: 0.9;
}
