/* ── Polar Blast AI Chatbot Widget ─────────────────────────────────────────── */

:root {
    --pb-navy:       #0b1f3a;
    --pb-navy-mid:   #122a4e;
    --pb-ice:        #e0f4ff;
    --pb-ice-bright: #c5eaff;
    --pb-blue:       #0077c8;
    --pb-blue-light: #2196f3;
    --pb-white:      #ffffff;
    --pb-grey:       #f2f6fa;
    --pb-grey-text:  #8a9bb0;
    --pb-text:       #1a2c42;
    --pb-radius:     14px;
    --pb-shadow:     0 12px 40px rgba(0, 60, 120, 0.22);
    --pb-font:       'Segoe UI', system-ui, -apple-system, sans-serif;
    --pb-z:          99999;
}

/* ── Launcher button ─────────────────────────────────────────────────────────── */
#pb-chat-launcher {
    position:        fixed;
    bottom:          28px;
    right:           28px;
    width:           60px;
    height:          60px;
    background:      linear-gradient(135deg, var(--pb-blue) 0%, var(--pb-navy) 100%);
    border-radius:   50%;
    display:         flex;
    align-items:     center;
    justify-content: center;
    cursor:          pointer;
    z-index:         var(--pb-z);
    box-shadow:      0 4px 20px rgba(0, 119, 200, 0.45);
    transition:      transform 0.25s ease, box-shadow 0.25s ease;
    color:           var(--pb-white);
}
#pb-chat-launcher:hover {
    transform:   translateY(-3px) scale(1.05);
    box-shadow:  0 8px 28px rgba(0, 119, 200, 0.55);
}
#pb-chat-launcher svg { width: 26px; height: 26px; }

/* ── Panel ───────────────────────────────────────────────────────────────────── */
#pb-chat-panel {
    position:      fixed;
    bottom:        102px;
    right:         28px;
    width:         370px;
    max-width:     calc(100vw - 32px);
    max-height:    580px;
    background:    var(--pb-white);
    border-radius: var(--pb-radius);
    box-shadow:    var(--pb-shadow);
    display:       flex;
    flex-direction: column;
    z-index:       var(--pb-z);
    overflow:      hidden;
    font-family:   var(--pb-font);

    /* Hidden state */
    opacity:       0;
    transform:     translateY(16px) scale(0.97);
    pointer-events: none;
    transition:    opacity 0.28s ease, transform 0.28s ease;
}
#pb-chat-panel.pb-open {
    opacity:        1;
    transform:      translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
#pb-chat-header {
    background:    linear-gradient(135deg, var(--pb-navy) 0%, var(--pb-navy-mid) 100%);
    padding:       14px 16px;
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    flex-shrink:   0;
}
#pb-chat-header-info {
    display:     flex;
    align-items: center;
    gap:         10px;
}
#pb-chat-avatar {
    width:           38px;
    height:          38px;
    border-radius:   50%;
    background:      linear-gradient(135deg, var(--pb-blue-light), var(--pb-blue));
    display:         flex;
    align-items:     center;
    justify-content: center;
    color:           var(--pb-white);
    flex-shrink:     0;
}
#pb-chat-name {
    color:       var(--pb-white);
    font-weight: 600;
    font-size:   14px;
    letter-spacing: 0.01em;
}
#pb-chat-status {
    color:       var(--pb-ice-bright);
    font-size:   12px;
    display:     flex;
    align-items: center;
    gap:         5px;
    margin-top:  2px;
}
#pb-status-dot {
    width:        8px;
    height:       8px;
    background:   #4cde80;
    border-radius: 50%;
    display:      inline-block;
    box-shadow:   0 0 6px rgba(76, 222, 128, 0.7);
}
#pb-chat-close {
    background:  transparent;
    border:      none;
    color:       rgba(255,255,255,0.7);
    cursor:      pointer;
    padding:     4px;
    border-radius: 6px;
    display:     flex;
    transition:  color 0.15s;
}
#pb-chat-close:hover { color: var(--pb-white); }

