/**
 * RP3 HivePress Compatibility Styles
 *
 * Este archivo resuelve conflictos visuales entre:
 * - Bootstrap (cargado por rp3store)
 * - HivePress CSS nativo
 * - Sistema Multi-Brand de RP3
 *
 * @package RP3_HivePress_Compat
 * @version 1.0.0
 */

/* ==========================================================================
   0. CRITICAL: Ocultar/Estilizar menú de usuario HivePress en header rp3store
   ========================================================================== */

/**
 * HivePress inyecta un menú de usuario (.menu-item--user-account) en el header
 * que aparece descuadrado. Estas reglas lo controlan.
 */

/* Opción 1: OCULTAR completamente el menú inyectado por HivePress en header */
/* rp3store tiene su propio menú de usuario, no necesitamos el de HivePress */
.top-header .menu-item--user-account,
.top-header .menu-item--user-login,
.top-header .menu-item--first,
.navbar .menu-item--user-account,
.navbar .menu-item--user-login,
.navbar-nav .menu-item--user-account,
.navbar-nav .menu-item--user-login,
.header .menu-item--user-account,
.header .menu-item--user-login,
/* Clase específica que HivePress agrega */
li.menu-item.menu-item--first {
    display: none !important;
}

/*
 * Nota: Si deseas MOSTRAR el menú de HivePress en lugar de ocultarlo:
 * 1. Comenta las reglas de display:none arriba
 * 2. En el plugin, cambia 'remove_hp_header_menu' => false en class-template-compat.php
 * 3. Agrega estilos personalizados aquí para el dropdown
 */

/* ==========================================================================
   1. CSS VARIABLES - Heredan de Multi-Brand
   ========================================================================== */

:root {
    /* Colores por defecto (Jandi) - sobrescritos por JS si multi-brand activo */
    --rp3-brand-primary: #F37021;
    --rp3-brand-secondary: #E5651C;
    --rp3-brand-accent: #FF8C42;

    /* Variables de HivePress personalizadas */
    --rp3-hp-border-radius: 8px;
    --rp3-hp-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --rp3-hp-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --rp3-hp-transition: all 0.3s ease;
}

/* ==========================================================================
   2. RESET: Evitar que Bootstrap afecte componentes HivePress
   ========================================================================== */

/* Formularios HivePress - Preservar estilos originales sobre Bootstrap */
.hp-form .form-control,
.hp-form input[type="text"],
.hp-form input[type="email"],
.hp-form input[type="password"],
.hp-form input[type="number"],
.hp-form input[type="tel"],
.hp-form input[type="url"],
.hp-form textarea {
    height: auto;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border: 1px solid #ddd;
    border-radius: var(--rp3-hp-border-radius);
    transition: var(--rp3-hp-transition);
}

.hp-form .form-control:focus,
.hp-form input:focus,
.hp-form textarea:focus {
    border-color: var(--rp3-brand-primary);
    box-shadow: 0 0 0 3px rgba(243, 112, 33, 0.1);
    outline: none;
}

/* Selects de HivePress */
.hp-form select.form-control,
.hp-form select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Botones HivePress - Estilo consistente con marca */
.hp-form .hp-button,
.hp-listing .hp-button,
.hp-vendor .hp-button,
button.hp-button,
a.hp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    border: none;
    border-radius: var(--rp3-hp-border-radius);
    cursor: pointer;
    transition: var(--rp3-hp-transition);
}

.hp-button--primary,
.hp-form button[type="submit"],
.hp-listing__action--primary {
    background-color: var(--rp3-brand-primary) !important;
    border-color: var(--rp3-brand-primary) !important;
    color: #fff !important;
}

.hp-button--primary:hover,
.hp-form button[type="submit"]:hover,
.hp-listing__action--primary:hover {
    background-color: var(--rp3-brand-secondary) !important;
    border-color: var(--rp3-brand-secondary) !important;
    transform: translateY(-1px);
    box-shadow: var(--rp3-hp-shadow-hover);
}

.hp-button--secondary {
    background-color: transparent;
    border: 2px solid var(--rp3-brand-primary);
    color: var(--rp3-brand-primary);
}

