/**
 * 4Heed Customer Type - Main Styles
 * RTL Support & #E00D30 Brand Color
 */

/* ============================================
   POPUP/MODAL STYLES
   ============================================ */

#customer-type-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    direction: rtl;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
}

#customer-type-modal .fourheed-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    cursor: default;
}

/* MANDATORY MODE - Enhanced backdrop blocking */
#customer-type-modal.mandatory-selection .fourheed-popup-overlay {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    pointer-events: all !important;
    cursor: not-allowed !important;
    z-index: 999998;
}

/* MANDATORY MODE - Prevent interaction with content below */
#customer-type-modal.mandatory-selection {
    pointer-events: all !important;
}

/* MANDATORY MODE - Modal content should still be clickable */
#customer-type-modal.mandatory-selection .modal-content {
    pointer-events: all !important;
    user-select: none;
}

#customer-type-modal .modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    padding: 40px;

    /* FIXED DIMENSIONS - Prevent resize/jump */
    max-width: 600px;
    width: 90%;
    min-height: 400px;
    /* Stable height to prevent jump */

    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    z-index: 1000000;

    /* CRITICAL: No transitions on width/height */
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#customer-type-modal .modal-content h2 {
    margin: 0 0 10px;
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
}

#customer-type-modal .modal-content p {
    margin: 0 0 30px;
    font-size: 16px;
    color: #666;
}

/* Type Options */
.fourheed-type-options {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 20px;

    /* CRITICAL: Use opacity/visibility, NOT display:none */
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0s 0s;
}

/* When loading: hide options with opacity */
.is-loading .fourheed-type-options {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0s 0.2s;
}

.fourheed-type-option,
[data-customer-type] {
    flex: 1;
    max-width: 250px;
    padding: 30px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
    text-align: center;
}

.fourheed-type-option:hover,
[data-customer-type]:hover {
    border-color: #E00D30;
    background: #fff;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(224, 13, 48, 0.15);
}

/* Selected State - Red border only (NO checkmark) */
.fourheed-type-option.selected,
.fourheed-type-option.is-selected,
[data-customer-type].selected,
[data-customer-type].is-selected {
    position: relative;
    border-color: #E00D30;
    border-width: 3px;
    background: linear-gradient(135deg, #fff5f6 0%, #ffffff 100%);
    box-shadow: 0 8px 25px rgba(224, 13, 48, 0.3);
    transform: scale(1.05);
}

.fourheed-type-icon {
    margin-bottom: 15px;
}

.fourheed-type-icon svg {
    display: inline-block;
}

.fourheed-type-option h3,
[data-customer-type] h3 {
    margin: 0 0 10px;
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
}

.fourheed-type-option p,
[data-customer-type] p {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* ============================================
   LOADING OVERLAY - Position Absolute
   ============================================ */

/* Loading State - OVERLAY (not replacing content) */
.fourheed-popup-loading {
    /* Position absolute to overlay content */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    /* Centering */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    /* Background overlay */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);

    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    /* Smooth transition */
    transition: opacity 0.2s ease, visibility 0s 0.2s;

    /* Above content */
    z-index: 10;
}

/* Show loader when modal has is-loading class */
.is-loading .fourheed-popup-loading {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transition: opacity 0.2s ease, visibility 0s 0s;
}

.fourheed-popup-loading .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #E00D30;
    border-radius: 50%;
    animation: fourheed-spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes fourheed-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.fourheed-popup-loading p {
    margin: 0;
    font-size: 16px;
    color: #666;
}

/* ============================================
   SWITCH BUTTON - EXACT DESIGN REQUIREMENTS
   ============================================ */

/* Legacy button (still works if rendered directly) - NORMAL SIZE */
#customer-type-switch {
    /* Layout & Positioning */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    direction: rtl;

    /* Colors - EXACT AS REQUIRED */
    background: #E00D30;
    color: #FFFFFF;
    border: none;

    /* Shape - NORMAL CAPSULE */
    border-radius: 24px;
    padding: 10px 20px;

    /* Typography - NORMAL SIZE (fixed from 42px!) */
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Shadow & Interaction */
    box-shadow: 0 4px 12px rgba(224, 13, 48, 0.25);
    cursor: pointer;

    /* Transitions */
    transition: transform 0.12s ease, filter 0.12s ease;
}

#customer-type-switch:hover {
    filter: brightness(0.95);
}

#customer-type-switch:active {
    transform: translateY(1px);
}

