/**
 * Flatsome Addon - 优化版主样式文件
 * 版本: 优化版
 * 优化内容:
 * - 减少 !important 使用 (从17个减少到4个)
 * - 移除重复代码
 * - 重新组织CSS结构
 * - 优化选择器特异性
 */

/* ========================================
   CSS Reset & Base Styles
   ======================================== */

/* Phosphor图标基础样式 - 只在必要时使用 !important */
.flatsome-addon .ph {
    font-family: 'Phosphor', sans-serif;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 全局基础样式 */
.flatsome-addon-container {
    margin-bottom: 20px;
}

.flatsome-addon-element {
    margin-bottom: 20px;
}

.flatsome-addon-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

.flatsome-addon-content {
    line-height: 1.6;
}

/* ========================================
   Icons System - 图标系统
   ======================================== */

/* Shipping Protection 图标 - 使用更高特异性选择器避免 !important */
.flatsome-addon .shipping-protection-icon.ph.ph-shield-check,
.flatsome-addon-shipping-protection .shipping-protection-info .shipping-protection-icon.ph.ph-shield-check {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgZmlsbD0iIzRDQUY1MCIgdmlld0JveD0iMCAwIDI1NiAyNTYiPjxwYXRoIGQ9Ik0yMDgsNDBINDhBMTYsMTYsMCwwLDAsMzIsNTZ2NTZjMCw1Mi43MiwyNS41Miw4NC42Nyw0Ni45MywxMDIuMTksMjMuMDYsMTguODYsNDYsMjUuMjYsNDcsMjUuNTNhOCw4LDAsMCwwLDQuMiwwYzEtLjI3LDIzLjkxLTYuNjcsNDctMjUuNTNDMTk4LjQ4LDE5Ni42NywyMjQsMTY0LjcyLDIyNCwxMTJWNTZBMTYsMTYsMCwwLDAsMjA4LDQwWm0wLDcyYzAsMzcuMDctMTMuNjYsNjcuMTYtNDAuNiw4OS40MkExMjkuMywxMjkuMywwLDAsMSwxMjgsMjIzLjYyYTEyOC4yNSwxMjguMjUsMCwwLDEtMzguOTItMjEuODFDNjEuODIsMTc5LjUxLDQ4LDE0OS4zLDQ4LDExMmwwLTU2LDE2MCwwWk04Mi4zNCwxNDEuNjZhOCw4LDAsMCwxLDExLjMyLTExLjMyTDExMiwxNDguNjlsNTAuMzQtNTAuMzVhOCw4LDAsMCwxLDExLjMyLDExLjMybC01Niw1NmE4LDgsMCwwLDEtMTEuMzIsMFoiPjwvcGF0aD48L3N2Zz4=');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin-right: 8px;
    vertical-align: middle;
}

/* 移除伪元素内容 */
.flatsome-addon .shipping-protection-icon.ph.ph-shield-check:before {
    content: none !important; /* 保留此处的 !important，用于覆盖图标字体的伪元素 */
    display: none !important;
}

/* ========================================
   Product Landing Page Styles
   ======================================== */

.flatsome-addon-product-landing-content {
    margin: 30px 0;
    clear: both;
    width: 100%;
}

.flatsome-addon-product-landing-content .row {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* ========================================
   Components - Estimated Shipping
   ======================================== */

.flatsome-addon-estimated-shipping {
    display: flex;
    align-items: center;
    margin: 15px 0;
    padding: 10px 0;
}

.flatsome-addon-estimated-shipping i {
    font-size: 24px;
    margin-right: 10px;
    color: inherit;
}

.flatsome-addon-estimated-shipping span {
    font-size: inherit;
    color: inherit;
}

/* ========================================
   Components - Trust Badges
   ======================================== */

.flatsome-addon-trust-badges {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    padding: 10px 0;
}

.trust-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px;
    flex: 1;
}

.trust-badge i {
    font-size: 32px;
    margin-bottom: 8px;
    color: inherit;
}

.trust-badge img {
    height: 32px;
    width: auto;
    margin-bottom: 8px;
}

.trust-badge span {
    font-size: inherit;
    font-weight: 500;
    color: inherit;
}

/* ========================================
   Components - Product Description
   ======================================== */

.flatsome-addon-product-description {
    margin: 20px 0;
    padding-bottom: 20px;
}

.flatsome-addon-product-description h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #334862;
}