.hp-button--secondary:hover {
    background-color: var(--rp3-brand-primary);
    color: #fff;
}

/* ==========================================================================
   3. GRID: Compatibilidad Bootstrap 5 con HivePress Grid
   ========================================================================== */

/* HivePress usa su propio grid, no interferir */
.hp-grid {
    display: grid !important;
    gap: 24px;
}

/* Contenedor de listings */
.hp-listings {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* Grid responsivo para listings */
.hp-listings--view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

/* Asegurar que container de Bootstrap no rompa layout */
.rp3-hivepress-active .hp-page .container,
.rp3-hivepress-active .hp-page .container-fluid {
    max-width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}

/* ==========================================================================
   4. CARDS Y LISTINGS
   ========================================================================== */

/* Cards de listing */
.hp-listing--view-block {
    background: #fff;
    border-radius: var(--rp3-hp-border-radius);
    overflow: hidden;
    box-shadow: var(--rp3-hp-shadow);
    transition: var(--rp3-hp-transition);
}

.hp-listing--view-block:hover {
    box-shadow: var(--rp3-hp-shadow-hover);
    transform: translateY(-4px);
}

/* Imagen del listing */
.hp-listing__image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4/3;
}

.hp-listing__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--rp3-hp-transition);
}

.hp-listing--view-block:hover .hp-listing__image img {
    transform: scale(1.05);
}

/* Contenido del listing */
.hp-listing__content {
    padding: 16px;
}

/* Título del listing */
.hp-listing__title {
    margin: 0 0 8px;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

.hp-listing__title a {
    color: #333;
    text-decoration: none;
    transition: var(--rp3-hp-transition);
}

.hp-listing__title a:hover {
    color: var(--rp3-brand-primary);
}

/* Categoría del listing */
.hp-listing__category {
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.hp-listing__category a {
    color: var(--rp3-brand-primary);
    text-decoration: none;
}

/* Precio */
.hp-listing__price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--rp3-brand-primary);
}

/* ==========================================================================
   5. FORMULARIOS Y CHECKOUT
   ========================================================================== */

/* Mantener estilos de campos personalizados de rp3store */
.hp-form .woocommerce-billing-fields,
.hp-form .woocommerce-shipping-fields {
    /* Preservar layout de rp3-woocommerce.php */
}

/* Campos RUC/CI de Ecuador - No modificar */
#billing_ruc,
#billing_tipo_ruc,
#billing_tipo_user {
    /* Estilos manejados por rp3-woocommerce.css */
}

/* Form rows - Compatibilidad con grid de WooCommerce */
.hp-form .form-row {
    margin-bottom: 16px;
}

.hp-form .form-row-first,
.hp-form .form-row-last {
    width: 48%;
    display: inline-block;
    vertical-align: top;
}

.hp-form .form-row-first {
    float: left;
    margin-right: 4%;
}

.hp-form .form-row-last {
    float: right;
    margin-right: 0;
}

.hp-form .form-row-wide {
    width: 100%;
    clear: both;
}

/* Labels */
.hp-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
}

.hp-form label .required {
    color: #e74c3c;
}

/* ==========================================================================
   6. SELECT2: Evitar conflictos entre versiones
   ========================================================================== */

/* Ambos usan Select2, asegurar consistencia */
.hp-form .select2-container {
    width: 100% !important;
}

.hp-form .select2-container--default .select2-selection--single {
    height: 44px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: var(--rp3-hp-border-radius);
}

.hp-form .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 26px;
    padding-left: 0;
    color: #333;
}

.hp-form .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 42px;
}

.hp-form .select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--rp3-brand-primary);
    box-shadow: 0 0 0 3px rgba(243, 112, 33, 0.1);
}

/* Dropdown de Select2 */
.select2-dropdown {
    border-color: #ddd;
    border-radius: var(--rp3-hp-border-radius);
    box-shadow: var(--rp3-hp-shadow);
}

.select2-results__option--highlighted[aria-selected] {
    background-color: var(--rp3-brand-primary) !important;
}

