/**
 * WhatsApp Agents Manager - Frontend Styles
 */

/* Floating Bubble */
.wam-bubble {
    position: fixed;
    z-index: 999999;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: wam-pulse 2s infinite;
}

.wam-bubble-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wam-bubble-bottom-left {
    bottom: 20px;
    left: 20px;
}

.wam-bubble-top-right {
    top: 20px;
    right: 20px;
}

.wam-bubble-top-left {
    top: 20px;
    left: 20px;
}

.wam-bubble-content {
    background: #25d366;
    color: white;
    border-radius: 50px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.2);
    min-width: 60px;
    justify-content: center;
}

.wam-bubble-text {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.wam-bubble-icon {
    font-size: 18px;
    line-height: 1;
}

.wam-bubble:hover {
    transform: scale(1.05);
    animation: none;
}

.wam-bubble:hover .wam-bubble-content {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Pulse animation */
@keyframes wam-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Shortcode Buttons */
.wam-shortcode-button-container {
    margin: 15px 0;
    display: inline-block;
}

.wam-shortcode-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.wam-shortcode-button.wam-link-style {
    background: none;
    color: #25d366;
    border: 2px solid #25d366;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
}

.wam-shortcode-button.wam-link-style:hover {
    background: #25d366;
    color: white;
    transform: none;
    box-shadow: none;
}

.wam-shortcode-button.wam-custom-button {
    background: transparent;
    border: none;
    color: inherit;
    padding: 0;
    box-shadow: none;
}

.wam-shortcode-button.wam-custom-button:hover {
    background: transparent;
    transform: none;
    box-shadow: none;
}

/* Product and Shop Buttons */
.wam-product-button-container,
.wam-shop-button-container {
    margin: 15px 0;
}

.wam-contact-button {
    background: #25d366;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
    min-height: 44px;
}

.wam-contact-button:hover {
    background: #128c7e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    color: white;
    text-decoration: none;
}

.wam-contact-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.3);
}

.wam-whatsapp-icon {
    font-size: 16px;
    line-height: 1;
}

/* Shop button specific styles */
.wam-shop-button {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

/* Product name display in buttons */
.wam-product-name {
    font-size: 12px;
    opacity: 0.9;
    font-weight: normal;
    display: block;
    margin-top: 2px;
}

/* Popup Styles - OPTIMIZADO */
.wam-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.wam-popup.active {
    opacity: 1;
    visibility: visible;
}

.wam-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.wam-popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.wam-popup.active .wam-popup-content {
    transform: translate(-50%, -50%) scale(1);
}

.wam-popup-header {
    padding: 10px 18px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: white;
    flex-shrink: 0;
}

.wam-popup-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.wam-popup-close {
    background: none;
    border: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
    line-height: 1;
}

.wam-popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.wam-popup-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

/* Agents List - COMPACTO */
.wam-agents-list {
    display: grid;
    gap: 12px;
}

.wam-agent-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.wam-agent-card:hover {
    border-color: #25d366;
    background: #f0fff4;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wam-agent-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.wam-agent-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wam-agent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wam-agent-avatar-placeholder {
    font-size: 18px;
    color: #9ca3af;
}

.wam-agent-info {
    flex: 1;
    min-width: 0;
}

.wam-agent-info h4 {
    margin: 0 0 2px 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.wam-agent-area {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}

.wam-agent-contact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.wam-agent-phone {
    font-size: 13px;
    color: #25d366;
    font-weight: 500;
}

.wam-contact-agent-btn {
    background: #25d366;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.wam-contact-agent-btn:hover {
    background: #128c7e;
}

/* Contact Form - COMPACTO */
.wam-contact-form {
    border-top: 1px solid #eee;
    padding-top: 12px;
    margin-top: 12px;
}

.wam-contact-form h4 {
    margin: 0 0 12px 0;
    color: #111827;
    font-size: 14px;
    line-height: 1.4;
}

#wam-contact-form {
    display: grid;
    gap: 10px;
}

#wam-contact-form input,
#wam-contact-form textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

#wam-contact-form input {
    height: 36px;
}

#wam-contact-form textarea {
    min-height: 60px;
    resize: vertical;
}

#wam-contact-form input::placeholder,
#wam-contact-form textarea::placeholder {
    color: #9ca3af;
    font-size: 13px;
}

#wam-contact-form input:focus,
#wam-contact-form textarea:focus {
    outline: none;
    border-color: #25d366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

/* Labels para los inputs */
#wam-contact-form label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.wam-submit-btn {
    background: #25d366;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    justify-self: start;
}

.wam-submit-btn:hover {
    background: #128c7e;
    transform: translateY(-1px);
}

.wam-submit-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* Loading States */
.wam-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: #6b7280;
}

.wam-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #25d366;
    border-radius: 50%;
    animation: wam-spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes wam-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error Messages */
.wam-message {
    padding: 10px 12px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 13px;
    font-weight: 500;
}

.wam-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.wam-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* No agents message */
.wam-agents-list > p {
    text-align: center;
    color: #6b7280;
    padding: 12px !important;
    margin: 0 !important;
    font-size: 13px;
    line-height: 1.4;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .wam-bubble-content {
        padding: 10px 16px;
    }
    
    .wam-bubble-text {
        font-size: 13px;
    }
    
    .wam-popup-content {
        width: 95%;
        margin: 10px;
    }
    
    .wam-popup-header,
    .wam-popup-body {
        padding: 16px;
    }
    
    .wam-contact-button {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .wam-agent-header {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .wam-agent-contact {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .wam-bubble {
        bottom: 15px;
        right: 15px;
    }
    
    .wam-bubble-bottom-left {
        left: 15px;
    }
    
    .wam-popup-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }
    
    .wam-popup.active .wam-popup-content {
        transform: none;
    }
}

/* WooCommerce Integration */
.woocommerce .wam-product-button-container {
    margin: 20px 0;
}

.woocommerce ul.products .wam-shop-button-container {
    margin-top: 10px;
}

.woocommerce ul.products .wam-shop-button {
    font-size: 12px;
    padding: 8px 12px;
}

/* Hide on specific pages */
.wam-hidden {
    display: none !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wam-bubble-content {
        border: 2px solid;
    }
    
    .wam-contact-button {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wam-bubble {
        animation: none;
    }
    
    .wam-popup,
    .wam-popup-content,
    .wam-contact-button,
    .wam-agent-card {
        transition: none;
    }
}