/**
 * Estilos para el Sistema de Mensajería
 * 
 * Uso público: Modal de contacto en productos y página de conversaciones
 *
 * @package WBP
 * @version 2.4.0
 */

/* ========================================
   Modal de Contacto en Producto
======================================== */

.wbp-contact-supplier-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #7c3085;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
}

.wbp-contact-supplier-btn:hover {
    background: #651f6d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 48, 133, 0.3);
}

.wbp-contact-supplier-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Modal Overlay */
.wbp-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    animation: fadeIn 0.3s ease;
}

.wbp-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

/* Modal Content */
.wbp-modal-content {
    background: white;
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
    position: relative;
}

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

/* Modal Header */
.wbp-modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wbp-modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wbp-modal-header .dashicons {
    color: #7c3085;
    font-size: 28px;
    width: 28px;
    height: 28px;
}

.wbp-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.wbp-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Modal Body */
.wbp-modal-body {
    padding: 30px;
}

.wbp-product-info {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 25px;
    border-left: 3px solid #7c3085;
}

.wbp-product-info p {
    margin: 5px 0;
    color: #666;
}

.wbp-product-info strong {
    color: #333;
}

/* Form Styles */
.wbp-contact-form .form-row {
    margin-bottom: 20px;
}

.wbp-contact-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.wbp-contact-form label .required {
    color: #d63638;
}

.wbp-contact-form input[type="text"],
.wbp-contact-form input[type="email"],
.wbp-contact-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.wbp-contact-form input:focus,
.wbp-contact-form textarea:focus {
    outline: none;
    border-color: #7c3085;
    box-shadow: 0 0 0 3px rgba(124, 48, 133, 0.1);
}

.wbp-contact-form textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.wbp-contact-form .form-note {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.wbp-contact-form .error {
    color: #d63638;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.wbp-contact-form .form-row.has-error input,
.wbp-contact-form .form-row.has-error textarea {
    border-color: #d63638;
}

.wbp-contact-form .form-row.has-error .error {
    display: block;
}

/* Modal Footer */
.wbp-modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f9f9f9;
}

.wbp-modal-footer button {
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.wbp-btn-cancel {
    background: #f0f0f1;
    color: #333;
}

.wbp-btn-cancel:hover {
    background: #e0e0e0;
}

.wbp-btn-send {
    background: #7c3085;
    color: white;
}

.wbp-btn-send:hover {
    background: #651f6d;
}

.wbp-btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.wbp-btn-send.sending {
    position: relative;
    padding-left: 45px;
}

.wbp-btn-send.sending::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 50%;
    margin-top: -8px;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Success Message */
.wbp-success-message {
    display: none;
    text-align: center;
    padding: 40px;
}

.wbp-success-message.active {
    display: block;
}

.wbp-success-icon {
    width: 64px;
    height: 64px;
    background: #46b450;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    animation: successPop 0.5s ease;
}

@keyframes successPop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.wbp-success-icon .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: white;
}

.wbp-success-message h3 {
    color: #333;
    margin-bottom: 10px;
}

.wbp-success-message p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.wbp-conversation-link {
    display: inline-block;
    padding: 10px 20px;
    background: #7c3085;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.2s;
    margin-top: 10px;
}

.wbp-conversation-link:hover {
    background: #651f6d;
    color: white;
    transform: translateY(-2px);
}

/* ========================================
   Página Pública de Conversación
======================================== */

.wbp-public-conversation {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}

.wbp-conversation-page-header {
    background: white;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wbp-conversation-page-header h1 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 28px;
}

.wbp-conversation-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    color: #666;
    font-size: 14px;
}

.wbp-conversation-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.wbp-conversation-meta .dashicons {
    color: #7c3085;
}

.wbp-status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.wbp-status-open {
    background: #d4edda;
    color: #155724;
}

.wbp-status-closed {
    background: #d6d8db;
    color: #383d41;
}

/* Messages List */
.wbp-public-messages {
    background: white;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wbp-public-message {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    animation: messageFadeIn 0.5s ease;
}

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

.wbp-message-avatar-public {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 24px;
}

.wbp-message-from-customer .wbp-message-avatar-public {
    background: #2271b1;
    color: white;
}

.wbp-message-from-supplier .wbp-message-avatar-public {
    background: #7c3085;
    color: white;
}

.wbp-public-message-content {
    flex: 1;
}

.wbp-public-message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.wbp-sender-name {
    font-weight: 600;
    color: #333;
}

.wbp-sender-badge {
    background: #7c3085;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}

.wbp-message-time-public {
    color: #999;
    font-size: 13px;
    margin-left: auto;
}

.wbp-public-message-body {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 6px;
    color: #333;
    line-height: 1.6;
}

.wbp-message-from-supplier .wbp-public-message-body {
    background: #f0e6f3;
}

/* Reply Form */
.wbp-public-reply-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wbp-public-reply-form h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

.wbp-public-reply-form textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    min-height: 150px;
    resize: vertical;
    transition: border-color 0.2s;
}

.wbp-public-reply-form textarea:focus {
    outline: none;
    border-color: #7c3085;
    box-shadow: 0 0 0 3px rgba(124, 48, 133, 0.1);
}

.wbp-public-reply-form button {
    margin-top: 15px;
    padding: 12px 30px;
    background: #7c3085;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.wbp-public-reply-form button:hover {
    background: #651f6d;
}

.wbp-public-reply-form button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Conversation Closed Notice */
.wbp-closed-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 20px;
    border-radius: 4px;
    color: #856404;
    text-align: center;
}

.wbp-closed-notice .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 5px;
}

/* ========================================
   Responsive
======================================== */

@media (max-width: 768px) {
    .wbp-modal-content {
        max-height: 100vh;
        border-radius: 0;
    }
    
    .wbp-modal-header,
    .wbp-modal-body,
    .wbp-modal-footer {
        padding: 20px;
    }
    
    .wbp-modal-header h2 {
        font-size: 20px;
    }
    
    .wbp-conversation-page-header,
    .wbp-public-messages,
    .wbp-public-reply-form {
        padding: 20px;
    }
    
    .wbp-public-message {
        flex-direction: column;
        gap: 10px;
    }
    
    .wbp-message-avatar-public {
        width: 40px;
        height: 40px;
    }
    
    .wbp-conversation-meta {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .wbp-contact-supplier-btn {
        width: 100%;
        justify-content: center;
    }
    
    .wbp-modal-footer {
        flex-direction: column;
    }
    
    .wbp-modal-footer button {
        width: 100%;
    }
}

/* ========================================
   Animaciones de carga
======================================== */

.wbp-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(124, 48, 133, 0.3);
    border-radius: 50%;
    border-top-color: #7c3085;
    animation: spin 1s ease-in-out infinite;
}

/* ========================================
   Accesibilidad
======================================== */

.wbp-contact-form input:focus-visible,
.wbp-contact-form textarea:focus-visible,
.wbp-public-reply-form textarea:focus-visible {
    outline: 2px solid #7c3085;
    outline-offset: 2px;
}

.wbp-modal-close:focus-visible,
button:focus-visible {
    outline: 2px solid #7c3085;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wbp-contact-supplier-btn,
    .wbp-btn-send,
    .wbp-public-reply-form button {
        border: 2px solid currentColor;
    }
}

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

