/**
 * WhatsApp Chat Widget Styles
 * Mobile-first, responsive design
 */

/* Hide elements with x-cloak until Alpine.js is loaded */
[x-cloak] {
    display: none !important;
}

/* Main Container */
.whatsapp-chat-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Position Classes */
.whatsapp-chat-bottom-right {
    bottom: 20px;
    right: 20px;
}

.whatsapp-chat-bottom-left {
    bottom: 20px;
    left: 20px;
}

.whatsapp-chat-top-right {
    top: 20px;
    right: 20px;
}

.whatsapp-chat-top-left {
    top: 20px;
    left: 20px;
}

.whatsapp-chat-center-right {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

.whatsapp-chat-center-left {
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
}

/* Chat Button */
.whatsapp-chat-button {
    position: relative;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #25D366;
    border: none;
}

.whatsapp-chat-button:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    transform: scale(1.05);
}

.whatsapp-chat-button:active {
    transform: scale(0.95);
}

/* Button Sizes */
.whatsapp-chat-size-small .whatsapp-chat-button {
    width: 48px;
    height: 48px;
    overflow: inherit;
}

.whatsapp-chat-size-medium .whatsapp-chat-button {
    width: 60px;
    height: 60px;
}

.whatsapp-chat-size-large .whatsapp-chat-button {
    width: 72px;
    height: 72px;
}

/* Dragging State */
.whatsapp-chat-button.dragging {
    cursor: move;
    opacity: 0.8;
}

/* Button Icon */
.button-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

/* Custom Logo Image */
.custom-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
}

.whatsapp-chat-size-small .custom-logo-img {
    padding: 10px;
}

.whatsapp-chat-size-large .custom-logo-img {
    padding: 14px;
}

.whatsapp-chat-button .close-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.whatsapp-chat-button:hover .button-icon {
    opacity: 0;
}

.whatsapp-chat-button:hover .close-icon {
    opacity: 1;
}

/* Availability Badge */
.availability-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* Chat Popup */
.whatsapp-chat-popup {
    position: absolute;
    width: 360px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: slideUp 0.3s ease;
    z-index: 1;
}

/* Default positioning (will be overridden by JavaScript) */
.whatsapp-chat-bottom-right .whatsapp-chat-popup {
    bottom: 80px;
    right: 0;
}

.whatsapp-chat-bottom-left .whatsapp-chat-popup {
    bottom: 80px;
    left: 0;
}

.whatsapp-chat-top-right .whatsapp-chat-popup {
    top: 80px;
    right: 0;
}

.whatsapp-chat-top-left .whatsapp-chat-popup {
    top: 80px;
    left: 0;
}

.whatsapp-chat-center-right .whatsapp-chat-popup {
    top: 50%;
    right: 90px;
    transform: translateY(-50%);
}

.whatsapp-chat-center-left .whatsapp-chat-popup {
    top: 50%;
    left: 90px;
    transform: translateY(-50%);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .whatsapp-chat-popup {
        position: fixed !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100vw - 20px) !important;
        max-width: 360px !important;
    }
    
    /* Bottom positions - popup above */
    .whatsapp-chat-bottom-right .whatsapp-chat-popup,
    .whatsapp-chat-bottom-left .whatsapp-chat-popup,
    .whatsapp-chat-center-right .whatsapp-chat-popup,
    .whatsapp-chat-center-left .whatsapp-chat-popup {
        bottom: 70px !important;
        top: auto !important;
    }
    
    /* Top positions - popup below */
    .whatsapp-chat-top-right .whatsapp-chat-popup,
    .whatsapp-chat-top-left .whatsapp-chat-popup {
        top: 70px !important;
        bottom: auto !important;
    }
}

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Animation based on position */
.whatsapp-chat-bottom-right .whatsapp-chat-popup,
.whatsapp-chat-bottom-left .whatsapp-chat-popup {
    animation: slideUp 0.3s ease;
}

.whatsapp-chat-top-right .whatsapp-chat-popup,
.whatsapp-chat-top-left .whatsapp-chat-popup {
    animation: slideDown 0.3s ease;
}

.whatsapp-chat-center-right .whatsapp-chat-popup {
    animation: slideLeft 0.3s ease;
}

.whatsapp-chat-center-left .whatsapp-chat-popup {
    animation: slideRight 0.3s ease;
}

/* Popup Header */
.popup-header {
    background-color: #25D366;
    color: white;
    padding: 16px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.agent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.agent-details h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.availability-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 13px;
    opacity: 0.9;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background-color: #4CAF50;
}

.status-indicator.away {
    background-color: #FFC107;
}

.status-indicator.offline {
    background-color: #F44336;
}

.close-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.close-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Popup Body */
.popup-body {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.popup-body::-webkit-scrollbar {
    width: 6px;
}

.popup-body::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Greeting Message */
.greeting-message {
    background-color: #E8F5E9;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.greeting-message p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

/* Quick Questions */
.quick-questions {
    margin-bottom: 16px;
}

.questions-title {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quick-question-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background-color: #F5F5F5;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #333;
    text-align: left;
    margin-bottom: 8px;
}

.quick-question-btn:hover {
    background-color: #E8F5E9;
    border-color: #25D366;
    transform: translateX(4px);
}

.quick-question-btn:active {
    transform: translateX(2px);
}

.question-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    flex-shrink: 0;
    vertical-align: middle;
}

.question-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* Custom Message */
.custom-message {
    margin-top: 16px;
}

.custom-message label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
}

