/* ============================================================
   ISLAND PROJECT AI CHATBOT — v1.0.0
   Brand: Navy #0B2F5C | Gold #B8912F | Ivory
   ============================================================ */

:root {
    --ip-navy:       #0B2F5C;
    --ip-navy-dark:  #071F3E;
    --ip-gold:       #B8912F;
    --ip-gold-light: #E9CD6E;
    --ip-ivory:      #FAF8F3;
    --ip-white:      #FFFFFF;
    --ip-radius:     14px;
    --ip-shadow:     0 8px 40px rgba(11,47,92,0.22);
}

/* ---- FLOATING BUTTON ---- */
#ip-chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99998;
    background: linear-gradient(135deg, var(--ip-navy) 0%, var(--ip-navy-dark) 100%);
    color: var(--ip-gold-light);
    border: 2px solid var(--ip-gold);
    border-radius: 50px;
    padding: 13px 20px;
    font-size: 14px;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    cursor: pointer;
    box-shadow: var(--ip-shadow);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    max-width: calc(100vw - 48px);
    overflow: hidden;
}

#ip-chatbot-toggle .ip-toggle-icon {
    font-size: 15px;
    line-height: 1;
}

#ip-chatbot-toggle .ip-toggle-short,
#ip-chatbot-toggle .ip-toggle-long {
    display: inline;
}

#ip-chatbot-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 48px rgba(11,47,92,0.32);
}

#ip-chatbot-toggle span {
    letter-spacing: 0.01em;
}

/* ---- CHAT WINDOW ---- */
#ip-chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: 99999;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: 620px;
    height: calc(100vh - 120px);
    height: calc(100dvh - 120px);
    background: var(--ip-white);
    border-radius: var(--ip-radius);
    box-shadow: var(--ip-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1.5px solid rgba(184,145,47,0.25);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    animation: ip-slideUp 0.25s ease;
}

@keyframes ip-slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- HEADER ---- */
#ip-chatbot-header {
    background: linear-gradient(135deg, var(--ip-navy) 0%, var(--ip-navy-dark) 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--ip-gold);
    flex-shrink: 0;
}

#ip-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#ip-chatbot-avatar {
    width: 40px;
    height: 40px;
    background: var(--ip-ivory);
    border: 1.5px solid var(--ip-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 20px;
    line-height: 1;
    color: var(--ip-navy-dark);
    flex-shrink: 0;
    overflow: hidden;
    padding: 4px;
    box-sizing: border-box;
}

#ip-chatbot-avatar img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

#ip-chatbot-title {
    color: var(--ip-white);
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

#ip-chatbot-subtitle {
    color: var(--ip-gold-light);
    font-size: 11px;
    font-weight: 500;
    opacity: 0.9;
    margin-top: 1px;
}

#ip-chatbot-close {
    background: rgba(255,255,255,0.12);
    border: none;
    color: var(--ip-white);
    font-size: 16px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s;
    line-height: 1;
}

#ip-chatbot-close:hover {
    background: rgba(255,255,255,0.22);
}

/* ---- MESSAGES ---- */
#ip-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--ip-ivory);
    scroll-behavior: smooth;
}

#ip-chatbot-messages::-webkit-scrollbar { width: 4px; }
#ip-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#ip-chatbot-messages::-webkit-scrollbar-thumb { background: rgba(11,47,92,0.15); border-radius: 4px; }

.ip-msg {
    display: flex;
    flex-direction: column;
}

.ip-msg-bot  { align-items: flex-start; }
.ip-msg-user { align-items: flex-end; }

.ip-msg-bubble {
    max-width: 85%;
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
}

.ip-msg-bot .ip-msg-bubble {
    background: var(--ip-white);
    color: #1a1a2e;
    border: 1px solid rgba(184,145,47,0.18);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(11,47,92,0.07);
}

.ip-msg-user .ip-msg-bubble {
    background: linear-gradient(135deg, var(--ip-navy) 0%, var(--ip-navy-dark) 100%);
    color: var(--ip-white);
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.ip-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-items: center;
}

.ip-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--ip-gold);
    border-radius: 50%;
    animation: ip-bounce 1.2s infinite;
}

.ip-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ip-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ip-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* ---- LEAD CAPTURE FORM ---- */
#ip-chatbot-lead-form {
    background: var(--ip-white);
    border-top: 2px solid var(--ip-gold);
    padding: 16px;
    flex-shrink: 0;
}

#ip-chatbot-lead-title {
    font-weight: 700;
    color: var(--ip-navy);
    font-size: 13px;
    margin-bottom: 10px;
    text-align: center;
}

