/*
 * chat-widget.css
 * Styles for the Premium Chat Widget
 */

/* General Body and Font */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Chat Widget Container */
#pcw-chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999; /* Ensure it's above other content */
    display: flex; /* Use flex to manage visibility of icon/box */
    flex-direction: column;
    align-items: flex-end;
    transition: all 0.3s ease-in-out; /* Smooth transition for state changes */
    -webkit-font-smoothing: antialiased; /* Better font rendering */
    -moz-osx-font-smoothing: grayscale;
}

/* Chat Icon (when widget is closed) */
#pcw-chat-icon {
    background-color: #2ecc71; /* Brighter, vibrant green */
    color: #fff;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25); /* Stronger shadow */
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    position: relative; /* For tooltip */
    overflow: hidden; /* For pulse animation */
}

#pcw-chat-icon::before { /* Pulse effect for icon */
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    animation: pcw-icon-pulse 2s infinite ease-out;
}

@keyframes pcw-icon-pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0;
    }
}


#pcw-chat-icon:hover {
    background-color: #27ae60; /* Darker green on hover */
    transform: translateY(-5px); /* More noticeable lift effect */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* Tooltip for Chat Icon */
.pcw-tooltip-container {
    position: relative;
}

.pcw-tooltip-text {
    visibility: hidden;
    width: 120px;
    background-color: rgba(0, 0, 0, 0.8); /* Darker tooltip */
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    position: absolute;
    z-index: 1;
    bottom: 125%; /* Position above the icon */
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    font-size: 14px;
    transform: translateY(10px); /* Initial position for animation */
}

.pcw-tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%; /* At the bottom of the tooltip */
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
}

#pcw-chat-icon:hover .pcw-tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateY(0); /* Move up to final position */
}


/* Chat Box (when widget is open) */
#pcw-chat-box {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); /* Stronger, deeper shadow */
    width: 350px; /* Default width */
    max-width: 90vw; /* Max width for responsiveness */
    height: 450px; /* Default height */
    max-height: 80vh; /* Max height for responsiveness */
    display: none; /* Hidden by default, controlled by JS/class */
    flex-direction: column;
    overflow: hidden;
    border: none; /* Remove border for cleaner look */
    transform-origin: bottom right; /* For scaling animation */
}

/* Animations for open/close */
#pcw-chat-box.open { /* This class is added/removed by JS for animations */
    animation: fadeInScaleUp 0.3s ease forwards;
}

@keyframes fadeInScaleUp {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Header */
.pcw-chat-header {
    background: linear-gradient(to right, #3498db, #2980b9); /* Premium blue gradient */
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Subtle white border */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1); /* Subtle shadow for header */
}

.pcw-chat-header-left {
    display: flex;
    align-items: center;
}

.pcw-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.6); /* Lighter border for premium feel */
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

.pcw-header-info h3 {
    margin: 0;
    font-size: 1.1em;
    color: #fff; /* White text for header */
    font-weight: 600;
}

.pcw-availability {
    display: flex;
    align-items: center;
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.8); /* Lighter white for status */
    margin-top: 2px;
}

.pcw-online-indicator {
    width: 8px;
    height: 8px;
    background-color: #2ecc71; /* Green */
    border-radius: 50%;
    margin-right: 6px;
    animation: pcw-pulse 1.5s infinite ease-out; /* Pulsing animation */
}

@keyframes pcw-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(46, 204, 113, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

.pcw-close-button {
    background: none;
    border: none;
    font-size: 1.3em; /* Slightly larger close icon */
    color: rgba(255, 255, 255, 0.8); /* White close icon */
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.pcw-close-button:hover {
    background-color: rgba(255, 255, 255, 0.2); /* Light background on hover */
    color: #fff;
}

/* Messages Area */
.pcw-chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f8f8f8; /* Very light subtle gray background */
    display: flex; /* For message alignment */
    flex-direction: column;
    gap: 10px; /* Space between messages */
}

.pcw-message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 0.95em;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); /* Subtle shadow for bubbles */
    animation: pcw-message-fade-in 0.3s ease-out forwards;
}

