/* =====================================================
   Kkey WhatsApp – Pre-Chat Form Modal
   ===================================================== */

/* ── Overlay backdrop ──────────────────────────────── */
#kkey-prechat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99998;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: kkey-fade-in 0.2s ease;
}

#kkey-prechat-overlay.kkey-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes kkey-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal card ────────────────────────────────────── */
#kkey-prechat-modal {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    width: 90%;
    max-width: 420px;
    overflow: hidden;
    animation: kkey-slide-up 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@keyframes kkey-slide-up {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Modal header ──────────────────────────────────── */
#kkey-prechat-modal .kkey-pcf-header {
    background: linear-gradient(135deg, #075e54 0%, #128c7e 60%, #25d366 100%);
    padding: 20px 22px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

#kkey-prechat-modal .kkey-pcf-header img.kkey-pcf-wa-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

#kkey-prechat-modal .kkey-pcf-header-text {
    flex: 1;
}

#kkey-prechat-modal .kkey-pcf-header h3 {
    color: #ffffff;
    margin: 0 0 2px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}

#kkey-prechat-modal .kkey-pcf-header p {
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
}

#kkey-prechat-modal .kkey-pcf-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: #fff;
    width: 28px;
    height: 28px;
    font-size: 16px;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

#kkey-prechat-modal .kkey-pcf-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ── Agent info strip ──────────────────────────────── */
#kkey-prechat-modal .kkey-pcf-agent-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 22px;
    background: #f0faf6;
    border-bottom: 1px solid #e2f5ee;
}

#kkey-prechat-modal .kkey-pcf-agent-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #25d366;
    flex-shrink: 0;
}

#kkey-prechat-modal .kkey-pcf-agent-avatar-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #25d366;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    flex-shrink: 0;
}

#kkey-prechat-modal .kkey-pcf-agent-info strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1a2a3a;
}

#kkey-prechat-modal .kkey-pcf-agent-info span {
    font-size: 12px;
    color: #25d366;
    display: flex;
    align-items: center;
    gap: 5px;
}

#kkey-prechat-modal .kkey-pcf-agent-info span::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #25d366;
    border-radius: 50%;
    animation: kkey-pulse 1.5s ease infinite;
}

@keyframes kkey-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ── Form body ─────────────────────────────────────── */
#kkey-prechat-modal .kkey-pcf-body {
    padding: 20px 22px 22px;
}

#kkey-prechat-modal .kkey-pcf-field {
    margin-bottom: 14px;
}

#kkey-prechat-modal .kkey-pcf-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

#kkey-prechat-modal .kkey-pcf-field label span.kkey-pcf-required {
    color: #e53e3e;
    margin-left: 2px;
}

#kkey-prechat-modal .kkey-pcf-field input,
#kkey-prechat-modal .kkey-pcf-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #2d3748;
    background: #f9fafb;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    outline: none;
    font-family: inherit;
}

#kkey-prechat-modal .kkey-pcf-field input:focus,
#kkey-prechat-modal .kkey-pcf-field textarea:focus {
    border-color: #25d366;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.12);
}

#kkey-prechat-modal .kkey-pcf-field input.kkey-pcf-error,
#kkey-prechat-modal .kkey-pcf-field textarea.kkey-pcf-error {
    border-color: #fc8181;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(252, 129, 129, 0.12);
}

#kkey-prechat-modal .kkey-pcf-field textarea {
    resize: vertical;
    min-height: 70px;
}

#kkey-prechat-modal .kkey-pcf-error-msg {
    color: #e53e3e;
    font-size: 11px;
    margin-top: 4px;
    display: none;
}

#kkey-prechat-modal .kkey-pcf-error-msg.kkey-visible {
    display: block;
}

/* ── Submit button ─────────────────────────────────── */
#kkey-prechat-modal .kkey-pcf-submit {
    width: 100%;
    background: linear-gradient(135deg, #075e54 0%, #128c7e 50%, #25d366 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 13px 20px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: opacity 0.2s ease, transform 0.15s ease;
    margin-top: 6px;
    font-family: inherit;
}

#kkey-prechat-modal .kkey-pcf-submit:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

#kkey-prechat-modal .kkey-pcf-submit:active {
    transform: translateY(0);
}

#kkey-prechat-modal .kkey-pcf-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

#kkey-prechat-modal .kkey-pcf-submit svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Spinner inside button */
#kkey-prechat-modal .kkey-pcf-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: kkey-spin 0.7s linear infinite;
}

@keyframes kkey-spin {
    to { transform: rotate(360deg); }
}

#kkey-prechat-modal.kkey-loading .kkey-pcf-submit .kkey-pcf-spinner { display: block; }
#kkey-prechat-modal.kkey-loading .kkey-pcf-btn-icon { display: none; }

/* ── Privacy note ──────────────────────────────────── */
#kkey-prechat-modal .kkey-pcf-privacy {
    text-align: center;
    font-size: 11px;
    color: #a0aec0;
    margin-top: 12px;
    line-height: 1.5;
}

/* ── Responsive ────────────────────────────────────── */
@media screen and (max-width: 480px) {
    #kkey-prechat-modal {
        width: 96%;
        max-width: none;
        border-radius: 14px;
    }

    #kkey-prechat-modal .kkey-pcf-header,
    #kkey-prechat-modal .kkey-pcf-body {
        padding-left: 16px;
        padding-right: 16px;
    }
}