/* ==========================================================================
   7. MODALES Y OVERLAYS
   ========================================================================== */

/* HivePress usa Fancybox, Bootstrap usa su propio modal */
/* Asegurar z-index correcto */
.fancybox-container {
    z-index: 99999 !important;
}

.fancybox-slide {
    padding: 20px;
}

.fancybox-content {
    border-radius: var(--rp3-hp-border-radius);
}

.hp-modal {
    z-index: 99998;
}

/* Bootstrap modal debajo de HivePress modals */
.modal {
    z-index: 1050;
}

.modal-backdrop {
    z-index: 1040;
}

/* ==========================================================================
   8. MENSAJES Y NOTIFICACIONES
   ========================================================================== */

/* rp3store remueve wc_print_notices, asegurar que HivePress notices se muestren */
.hp-messages,
.hp-notice {
    display: block !important;
    margin-bottom: 20px;
    padding: 16px 20px;
    border-radius: var(--rp3-hp-border-radius);
}

.hp-notice--success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.hp-notice--error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.hp-notice--warning {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

.hp-notice--info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* ==========================================================================
   9. VENDOR DASHBOARD
   ========================================================================== */

/* Dashboard de vendedor */
.hp-vendor-dashboard {
    padding: 20px 0;
}

.hp-vendor-dashboard .hp-menu {
    background: #f8f9fa;
    border-radius: var(--rp3-hp-border-radius);
    padding: 20px;
    margin-bottom: 30px;
}

.hp-vendor-dashboard .hp-menu__item {
    margin-bottom: 8px;
}

.hp-vendor-dashboard .hp-menu__item a {
    display: block;
    padding: 10px 16px;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: var(--rp3-hp-transition);
}

.hp-vendor-dashboard .hp-menu__item a:hover,
.hp-vendor-dashboard .hp-menu__item--current a {
    background-color: var(--rp3-brand-primary);
    color: #fff;
}

/* ==========================================================================
   10. HEADER INTEGRATION
   ========================================================================== */

/* Asegurar que header de HivePress respete estructura de rp3store */
.rp3-hivepress-active .hp-page-header {
    background-color: var(--rp3-brand-primary);
    padding: 40px 0;
    margin-bottom: 40px;
}

.hp-page-title {
    color: #fff;
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

.hp-page-description {
    color: rgba(255, 255, 255, 0.9);
    margin-top: 10px;
}

/* Breadcrumbs */
.hp-breadcrumbs {
    margin-bottom: 20px;
    font-size: 0.875rem;
}

.hp-breadcrumbs a {
    color: var(--rp3-brand-primary);
    text-decoration: none;
}

.hp-breadcrumbs a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   11. SEARCH AND FILTERS
   ========================================================================== */

/* Formulario de búsqueda de listings */
.hp-form--listing-search {
    background: #f8f9fa;
    padding: 24px;
    border-radius: var(--rp3-hp-border-radius);
    margin-bottom: 30px;
}

.hp-form--listing-search .hp-form__fields {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.hp-form--listing-search .hp-form__field {
    flex: 1;
    min-width: 200px;
}

.hp-form--listing-search .hp-form__actions {
    display: flex;
    align-items: flex-end;
}

/* Filtros laterales */
.hp-listing-filter {
    margin-bottom: 20px;
}

.hp-listing-filter__title {
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--rp3-brand-primary);
}

/* ==========================================================================
   12. CAROUSELS: Evitar conflicto Slick
   ========================================================================== */

/* rp3store y HivePress ambos usan Slick */
/* Namespace para evitar conflictos */
.hp-listing__images .slick-slider {
    /* Estilos específicos HivePress Slick */
}

.hp-listing__images .slick-slide img {
    width: 100%;
    height: auto;
}

.hp-listing__images .slick-dots {
    bottom: 15px;
}

.hp-listing__images .slick-dots li button:before {
    color: #fff;
    opacity: 0.5;
}

.hp-listing__images .slick-dots li.slick-active button:before {
    opacity: 1;
}

/* Slick de rp3store (sin afectar) */
.rp3-slider .slick-slider {
    /* Estilos específicos rp3store Slick - no modificar */
}

/* ==========================================================================
   13. FAVORITES (HivePress Extension)
   ========================================================================== */

.hp-listing__action--favorite {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--rp3-hp-shadow);
    transition: var(--rp3-hp-transition);
    z-index: 10;
}

.hp-listing__action--favorite:hover {
    transform: scale(1.1);
}

.hp-listing__action--favorite.hp-listing__action--favorited {
    color: #e74c3c;
}

/* ==========================================================================
   14. REVIEWS (HivePress Extension)
   ========================================================================== */

.hp-listing__rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.hp-rating__stars {
    color: #ffc107;
}

.hp-rating__count {
    color: #666;
    font-size: 0.875rem;
}

/* Review form */
.hp-form--review {
    background: #f8f9fa;
    padding: 24px;
    border-radius: var(--rp3-hp-border-radius);
}

/* ==========================================================================
   15. MESSAGES (HivePress Extension)
   ========================================================================== */

.hp-messages-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    border-radius: var(--rp3-hp-border-radius);
}

