/* ================================
   CHAT TOGGLE BUBBLE
   ================================ */
#sh-chat-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 10;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#sh-toggle-chat {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #007cba;
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

#sh-toggle-chat:hover {
    background: #006ba1;
    transform: scale(1.05);
}

/* ================================
   CHAT WINDOW STRUCTURE
   ================================ */
#sh-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 370px;
    height: 500px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
    transform: scale(0.9);
    opacity: 0;
    pointer-events: none;
}

#sh-chat-window.sh-active {
    transform: scale(1);
    opacity: 1;
    pointer-events: all;
}

.sh-hidden {
    display: none !important;
}

/* ================================
   CHAT HEADER
   ================================ */
#sh-chat-header {
    background: #007cba;
    color: #fff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
}

.sh-header-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sh-header-img-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255,255,255,0.2);
}

#sh-close-chat {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

/* ================================
   PRE-CHAT FORM
   ================================ */
#sh-pre-chat-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#sh-pre-chat-form p {
    margin: 0 0 10px 0;
    color: #555;
    font-size: 14px;
}

#sh-pre-chat-form input[type="text"],
#sh-pre-chat-form input[type="email"] {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}

/* Anti-Spam Human Verification Slider */
.sh-slider-container {
    position: relative;
    width: 100%;
    height: 40px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    margin-top: 5px;
    margin-bottom: 5px;
}

.sh-slider-bg-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: #d4edda;
    z-index: 1;
    transition: width 0.1s ease;
}

.sh-slider-container label {
    position: absolute;
    width: 100%;
    text-align: center;
    color: #666;
    pointer-events: none;
    font-size: 12px;
    z-index: 2;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type=range].sh-human-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    position: relative;
    z-index: 3;
    height: 100%;
    margin: 0;
    outline: none;
}

input[type=range].sh-human-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 36px;
    width: 40px;
    background: #007cba;
    cursor: pointer;
    border-radius: 4px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

input[type=range].sh-human-slider::-moz-range-thumb {
    height: 36px;
    width: 40px;
    background: #007cba;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

#sh-start-chat-btn {
    background: #007cba !important;
    border: none;
    color: #fff !important;
    padding: 10px !important;
    border-radius: 4px !important;
    cursor: not-allowed;
    font-weight: 600;
    transition: all 0.3s;
    opacity: 0.5;
    pointer-events: none;
}

#sh-start-chat-btn.sh-unlocked {
    opacity: 1;
    cursor: pointer;
    pointer-events: auto;
}

/* ================================
   ACTIVE CHAT AREA
   ================================ */
#sh-active-chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#sh-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f4f4f4;
}

/* Wrappers for Avatar alignment */
.sh-msg-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

.sh-msg-wrapper.admin-wrapper {
    justify-content: flex-start;
}

.sh-msg-wrapper.user-wrapper {
    justify-content: flex-end;
}

.sh-msg-avatar {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.sh-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.4;
    word-wrap: break-word;
}

.sh-msg.user {
    background: #007cba;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.sh-msg.admin {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.sh-msg.system {
    background: #fff3cd;
    color: #856404;
    align-self: center;
    font-size: 12px;
    text-align: center;
    border: 1px solid #ffeeba;
    border-radius: 12px;
    margin: 5px 0;
}

/* ================================
   CHAT INPUT AREA
   ================================ */
#sh-input-area {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: center;
}

#sh-user-message {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 60px;
}

#sh-user-message:focus {
    border-color: #007cba;
}

#sh-send-message-btn {
    background: #007cba;
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ================================
   MOBILE RESPONSIVENESS FIX
   ================================ */
@media (max-width: 480px) {
    #sh-chat-widget {
        bottom: 15px;
        right: 15px;
    }

    #sh-toggle-chat {
        width: 55px;
        height: 55px;
    }

    #sh-chat-window {
        /* Calculate width to prevent left cutoff, leaving safe margin */
        width: calc(100vw - 30px);
        right: 0;
        height: 450px;
        bottom: 70px;
    }
}
