/**
 * Interactive Body Chart - Frontend Styles
 * 
 * @package Interactive_Body_Chart
 * @since 1.0.2
 */

/* ========================================
   Container & Wrapper Styles
   ======================================== */

.ibc-body-chart-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.ibc-body-chart-wrapper {
    position: relative;
    width: 100%;
    display: inline-block;
}

.ibc-body-image {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.ibc-placeholder {
    width: 100%;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5;
    color: #666;
    font-size: 14px;
    text-align: center;
    padding: 20px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    box-sizing: border-box;
}

.ibc-body-parts-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ========================================
   Body Part Container Styles
   ======================================== */

.ibc-body-part {
    position: absolute;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;
    pointer-events: auto;
    cursor: pointer;
    text-decoration: none;
    outline: none;
    z-index: 10;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
}

.ibc-body-part:focus {
    outline: 2px solid #f5a623;
    outline-offset: 4px;
    border-radius: 4px;
}

/* LEFT POSITIONED: Label on left, then line, then marker on the right */
.ibc-body-part.position-left {
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
}

/* RIGHT POSITIONED: Marker on left, then line, then label on the right */
.ibc-body-part.position-right {
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
}

/* ========================================
   Marker Styles
   ======================================== */

.ibc-marker {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    background-color: #f5a623;
    border-radius: 50%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -o-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    -webkit-box-shadow: 0 2px 8px rgba(245, 166, 35, 0.4);
    box-shadow: 0 2px 8px rgba(245, 166, 35, 0.4);
    -ms-flex-negative: 0;
    flex-shrink: 0;
    position: relative;
}

/* For LEFT position: marker is LAST (order 3), positioned at the right edge */
/* Order: Label (1) -> Line (2) -> Marker (3) */
.ibc-body-part.position-left .ibc-marker {
    -webkit-box-ordinal-group: 4;
    -ms-flex-order: 3;
    order: 3;
}

/* For RIGHT position: marker is FIRST (order 1), positioned at the left edge */
/* Order: Marker (1) -> Line (2) -> Label (3) */
.ibc-body-part.position-right .ibc-marker {
    -webkit-box-ordinal-group: 2;
    -ms-flex-order: 1;
    order: 1;
}

.ibc-marker-inner {
    width: 50%;
    height: 50%;
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    -webkit-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

/* Pulse animation for markers */
.marker-pulse .ibc-marker::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: inherit;
    opacity: 0;
    -webkit-animation: markerPulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    animation: markerPulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    pointer-events: none;
}

@-webkit-keyframes markerPulse {
    0% {
        -webkit-transform: scale(1);
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        -webkit-transform: scale(2);
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes markerPulse {
    0% {
        -webkit-transform: scale(1);
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        -webkit-transform: scale(2);
        transform: scale(2);
        opacity: 0;
    }
}

/* ========================================
   Line Styles
   ======================================== */

.ibc-line {
    height: 2px;
    background-color: #3a4a5c;
    width: 60px;
    min-width: 10px;
    -webkit-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -o-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -ms-flex-negative: 0;
    flex-shrink: 0;
    display: block;
}

/* For LEFT position: line is in the MIDDLE (order 2) */
.ibc-body-part.position-left .ibc-line {
    -webkit-box-ordinal-group: 3;
    -ms-flex-order: 2;
    order: 2;
    -webkit-transform-origin: right center;
    -ms-transform-origin: right center;
    transform-origin: right center;
}

/* For RIGHT position: line is in the MIDDLE (order 2) */
.ibc-body-part.position-right .ibc-line {
    -webkit-box-ordinal-group: 3;
    -ms-flex-order: 2;
    order: 2;
    -webkit-transform-origin: left center;
    -ms-transform-origin: left center;
    transform-origin: left center;
}

/* Line animation on load */
.animation-enabled:not(.animated) .ibc-line {
    -webkit-transform: scaleX(0);
    -ms-transform: scaleX(0);
    transform: scaleX(0);
}

.animation-enabled.animated .ibc-line {
    -webkit-transform: scaleX(1);
    -ms-transform: scaleX(1);
    transform: scaleX(1);
}

/* ========================================
   Label Styles
   ======================================== */

.ibc-label {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    white-space: nowrap;
    -webkit-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -o-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 4px 8px;
    background-color: transparent;
    border-radius: 4px;
    display: block;
}

/* For LEFT position: label is FIRST (order 1) */
.ibc-body-part.position-left .ibc-label {
    -webkit-box-ordinal-group: 2;
    -ms-flex-order: 1;
    order: 1;
    text-align: right;
    padding-right: 8px;
}

/* For RIGHT position: label is LAST (order 3) */
.ibc-body-part.position-right .ibc-label {
    -webkit-box-ordinal-group: 4;
    -ms-flex-order: 3;
    order: 3;
    text-align: left;
    padding-left: 8px;
}

/* Label animation on load */
.animation-enabled:not(.animated) .ibc-label {
    opacity: 0;
}

.animation-enabled:not(.animated) .ibc-body-part.position-left .ibc-label {
    -webkit-transform: translateX(10px);
    -ms-transform: translateX(10px);
    transform: translateX(10px);
}

.animation-enabled:not(.animated) .ibc-body-part.position-right .ibc-label {
    -webkit-transform: translateX(-10px);
    -ms-transform: translateX(-10px);
    transform: translateX(-10px);
}

.animation-enabled.animated .ibc-label {
    opacity: 1;
    -webkit-transform: translateX(0);
    -ms-transform: translateX(0);
    transform: translateX(0);
}

/* ========================================
   Hover Effects
   ======================================== */

/* Highlight All */
.hover-effect-highlight-all .ibc-body-part:hover .ibc-marker,
.hover-effect-highlight-all .ibc-body-part:focus .ibc-marker {
    -webkit-box-shadow: 0 4px 16px rgba(245, 166, 35, 0.6);
    box-shadow: 0 4px 16px rgba(245, 166, 35, 0.6);
    background-color: #e8940f;
    -webkit-transform: scale(1.3);
    -ms-transform: scale(1.3);
    transform: scale(1.3);
}

.hover-effect-highlight-all .ibc-body-part:hover .ibc-line,
.hover-effect-highlight-all .ibc-body-part:focus .ibc-line {
    background-color: #f5a623;
    height: 3px;
}

.hover-effect-highlight-all .ibc-body-part:hover .ibc-label,
.hover-effect-highlight-all .ibc-body-part:focus .ibc-label {
    color: #f5a623;
    font-weight: 600;
}

/* Highlight Marker Only */
.hover-effect-highlight-marker .ibc-body-part:hover .ibc-marker,
.hover-effect-highlight-marker .ibc-body-part:focus .ibc-marker {
    -webkit-transform: scale(1.5);
    -ms-transform: scale(1.5);
    transform: scale(1.5);
    -webkit-box-shadow: 0 4px 20px rgba(245, 166, 35, 0.7);
    box-shadow: 0 4px 20px rgba(245, 166, 35, 0.7);
}

/* Highlight Line Only */
.hover-effect-highlight-line .ibc-body-part:hover .ibc-line,
.hover-effect-highlight-line .ibc-body-part:focus .ibc-line {
    background-color: #f5a623;
    height: 4px;
}

/* Highlight Label Only */
.hover-effect-highlight-label .ibc-body-part:hover .ibc-label,
.hover-effect-highlight-label .ibc-body-part:focus .ibc-label {
    color: #f5a623;
    font-weight: 700;
    font-size: 16px;
}

/* Scale Effect */
.hover-effect-scale .ibc-body-part:hover,
.hover-effect-scale .ibc-body-part:focus {
    -webkit-transform: translateY(-50%) scale(1.05);
    -ms-transform: translateY(-50%) scale(1.05);
    transform: translateY(-50%) scale(1.05);
}

/* Glow Effect */
.hover-effect-glow .ibc-body-part:hover .ibc-marker,
.hover-effect-glow .ibc-body-part:focus .ibc-marker {
    -webkit-box-shadow: 
        0 0 10px #f5a623,
        0 0 20px #f5a623,
        0 0 30px rgba(245, 166, 35, 0.5),
        0 0 40px rgba(245, 166, 35, 0.3);
    box-shadow: 
        0 0 10px #f5a623,
        0 0 20px #f5a623,
        0 0 30px rgba(245, 166, 35, 0.5),
        0 0 40px rgba(245, 166, 35, 0.3);
}

.hover-effect-glow .ibc-body-part:hover .ibc-line,
.hover-effect-glow .ibc-body-part:focus .ibc-line {
    -webkit-box-shadow: 0 0 10px rgba(245, 166, 35, 0.5);
    box-shadow: 0 0 10px rgba(245, 166, 35, 0.5);
}

.hover-effect-glow .ibc-body-part:hover .ibc-label,
.hover-effect-glow .ibc-body-part:focus .ibc-label {
    text-shadow: 0 0 10px rgba(245, 166, 35, 0.5);
}

/* ========================================
   Animation States
   ======================================== */

.animation-enabled:not(.animated) .ibc-body-part {
    opacity: 0;
}

.animation-enabled.animated .ibc-body-part {
    opacity: 1;
    -webkit-transition: opacity 0.3s ease;
    -o-transition: opacity 0.3s ease;
    transition: opacity 0.3s ease;
}

/* ========================================
   Mobile Toggle View
   ======================================== */

/* Hide mobile toggle and mobile views on desktop */
.ibc-mobile-toggle {
    display: none;
}

.ibc-mobile-view {
    display: none;
}

.ibc-desktop-view {
    display: block;
}

/* Mobile Toggle Button Styles */
.ibc-mobile-toggle {
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    margin-bottom: 15px;
    background-color: #f0f0f0;
    border-radius: 8px;
    padding: 4px;
    gap: 0;
}

.ibc-toggle-btn {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    padding: 12px 24px;
    border: none;
    background-color: transparent;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    -webkit-transition: all 0.25s ease;
    -o-transition: all 0.25s ease;
    transition: all 0.25s ease;
    text-align: center;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.ibc-toggle-btn:focus {
    outline: 2px solid #f5a623;
    outline-offset: 2px;
}

.ibc-toggle-btn.active {
    background-color: #f5a623;
    color: #fff;
    -webkit-box-shadow: 0 2px 8px rgba(245, 166, 35, 0.3);
    box-shadow: 0 2px 8px rgba(245, 166, 35, 0.3);
}

.ibc-toggle-btn:not(.active):hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* ========================================
   Responsive Styles - Tablet
   ======================================== */

@media screen and (max-width: 1024px) {
    .ibc-label {
        font-size: 12px;
    }
    
    .ibc-marker {
        width: 16px;
        height: 16px;
        min-width: 16px;
        min-height: 16px;
    }
}

/* ========================================
   Responsive Styles - Mobile
   ======================================== */

@media screen and (max-width: 767px) {
    .ibc-body-chart-container {
        padding: 5px;
    }
    
    /* Mobile Toggle View - Show/Hide */
    .mobile-toggle-enabled .ibc-mobile-toggle {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
    }
    
    .mobile-toggle-enabled .ibc-desktop-view {
        display: none;
    }
    
    .mobile-toggle-enabled .ibc-mobile-view {
        display: none;
    }
    
    .mobile-toggle-enabled .ibc-mobile-view.active {
        display: block;
    }
    
    .ibc-marker {
        width: 18px;
        height: 18px;
        min-width: 18px;
        min-height: 18px;
        -webkit-box-shadow: 0 2px 8px rgba(245, 166, 35, 0.5);
        box-shadow: 0 2px 8px rgba(245, 166, 35, 0.5);
    }
    
    .ibc-label {
        font-size: 11px;
        padding: 2px 4px;
        background-color: transparent;
        border-radius: 0;
        -webkit-box-shadow: none;
        box-shadow: none;
    }
    
    /* Larger touch targets on mobile */
    .ibc-body-part {
        padding: 5px;
        margin: -5px;
    }
    
    /* Hide labels on mobile option */
    .hide-labels-mobile .ibc-label {
        display: none;
    }
    
    .hide-labels-mobile .ibc-line {
        display: none;
    }
    
    /* Show label on active/focus for mobile */
    .hide-labels-mobile .ibc-body-part:active .ibc-label,
    .hide-labels-mobile .ibc-body-part:focus .ibc-label,
    .hide-labels-mobile .ibc-body-part.active .ibc-label {
        display: block;
        position: absolute;
        bottom: calc(100% + 10px);
        left: 50%;
        -webkit-transform: translateX(-50%);
        -ms-transform: translateX(-50%);
        transform: translateX(-50%);
        white-space: nowrap;
        background-color: rgba(0, 0, 0, 0.9);
        color: #fff;
        padding: 8px 12px;
        border-radius: 4px;
        z-index: 100;
        font-size: 12px;
    }
    
    .hide-labels-mobile .ibc-body-part:active .ibc-label::after,
    .hide-labels-mobile .ibc-body-part:focus .ibc-label::after,
    .hide-labels-mobile .ibc-body-part.active .ibc-label::after {
        content: '';
        position: absolute;
        top: 100%;
        left: 50%;
        -webkit-transform: translateX(-50%);
        -ms-transform: translateX(-50%);
        transform: translateX(-50%);
        border: 6px solid transparent;
        border-top-color: rgba(0, 0, 0, 0.9);
    }
}

/* ========================================
   Responsive Styles - Small Mobile
   ======================================== */

@media screen and (max-width: 480px) {
    .ibc-marker {
        width: 16px;
        height: 16px;
        min-width: 16px;
        min-height: 16px;
    }
    
    .ibc-label {
        font-size: 10px;
    }
    
    .ibc-toggle-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* ========================================
   Elementor Editor Specific Styles
   ======================================== */

.elementor-editor-active .ibc-body-chart-container {
    /* Always show elements in editor */
}

.elementor-editor-active .ibc-body-part {
    opacity: 1 !important;
}

.elementor-editor-active .ibc-line {
    -webkit-transform: scaleX(1) !important;
    -ms-transform: scaleX(1) !important;
    transform: scaleX(1) !important;
}

.elementor-editor-active .ibc-label {
    opacity: 1 !important;
    -webkit-transform: translateX(0) !important;
    -ms-transform: translateX(0) !important;
    transform: translateX(0) !important;
}

/* Editor Preview Mode - Desktop */
.elementor-editor-active .editor-preview-desktop .ibc-desktop-view {
    display: block !important;
}

.elementor-editor-active .editor-preview-desktop .ibc-mobile-view {
    display: none !important;
}

.elementor-editor-active .editor-preview-desktop .ibc-mobile-toggle {
    display: none !important;
}

/* Editor Preview Mode - Mobile Front */
.elementor-editor-active .editor-preview-mobile-front .ibc-desktop-view {
    display: none !important;
}

.elementor-editor-active .editor-preview-mobile-front .ibc-mobile-toggle {
    display: -webkit-box !important;
    display: -ms-flexbox !important;
    display: flex !important;
}

.elementor-editor-active .editor-preview-mobile-front .ibc-mobile-view {
    display: none !important;
}

.elementor-editor-active .editor-preview-mobile-front .ibc-front-view {
    display: block !important;
}

.elementor-editor-active .editor-preview-mobile-front .ibc-toggle-btn[data-view="front"] {
    background-color: #f5a623 !important;
    color: #fff !important;
}

.elementor-editor-active .editor-preview-mobile-front .ibc-toggle-btn[data-view="back"] {
    background-color: transparent !important;
    color: #333 !important;
}

/* Editor Preview Mode - Mobile Back */
.elementor-editor-active .editor-preview-mobile-back .ibc-desktop-view {
    display: none !important;
}

.elementor-editor-active .editor-preview-mobile-back .ibc-mobile-toggle {
    display: -webkit-box !important;
    display: -ms-flexbox !important;
    display: flex !important;
}

.elementor-editor-active .editor-preview-mobile-back .ibc-mobile-view {
    display: none !important;
}

.elementor-editor-active .editor-preview-mobile-back .ibc-back-view {
    display: block !important;
}

.elementor-editor-active .editor-preview-mobile-back .ibc-toggle-btn[data-view="back"] {
    background-color: #f5a623 !important;
    color: #fff !important;
}

.elementor-editor-active .editor-preview-mobile-back .ibc-toggle-btn[data-view="front"] {
    background-color: transparent !important;
    color: #333 !important;
}

/* Highlight body part being edited */
.elementor-editor-active .ibc-body-part:hover {
    outline: 2px dashed #71d7f7;
    outline-offset: 4px;
}

/* Show coordinates helper in editor */
.elementor-editor-active .ibc-body-part::before {
    content: attr(data-x) '%, ' attr(data-y) '%';
    position: absolute;
    top: -20px;
    left: 50%;
    -webkit-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    transform: translateX(-50%);
    font-size: 10px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    opacity: 0;
    -webkit-transition: opacity 0.2s ease;
    -o-transition: opacity 0.2s ease;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 100;
}

.elementor-editor-active .ibc-body-part:hover::before {
    opacity: 1;
}

/* ========================================
   Accessibility
   ======================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ibc-marker {
        border: 2px solid #000;
    }
    
    .ibc-line {
        height: 3px;
    }
    
    .ibc-label {
        font-weight: 600;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ibc-marker,
    .ibc-line,
    .ibc-label,
    .ibc-body-part {
        -webkit-transition: none !important;
        -o-transition: none !important;
        transition: none !important;
        -webkit-animation: none !important;
        animation: none !important;
    }
    
    .marker-pulse .ibc-marker::after {
        -webkit-animation: none;
        animation: none;
    }
    
    .animation-enabled .ibc-body-part,
    .animation-enabled .ibc-line,
    .animation-enabled .ibc-label {
        opacity: 1 !important;
        -webkit-transform: none !important;
        -ms-transform: none !important;
        transform: none !important;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .ibc-marker::after {
        display: none;
    }
    
    .ibc-label {
        font-size: 10pt;
    }
    
    .ibc-body-part {
        opacity: 1 !important;
    }
}