.flatsome-addon-product-description .description-content {
    font-size: inherit;
    line-height: 1.6;
    color: inherit;
}

/* ========================================
   Components - Accordion
   ======================================== */

.flatsome-addon-accordion {
    margin: 20px 0;
}

.accordion-item {
    border-bottom: 1px solid #ececec;
    position: relative;
}

.accordion-title {
    display: flex;
    align-items: center;
    padding: 15px 0;
    cursor: pointer;
    position: relative;
    transition: color 0.3s, border-color 0.3s;
    outline: none;
}

.accordion-title i:first-child {
    font-size: 16px;
    margin-right: 10px;
    color: inherit;
}

.accordion-title span {
    flex: 1;
    font-size: inherit;
    font-weight: 500;
    color: inherit;
}

.accordion-icon {
    font-size: 16px;
    color: inherit;
    transform-origin: center;
    transition: transform 0.3s;
}

.accordion-item.active .accordion-icon {
    transform: rotate(45deg);
}

.accordion-content {
    padding: 0 0 15px 26px;
    font-size: inherit;
    line-height: 1.6;
    color: inherit;
    overflow: hidden;
    transition: padding 0.3s;
}

.accordion-inner {
    padding: 0;
    overflow: hidden;
    transition: max-height 0.3s;
}

/* ========================================
   Shipping Protection - Main Component
   ======================================== */

.flatsome-addon-shipping-protection {
    margin-top: 15px;
    padding: 12px 0;
    border-top: 1px solid #e8e8e8;
    display: block;
    visibility: visible;
    opacity: 1;
}

/* 统一的内容布局 - 避免重复定义 */
.shipping-protection-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
}

.shipping-protection-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.shipping-protection-icon {
    font-size: 18px;
    margin-right: 8px;
    color: #4CAF50;
    transition: color 0.3s ease;
}

.shipping-protection-text {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
}

.shipping-protection-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shipping-protection-price {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    min-width: 40px;
    text-align: right;
}

/* ========================================
   Toggle Switch Component
   ======================================== */

.shipping-protection-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
    cursor: pointer;
}

.shipping-protection-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.shipping-protection-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 24px;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.shipping-protection-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Toggle states */
.shipping-protection-checkbox:checked + .shipping-protection-slider {
    background-color: #4CAF50;
    box-shadow: inset 0 2px 4px rgba(76, 175, 80, 0.3);
}

.shipping-protection-checkbox:checked + .shipping-protection-slider:before {
    transform: translateX(20px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.shipping-protection-checkbox:focus + .shipping-protection-slider {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

/* Hover effects */
.shipping-protection-switch:hover .shipping-protection-slider {
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.15);
}

.shipping-protection-switch:hover .shipping-protection-checkbox:checked + .shipping-protection-slider {
    background-color: #45a049;
    box-shadow: inset 0 2px 6px rgba(69, 160, 73, 0.4);
}

/* Disabled state */
.shipping-protection-checkbox:disabled + .shipping-protection-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   Theme Compatibility
   ======================================== */

/* Widget compatibility */
.widget_shopping_cart .flatsome-addon-shipping-protection {
    padding-left: 0;
    padding-right: 0;
}

/* Mini Cart styles */
.cart-popup-inner .flatsome-addon-shipping-protection,
.nav-dropdown .flatsome-addon-shipping-protection {
    margin-top: 10px;
    padding: 10px 15px;
    background-color: #f9f9f9;
    border-radius: 3px;
    border: 1px solid #e8e8e8;
}

/* Off-canvas cart styles */
.off-canvas-cart .flatsome-addon-shipping-protection {
    margin: 15px 0 0 0;
    padding: 12px 15px;
    background-color: #f8f8f8;
    border-radius: 4px;
}

/* ========================================
   Checkout Page Styles
   ======================================== */

.checkout-shipping-protection {
    background-color: #f9f9f9;
    border: 1px solid #e8e8e8;
    border-radius: 5px;
    margin-bottom: 20px;
    padding: 15px;
}

.checkout-shipping-protection .shipping-protection-info {
    align-items: flex-start;
}

.shipping-protection-text-wrapper {
    display: flex;
    flex-direction: column;
}

.shipping-protection-description {
    display: block;
    font-size: 12px;
    color: #666;
    font-weight: normal;
    margin-top: 2px;
    line-height: 1.3;
}

/* Checkout specific overrides */
.woocommerce-checkout .checkout-shipping-protection .shipping-protection-icon {
    font-size: 20px;
    margin-right: 10px;
    margin-top: 2px;
}

.woocommerce-checkout .checkout-shipping-protection .shipping-protection-price {
    font-size: 16px;
    font-weight: 700;
    color: #2e7d32;
}

/* Checkout toggle sizing */
.checkout-shipping-protection .shipping-protection-switch {
    width: 50px;
    height: 28px;
}

.checkout-shipping-protection .shipping-protection-slider:before {
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
}

.checkout-shipping-protection .shipping-protection-checkbox:checked + .shipping-protection-slider:before {
    transform: translateX(22px);
}

/* ========================================
   Admin Interface Styles
   ======================================== */

.flatsome-addon-metabox {
    margin: 15px 0;
}

.flatsome-addon-metabox-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.flatsome-addon-metabox-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.flatsome-addon-badge-settings,
.flatsome-addon-accordion-settings {
    margin-bottom: 15px;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #eee;
}

.flatsome-addon-badge-settings h4,
.flatsome-addon-accordion-settings h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
}

/* ========================================
   Interactive States & Animations
   ======================================== */

/* Loading state */
.shipping-protection-loading .shipping-protection-icon {
    animation: shipping-protection-pulse 1.5s infinite;
}

@keyframes shipping-protection-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Success state */
.shipping-protection-success .shipping-protection-icon {
    animation: shipping-protection-success 0.6s ease-out;
}

@keyframes shipping-protection-success {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); color: #4CAF50; }
    100% { transform: scale(1); }
}