.hp-message {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #fff;
    border-radius: var(--rp3-hp-border-radius);
    box-shadow: var(--rp3-hp-shadow);
}

.hp-message--sent {
    background: var(--rp3-brand-primary);
    color: #fff;
    margin-left: 20%;
}

.hp-message--received {
    margin-right: 20%;
}

/* ==========================================================================
   16. GEOLOCATION (HivePress Extension)
   ========================================================================== */

.hp-listing-map {
    height: 400px;
    border-radius: var(--rp3-hp-border-radius);
    overflow: hidden;
    margin-bottom: 30px;
}

.hp-form__field--location input {
    padding-left: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 0a5 5 0 0 0-5 5c0 4.5 5 11 5 11s5-6.5 5-11a5 5 0 0 0-5-5zm0 7.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
}

/* ==========================================================================
   17. RESPONSIVE DESIGN
   ========================================================================== */

/* Tablet */
@media (max-width: 991px) {
    .hp-listings--view-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hp-form--listing-search .hp-form__fields {
        flex-direction: column;
    }

    .hp-form--listing-search .hp-form__field {
        min-width: 100%;
    }

    .hp-vendor-dashboard {
        flex-direction: column;
    }

    .hp-vendor-dashboard .hp-menu {
        margin-bottom: 20px;
    }
}

/* Mobile */
@media (max-width: 575px) {
    .hp-listings--view-grid {
        grid-template-columns: 1fr;
    }

    .hp-form .form-row-first,
    .hp-form .form-row-last {
        width: 100%;
        float: none;
        margin-right: 0;
    }

    .hp-page-header {
        padding: 24px 0;
    }

    .hp-page-title {
        font-size: 1.5rem;
    }

    .hp-listing--view-block {
        margin-bottom: 16px;
    }

    .hp-message--sent {
        margin-left: 10%;
    }

    .hp-message--received {
        margin-right: 10%;
    }
}

/* ==========================================================================
   18. PRINT STYLES
   ========================================================================== */

@media print {
    .hp-listing__action,
    .hp-form,
    .hp-messages,
    .hp-vendor-dashboard .hp-menu {
        display: none !important;
    }

    .hp-listing {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ==========================================================================
   19. DARK MODE SUPPORT (Future)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* Preparado para futuro soporte de dark mode */
    /* Descomentar cuando se implemente */
    /*
    .rp3-hivepress-active.dark-mode {
        --rp3-hp-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    */
}

/* ==========================================================================
   20. BRAND-SPECIFIC OVERRIDES
   ========================================================================== */

/* Jandi (Default) */
.rp3-hp-brand--jandi {
    --rp3-brand-primary: #F37021;
    --rp3-brand-secondary: #E5651C;
}

/* Ingco */
.rp3-hp-brand--ingco {
    --rp3-brand-primary: #FF6600;
    --rp3-brand-secondary: #E55C00;
}

/* Makita */
.rp3-hp-brand--makita {
    --rp3-brand-primary: #00A0D2;
    --rp3-brand-secondary: #0090BD;
}