@keyframes pcw-message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pcw-message-received {
    background-color: #e7e7e7; /* Light gray for received messages */
    color: #333;
    align-self: flex-start; /* Align to left */
    border-bottom-left-radius: 4px; /* Straight edge on bottom left */
}

.pcw-message-sent {
    background-color: #d4edda; /* Soft pastel green for sent messages */
    color: #333;
    align-self: flex-end; /* Align to right */
    border-bottom-right-radius: 4px; /* Straight edge on bottom right */
}

/* Input Area */
.pcw-chat-input-area {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background-color: #f7f7f7;
    display: flex;
    gap: 10px;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

#pcw-chat-input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 25px; /* Fully rounded input */
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#pcw-chat-input:focus {
    border-color: #3498db; /* Blue border on focus */
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2); /* Subtle blue glow */
}

#pcw-chat-input.pcw-input-error {
    animation: pcw-shake 0.3s ease-in-out;
    border-color: #e74c3c; /* Red border for error */
}

@keyframes pcw-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

#pcw-send-message {
    background-color: #2ecc71; /* Green send button */
    color: #fff;
    border: none;
    border-radius: 25px; /* Fully rounded button */
    padding: 10px 18px;
    font-size: 0.95em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

#pcw-send-message:hover {
    background-color: #27ae60; /* Darker green on hover */
    transform: translateY(-1px); /* Slight lift */
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

#pcw-send-message:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}


/* Initial State Handling (controlled by PHP/JS for initial load) */
#pcw-chat-widget-container.pcw-widget-open #pcw-chat-icon {
    display: none;
}

#pcw-chat-widget-container.pcw-widget-open #pcw-chat-box {
    display: flex; /* Show the chat box */
}

#pcw-chat-widget-container.pcw-widget-closed #pcw-chat-icon {
    display: flex; /* Show the icon */
}

#pcw-chat-widget-container.pcw-widget-closed #pcw-chat-box {
    display: none; /* Hide the chat box */
}


/* Responsive Adjustments */
@media (max-width: 768px) {
    #pcw-chat-widget-container {
        bottom: 15px;
        right: 15px;
    }

    #pcw-chat-icon {
        width: 55px;
        height: 55px;
        font-size: 26px;
    }

    #pcw-chat-box {
        width: 320px; /* Slightly smaller on tablets */
        height: 400px;
    }
}

@media (max-width: 480px) {
    #pcw-chat-widget-container {
        bottom: 10px;
        right: 10px;
    }

    #pcw-chat-icon {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

    #pcw-chat-box {
        width: 95vw; /* Almost full width on small mobiles */
        max-width: 300px; /* But not too wide if viewport is large */
        height: 60vh; /* **Adjusted for smaller height on mobile** */
        max-height: 380px; /* **Added max-height for better control** */
        font-size: 0.9em;
    }

    .pcw-chat-header {
        padding: 10px 15px;
    }

    .pcw-avatar {
        width: 35px;
        height: 35px;
        margin-right: 10px;
    }

    .pcw-header-info h3 {
        font-size: 1em;
    }

    .pcw-availability {
        font-size: 0.8em;
    }

    .pcw-close-button {
        font-size: 1em;
    }

    .pcw-chat-messages {
        padding: 15px;
    }

    .pcw-message {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .pcw-chat-input-area {
        padding: 10px 15px;
        flex-direction: column; /* Stack input and button on very small screens */
        gap: 8px;
    }

    #pcw-chat-input {
        padding: 8px 12px;
        width: calc(100% - 24px); /* Account for padding */
    }

    #pcw-send-message {
        width: 100%; /* Full width button */
        padding: 10px 0;
        justify-content: center; /* Center icon and text */
    }
}