/* Switch activation animation */
.shipping-protection-switch.active .shipping-protection-slider {
    animation: shipping-protection-switch-glow 0.3s ease-out;
}

@keyframes shipping-protection-switch-glow {
    0% { box-shadow: inset 0 2px 4px rgba(76, 175, 80, 0.3); }
    50% { box-shadow: inset 0 2px 8px rgba(76, 175, 80, 0.5), 0 0 8px rgba(76, 175, 80, 0.3); }
    100% { box-shadow: inset 0 2px 4px rgba(76, 175, 80, 0.3); }
}

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

/* Tablet styles */
@media (max-width: 849px) {
    .flatsome-addon-product-landing-content {
        margin: 20px 0;
    }
    
    .flatsome-addon-trust-badges {
        flex-wrap: wrap;
    }
    
    .trust-badge {
        flex: 0 0 33.33%;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    .flatsome-addon-title {
        font-size: 16px;
    }
    
    .flatsome-addon-shipping-protection {
        margin-top: 12px;
        padding: 10px 0;
    }
    
    .shipping-protection-icon {
        font-size: 16px;
        margin-right: 6px;
    }
    
    .shipping-protection-text,
    .shipping-protection-price {
        font-size: 13px;
    }
    
    .shipping-protection-controls {
        gap: 8px;
    }
    
    .shipping-protection-switch {
        width: 40px;
        height: 22px;
    }
    
    .shipping-protection-slider:before {
        height: 16px;
        width: 16px;
        left: 3px;
        bottom: 3px;
    }
    
    .shipping-protection-checkbox:checked + .shipping-protection-slider:before {
        transform: translateX(18px);
    }
    
    /* Checkout mobile styles */
    .checkout-shipping-protection {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .woocommerce-checkout .checkout-shipping-protection .shipping-protection-icon {
        font-size: 18px;
        margin-right: 8px;
    }
    
    .woocommerce-checkout .checkout-shipping-protection .shipping-protection-price {
        font-size: 15px;
    }
    
    .shipping-protection-description {
        font-size: 11px;
    }
    
    .checkout-shipping-protection .shipping-protection-switch {
        width: 44px;
        height: 24px;
    }
    
    .checkout-shipping-protection .shipping-protection-slider:before {
        height: 18px;
        width: 18px;
    }
    
    .checkout-shipping-protection .shipping-protection-checkbox:checked + .shipping-protection-slider:before {
        transform: translateX(20px);
    }
}

/* Small mobile styles */
@media (max-width: 549px) {
    .trust-badge {
        flex: 0 0 100%;
        margin-bottom: 10px;
    }
    
    .flatsome-addon-trust-badges {
        flex-direction: column;
    }
}