/* ── Messages area ───────────────────────────────────────────────────────────── */
#pb-chat-messages {
    flex:       1;
    overflow-y: auto;
    padding:    16px;
    display:    flex;
    flex-direction: column;
    gap:        10px;
    background: var(--pb-grey);
    scrollbar-width: thin;
    scrollbar-color: var(--pb-blue) transparent;
}
#pb-chat-messages::-webkit-scrollbar { width: 4px; }
#pb-chat-messages::-webkit-scrollbar-thumb { background: var(--pb-blue); border-radius: 2px; }

/* Bubbles */
.pb-msg {
    display:       flex;
    flex-direction: column;
    max-width:     80%;
    animation:     pb-fadein 0.22s ease;
}
@keyframes pb-fadein {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.pb-msg.pb-bot  { align-self: flex-start; }
.pb-msg.pb-user { align-self: flex-end; }

.pb-bubble {
    padding:       10px 13px;
    border-radius: 12px;
    font-size:     13.5px;
    line-height:   1.55;
}
.pb-bot .pb-bubble {
    background:    var(--pb-white);
    color:         var(--pb-text);
    border-bottom-left-radius: 4px;
    box-shadow:    0 1px 4px rgba(0,0,0,0.07);
}
.pb-user .pb-bubble {
    background:    linear-gradient(135deg, var(--pb-blue) 0%, var(--pb-navy-mid) 100%);
    color:         var(--pb-white);
    border-bottom-right-radius: 4px;
}
.pb-bubble p { margin: 0 0 6px; }
.pb-bubble p:last-child { margin-bottom: 0; }
.pb-bubble ul, .pb-bubble ol { margin: 4px 0 4px 16px; padding: 0; }
.pb-bubble li { margin-bottom: 3px; }
.pb-bubble strong { font-weight: 600; }

.pb-meta {
    font-size:  11px;
    color:      var(--pb-grey-text);
    margin-top: 3px;
    padding:    0 2px;
}
.pb-bot .pb-meta  { align-self: flex-start; }
.pb-user .pb-meta { align-self: flex-end; }

/* Typing indicator */
.pb-typing .pb-bubble {
    padding: 11px 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.pb-typing-dot {
    width:        7px;
    height:       7px;
    background:   var(--pb-blue);
    border-radius: 50%;
    animation:    pb-bounce 1.2s infinite ease-in-out;
}
.pb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.pb-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pb-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%            { transform: scale(1);   opacity: 1; }
}

/* Booking confirmation banner */
.pb-booking-confirm {
    background:    linear-gradient(135deg, #e8f8ef, #d4f4e2);
    border:        1px solid #a3ddb8;
    border-radius: 10px;
    padding:       10px 13px;
    font-size:     13px;
    color:         #1a5c35;
    margin-top:    4px;
}
.pb-booking-confirm strong { display: block; margin-bottom: 3px; font-size: 13.5px; }

/* ── Footer / input ───────────────────────────────────────────────────────────── */
#pb-chat-footer {
    display:      flex;
    align-items:  flex-end;
    padding:      10px 12px;
    gap:          8px;
    border-top:   1px solid #dce8f5;
    background:   var(--pb-white);
    flex-shrink:  0;
}
#pb-chat-input {
    flex:          1;
    border:        1.5px solid #cddff0;
    border-radius: 10px;
    padding:       9px 12px;
    font-size:     13.5px;
    font-family:   var(--pb-font);
    resize:        none;
    outline:       none;
    line-height:   1.4;
    max-height:    100px;
    overflow-y:    auto;
    color:         var(--pb-text);
    transition:    border-color 0.2s;
}
#pb-chat-input:focus { border-color: var(--pb-blue); }
#pb-chat-send {
    width:           38px;
    height:          38px;
    min-width:       38px;
    background:      linear-gradient(135deg, var(--pb-blue) 0%, var(--pb-navy-mid) 100%);
    border:          none;
    border-radius:   10px;
    color:           var(--pb-white);
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    justify-content: center;
    transition:      opacity 0.2s, transform 0.15s;
}
#pb-chat-send:hover   { opacity: 0.88; transform: scale(1.05); }
#pb-chat-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Mobile responsive ───────────────────────────────────────────────────────── */
@media (max-width: 440px) {
    #pb-chat-panel {
        bottom:        0;
        right:         0;
        left:          0;
        width:         100%;
        max-width:     100%;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        max-height:    70vh;
    }
    #pb-chat-launcher {
        bottom: 20px;
        right:  20px;
    }
}