#ip-chatbot-lead-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid rgba(11,47,92,0.18);
    border-radius: 8px;
    /* 16px minimum - prevents iOS zoom on focus. */
    font-size: 16px;
    margin-bottom: 8px;
    box-sizing: border-box;
    color: #1a1a2e;
    background: var(--ip-ivory);
    transition: border-color 0.15s;
    font-family: inherit;
}

#ip-chatbot-lead-form input:focus {
    outline: none;
    border-color: var(--ip-gold);
    background: var(--ip-white);
}

#ip-lead-submit {
    width: 100%;
    padding: 11px;
    background: linear-gradient(135deg, var(--ip-gold) 0%, var(--ip-gold-light) 100%);
    color: var(--ip-navy-dark);
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    font-family: inherit;
    margin-top: 2px;
}

#ip-lead-submit:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

#ip-lead-result {
    font-size: 12px;
    text-align: center;
    margin-top: 8px;
    color: var(--ip-navy);
    font-weight: 600;
}

/* Honeypot — hidden from humans */
#ip-honeypot { display: none !important; }

/* ---- QUICK REPLIES ---- */
#ip-chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    background: var(--ip-white);
    border-top: 1px solid rgba(184,145,47,0.15);
    flex-shrink: 0;
}

.ip-quick-reply {
    background: var(--ip-ivory);
    border: 1.5px solid rgba(184,145,47,0.35);
    color: var(--ip-navy);
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.ip-quick-reply:hover {
    background: var(--ip-navy);
    color: var(--ip-gold-light);
    border-color: var(--ip-navy);
}

/* ---- INPUT AREA ---- */
#ip-chatbot-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    background: var(--ip-white);
    border-top: 1px solid rgba(11,47,92,0.1);
    flex-shrink: 0;
}

#ip-chatbot-input {
    flex: 1;
    border: 1.5px solid rgba(11,47,92,0.18);
    border-radius: 10px;
    padding: 9px 12px;
    /* 16px minimum: anything smaller makes iOS Safari zoom the whole page
       the moment the visitor taps to type. */
    font-size: 16px;
    font-family: inherit;
    resize: none;
    min-height: 38px;
    max-height: 100px;
    background: var(--ip-ivory);
    color: #1a1a2e;
    transition: border-color 0.15s;
    line-height: 1.4;
}

#ip-chatbot-input:focus {
    outline: none;
    border-color: var(--ip-gold);
    background: var(--ip-white);
}

#ip-chatbot-input::placeholder {
    color: rgba(11,47,92,0.4);
}

#ip-chatbot-send {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--ip-navy) 0%, var(--ip-navy-dark) 100%);
    border: none;
    border-radius: 10px;
    color: var(--ip-gold-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}

#ip-chatbot-send:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

#ip-chatbot-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* ---- FOOTER ---- */
#ip-chatbot-footer {
    padding: 7px 14px;
    background: var(--ip-navy-dark);
    text-align: center;
    font-size: 11px;
    color: rgba(233,205,110,0.65);
    flex-shrink: 0;
}

#ip-chatbot-footer a {
    color: var(--ip-gold-light);
    text-decoration: none;
    opacity: 0.8;
}

#ip-chatbot-footer a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ---- MOBILE ---- */
@media (max-width: 480px) {
    #ip-chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        max-height: 88vh;
        max-height: 88dvh;
        height: 88dvh;
        border-radius: var(--ip-radius) var(--ip-radius) 0 0;
    }

    /* Full label retained on mobile. */
    #ip-chatbot-toggle {
        bottom: 16px;
        right: 16px;
        font-size: 13px;
        padding: 11px 16px;
    }

    #ip-chatbot-messages {
        padding: 14px;
    }

    .ip-msg-bubble {
        max-width: 88%;
    }
}

@media (max-width: 360px) {
    #ip-chatbot-toggle {
        font-size: 12px;
        padding: 10px 14px;
    }
}


/* ============================================================
   reCAPTCHA BADGE
   Google's invisible reCAPTCHA badge parks itself bottom-right,
   which is where the chat button lives. Move it to the left so
   the two don't stack. The badge stays visible, which is what
   Google's terms require.
   ============================================================ */
.grecaptcha-badge {
    left: 14px !important;
    right: auto !important;
    bottom: 14px !important;
    z-index: 99990 !important;
    /* Collapse to just the reCAPTCHA mark. The badge stays visible, which
       is what Google's terms require, but stops occupying a wide panel. */
    width: 70px !important;
    overflow: hidden !important;
    transition: width 0.3s ease !important;
}

/* Expand on hover so the full attribution is still reachable. */
.grecaptcha-badge:hover,
.grecaptcha-badge:focus-within {
    width: 256px !important;
}

@media (max-width: 480px) {
    .grecaptcha-badge {
        left: 8px !important;
        bottom: 8px !important;
        width: 60px !important;
        transform: scale(0.85);
        transform-origin: bottom left;
    }
}