/* WoodMart Shortcode Button - Scoped to prevent theme conflicts */
[data-ct-switch] {
    /* Layout & Positioning */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    direction: rtl;
    text-align: center;

    /* Colors - EXACT AS REQUIRED */
    background: #E00D30 !important;
    color: #FFFFFF !important;
    border: none !important;

    /* Shape - Capsule */
    border-radius: 999px !important;
    padding: 12px 28px !important;

    /* Typography */
    font-size: 16px !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    white-space: nowrap;

    /* Shadow & Interaction */
    box-shadow: 0 8px 16px rgba(224, 13, 48, 0.25) !important;
    cursor: pointer !important;

    /* Transitions */
    transition: all 0.2s ease !important;
}

/* Apply larger size in header context */
.wd-header [data-ct-switch],
.whb-header [data-ct-switch] {
    font-size: 16px !important;
    padding: 12px 30px !important;
}

[data-ct-switch]:hover {
    filter: brightness(0.95) !important;
    box-shadow: 0 10px 20px rgba(224, 13, 48, 0.35) !important;
    transform: translateY(-1px) !important;
}

[data-ct-switch]:active {
    transform: translateY(0) !important;
}


/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    #customer-type-modal .modal-content {
        padding: 30px 20px;
        width: 95%;
    }

    #customer-type-modal .modal-content h2 {
        font-size: 22px;
    }

    .fourheed-type-options {
        /*flex-direction: column;*/
        gap: 15px;
    }

    .fourheed-type-option,
    [data-customer-type] {
        max-width: 100%;
        padding: 25px 15px;
    }

    /* Floating button responsive - smaller on mobile */
    .fourheed-floating-switch-btn,
    #customer-type-switch {
        font-size: 16px !important;
        padding: 12px 24px !important;
        top: 10px !important;
        right: 10px !important;
    }
}

/* ============================================
   ADMIN STYLES
   ============================================ */

.fourheed-customer-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    direction: rtl;
}

.fourheed-customer-type-badge.personal {
    background: #e3f2fd;
    color: #1976d2;
}

.fourheed-customer-type-badge.business {
    background: #fff5f6;
    color: #E00D30;
}

/* Product Meta Fields in Admin */
.fourheed-product-fields {
    border-top: 1px solid #eee;
    padding-top: 20px;
    margin-top: 20px;
}

.fourheed-product-fields h4 {
    margin: 0 0 15px;
    color: #E00D30;
    font-size: 16px;
}

/* Business Price Badge on Products */
.fourheed-business-price-badge {
    display: inline-block;
    padding: 5px 12px;
    background: linear-gradient(135deg, #E00D30 0%, #c20b28 100%);
    color: #ffffff;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin: 5px 0;
    direction: rtl;
}

/* Notices */
.woocommerce-message.fourheed-notice,
.woocommerce-error.fourheed-notice {
    direction: rtl;
    text-align: right;
}

/* ============================================
   POPUP ENHANCEMENTS - Subtitles + Selected Highlight
   ============================================ */

/* Injected Subtitle Styling */
.fourheed-subtitle,
.fourheed-subtitle-native {
    font-size: 13px;
    color: #777;
    margin-top: 6px;
    line-height: 1.4;
    font-weight: 400;
    direction: rtl;
}

/* Ensure title is visually dominant */
.fourheed-type-option h3,
[data-customer-type] h3 {
    font-weight: 700;
    font-size: 22px;
    margin-bottom: 6px;
}

/* Card Default State */
.fourheed-type-option,
[data-customer-type] {
    border: 1px solid transparent;
    background: #f6f6f6;
    transition: all 220ms ease;
}

/* Card Hover State */
.fourheed-type-option:hover,
[data-customer-type]:hover {
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* SELECTED CARD - Active Highlight */
.fourheed-active-card,
.fourheed-type-option.fourheed-active-card,
[data-customer-type].fourheed-active-card {
    border: 2px solid #E00D30 !important;
    box-shadow: 0 0 0 4px rgba(224, 13, 48, 0.12), 0 8px 20px rgba(224, 13, 48, 0.15) !important;
    background: #fff !important;
    transform: scale(1.02) !important;
}

/* Micro-animation on selection */
.fourheed-active-card {
    animation: card-select-pulse 0.4s ease-out;
}

@keyframes card-select-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1.02);
    }
}

/* Prevent subtitle duplication - hide any duplicates */
[data-fourheed-subtitle]+[data-fourheed-subtitle],
.fourheed-subtitle+.fourheed-subtitle {
    display: none !important;
}