.custom-message textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.custom-message textarea:focus {
    outline: none;
    border-color: #25D366;
}

.send-button {
    width: 100%;
    padding: 12px;
    background-color: #25D366;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.2s ease;
}

.send-button:hover {
    background-color: #128C7E;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.send-button:active {
    transform: translateY(0);
}

/* Offline Notice */
.offline-notice {
    background-color: #FFF3E0;
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    border-left: 4px solid #FF9800;
}

.offline-notice p {
    margin: 0;
    font-size: 13px;
    color: #E65100;
}

/* Animation Variants */
.whatsapp-chat-container.animation-fade {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.whatsapp-chat-container.animation-bounce .whatsapp-chat-button {
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.whatsapp-chat-container.animation-zoom {
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse Effect for Button */
.whatsapp-chat-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: inherit;
    transform: translate(-50%, -50%);
    animation: pulse 2s ease infinite;
    opacity: 0.7;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.7;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Maintain position classes on mobile */
    .whatsapp-chat-bottom-right {
        bottom: 10px !important;
        right: 10px !important;
        left: auto !important;
        top: auto !important;
    }
    
    .whatsapp-chat-bottom-left {
        bottom: 10px !important;
        left: 10px !important;
        right: auto !important;
        top: auto !important;
    }
    
    .whatsapp-chat-top-right {
        top: 10px !important;
        right: 10px !important;
        left: auto !important;
        bottom: auto !important;
    }
    
    .whatsapp-chat-top-left {
        top: 10px !important;
        left: 10px !important;
        right: auto !important;
        bottom: auto !important;
    }
    
    .whatsapp-chat-center-right {
        top: 50% !important;
        right: 10px !important;
        left: auto !important;
        bottom: auto !important;
        transform: translateY(-50%) !important;
    }
    
    .whatsapp-chat-center-left {
        top: 50% !important;
        left: 10px !important;
        right: auto !important;
        bottom: auto !important;
        transform: translateY(-50%) !important;
    }
    
    .whatsapp-chat-popup {
        width: calc(100vw - 20px);
        max-width: 360px;
    }
    
    .whatsapp-chat-size-small .whatsapp-chat-button {
        width: 56px;
        height: 56px;
    }
    
    .whatsapp-chat-size-medium .whatsapp-chat-button {
        width: 64px;
        height: 64px;
    }
    
    .whatsapp-chat-size-large .whatsapp-chat-button {
        width: 72px;
        height: 72px;
    }
}

@media (max-width: 480px) {
    .popup-body {
        padding: 16px;
        max-height: 60vh;
    }
    
    .agent-details h3 {
        font-size: 14px;
    }
    
    .quick-question-btn {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* Tablet Responsive */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Maintain position classes on tablet */
    .whatsapp-chat-bottom-right {
        bottom: 15px;
        right: 15px;
    }
    
    .whatsapp-chat-bottom-left {
        bottom: 15px;
        left: 15px;
    }
    
    .whatsapp-chat-top-right {
        top: 15px;
        right: 15px;
    }
    
    .whatsapp-chat-top-left {
        top: 15px;
        left: 15px;
    }
    
    .whatsapp-chat-center-right {
        top: 50%;
        right: 15px;
        transform: translateY(-50%);
    }
    
    .whatsapp-chat-center-left {
        top: 50%;
        left: 15px;
        transform: translateY(-50%);
    }
    
    .whatsapp-chat-popup {
        width: 340px;
    }
}

/* Desktop Large Screens */
@media (min-width: 1440px) {
    .whatsapp-chat-popup {
        width: 380px;
    }
}

/* Print Styles */
@media print {
    .whatsapp-chat-container {
        display: none !important;
    }
}

/* Accessibility */
.whatsapp-chat-button:focus,
.quick-question-btn:focus,
.send-button:focus,
.close-button:focus {
    outline: 2px solid #25D366;
    outline-offset: 2px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .whatsapp-chat-popup {
        background: #1E1E1E;
        color: #E0E0E0;
    }
    
    .greeting-message {
        background-color: #2C3E2C;
    }
    
    .greeting-message p {
        color: #E0E0E0;
    }
    
    .quick-question-btn {
        background-color: #2A2A2A;
        border-color: #3A3A3A;
        color: #E0E0E0;
    }
    
    .quick-question-btn:hover {
        background-color: #2C3E2C;
    }
    
    .custom-message textarea {
        background-color: #2A2A2A;
        border-color: #3A3A3A;
        color: #E0E0E0;
    }
    
    .offline-notice {
        background-color: #3E2A1C;
        border-left-color: #FF9800;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .whatsapp-chat-button {
        border: 2px solid white;
    }
    
    .quick-question-btn {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
