/**
 * CH Chat Assistant - Frontend Widget Styles
 * ConstructionHands.com black/white branding
 * © 2026 Construction Jobs, Inc. — Proprietary
 */

/* ===== Chat Launcher Button ===== */
.chca-launcher {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1a1a1a;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 0;
}
.chca-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}
.chca-launcher svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}
.chca-launcher.left {
    right: auto;
    left: 24px;
}
.chca-launcher .chca-badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc2626;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ===== Chat Window ===== */
.chca-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    z-index: 2147483647;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.chca-window.open {
    display: flex;
    animation: chcaSlideUp 0.3s ease-out;
}
.chca-window.left {
    right: auto;
    left: 24px;
}

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

/* ===== Header ===== */
.chca-header {
    background: #1a1a1a;
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chca-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chca-header-avatar {
    width: 36px;
    height: 36px;
    background: #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chca-header-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}
.chca-header-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}
.chca-header-info span {
    font-size: 11px;
    color: #aaa;
}
.chca-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    font-size: 20px;
    line-height: 1;
    opacity: 0.7;
}
.chca-header-close:hover {
    opacity: 1;
}

/* ===== Messages Area ===== */
.chca-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: calc(100vh - 280px);
    background: #f9fafb;
}

/* Message Bubbles */
.chca-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: chcaFadeIn 0.2s ease-out;
}
@keyframes chcaFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chca-msg.user {
    align-self: flex-end;
    background: #1a1a1a;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chca-msg.assistant {
    align-self: flex-start;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.chca-msg.system {
    align-self: center;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 12px;
    border-radius: 8px;
    text-align: center;
}

/* Links in messages */
.chca-msg.assistant a {
    color: #1a1a1a;
    font-weight: 600;
    text-decoration: underline;
}

/* Typing indicator */
.chca-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.chca-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: chcaBounce 1.4s infinite ease-in-out;
}
.chca-typing span:nth-child(1) { animation-delay: -0.32s; }
.chca-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes chcaBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ===== CSAT Feedback ===== */
.chca-csat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    margin-top: 4px;
}
.chca-csat button {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.chca-csat button:hover {
    background: #f3f4f6;
}
.chca-csat button.selected {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}
.chca-csat-label {
    font-size: 11px;
    color: #9ca3af;
}

/* ===== Input Area ===== */
.chca-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.chca-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chca-input-row textarea {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}
.chca-input-row textarea:focus {
    border-color: #1a1a1a;
}
.chca-input-row textarea::placeholder {
    color: #9ca3af;
}
.chca-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1a1a1a;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}
.chca-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.chca-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* ===== Privacy Notice ===== */
.chca-privacy {
    padding: 6px 16px 8px;
    font-size: 10px;
    color: #9ca3af;
    text-align: center;
    background: #fff;
    line-height: 1.4;
}
.chca-privacy a {
    color: #6b7280;
    text-decoration: underline;
}

/* ===== Powered By ===== */
.chca-powered {
    padding: 4px 16px 8px;
    font-size: 10px;
    color: #d1d5db;
    text-align: center;
}

/* ===== PII Warning ===== */
.chca-pii-notice {
    background: #fef3c7;
    color: #92400e;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 8px;
    text-align: center;
    margin: 4px 16px;
}

/* ===== Proactive Bubble ===== */
.chca-proactive {
    position: fixed;
    bottom: 160px;
    right: 24px;
    max-width: 300px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 14px 18px;
    z-index: 2147483645;
    animation: chcaSlideUp 0.3s ease-out;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.chca-proactive.left {
    right: auto;
    left: 24px;
}
.chca-proactive p {
    margin: 0 0 10px;
    font-size: 14px;
    color: #1a1a1a;
    line-height: 1.5;
}
.chca-proactive-actions {
    display: flex;
    gap: 8px;
}
.chca-proactive-accept {
    padding: 6px 14px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.chca-proactive-dismiss {
    padding: 6px 14px;
    background: #f3f4f6;
    color: #6b7280;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
    .chca-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    .chca-window.left {
        left: 0;
    }
    .chca-messages {
        max-height: calc(100vh - 200px);
    }
    .chca-proactive {
        bottom: 150px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
}
