/**
 * 子比主题会员插件 - 兼容性样式
 * 用于解决不同主题和环境的显示问题
 */

/* 基础兼容性 */
.zibll-membership-page,
.zibll-membership-comparison,
.zibll-frontend-post-wrapper {
    box-sizing: border-box;
}

.zibll-membership-page *,
.zibll-membership-comparison *,
.zibll-frontend-post-wrapper * {
    box-sizing: inherit;
}

/* 清除浮动 */
.zibll-membership-page::after,
.zibll-membership-comparison::after,
.zibll-frontend-post-wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/* 移动端兼容性 */
@media screen and (max-width: 768px) {
    .zibll-membership-page,
    .zibll-membership-comparison,
    .zibll-frontend-post-wrapper {
        padding: 10px;
        margin: 0 -10px;
    }
    
    .comparison-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .comparison-card {
        margin-bottom: 15px !important;
    }
    
    .form-group {
        margin-bottom: 15px !important;
    }
    
    .form-control {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* 表单兼容性 */
.zibll-post-form .form-group {
    margin-bottom: 20px;
}

.zibll-post-form .form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
}

.zibll-post-form textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.zibll-post-form select.form-control {
    height: auto;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 16px 12px;
}

/* 按钮兼容性 */
.zibll-post-form .btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1.5;
}

.zibll-post-form .btn-primary {
    color: #fff;
    background-color: #007cba;
    border-color: #007cba;
}

.zibll-post-form .btn-primary:hover {
    background-color: #006ba1;
    border-color: #006ba1;
}

.zibll-post-form .btn-outline {
    color: #007cba;
    background-color: transparent;
    border-color: #007cba;
}

.zibll-post-form .btn-outline:hover {
    color: #fff;
    background-color: #007cba;
    border-color: #007cba;
}

.zibll-post-form .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 编辑器兼容性 */
.zibll-post-form .wp-editor-wrap {
    border: 1px solid #ddd;
    border-radius: 4px;
}

.zibll-post-form .wp-editor-tools {
    background: #f5f5f5;
    padding: 5px;
    border-bottom: 1px solid #ddd;
}

.zibll-post-form .wp-editor-container {
    border: none;
}

/* 短代码兼容性 */
.member-content-restricted,
.member-download-restricted {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
}

.member-content-restricted .restricted-icon,
.member-download-restricted .restricted-icon {
    font-size: 48px;
    color: #6c757d;
    margin-bottom: 15px;
}

.member-content-restricted h3,
.member-download-restricted h3 {
    margin: 0 0 10px 0;
    color: #495057;
}

.member-content-restricted p,
.member-download-restricted p {
    margin: 0 0 15px 0;
    color: #6c757d;
}

/* 弹窗兼容性 */
.zibll-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    overflow-y: auto;
}

.zibll-modal .modal-content {
    position: relative;
    background: #fff;
    margin: 50px auto;
    padding: 0;
    width: 90%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.zibll-modal .modal-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.zibll-modal .modal-body {
    padding: 20px;
}

.zibll-modal .modal-footer {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    text-align: right;
}

.zibll-modal .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
}

.zibll-modal .modal-close:hover {
    color: #495057;
}

/* 表格兼容性 */
.zibll-membership-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.zibll-membership-table th,
.zibll-membership-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.zibll-membership-table th {
    background: #f8f9fa;
    font-weight: 600;
}

.zibll-membership-table tr:hover {
    background: #f8f9fa;
}

/* 卡片兼容性 */
.zibll-membership-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.zibll-membership-card .card-header {
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.zibll-membership-card .card-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.zibll-membership-card .card-body {
    padding: 0;
}

.zibll-membership-card .card-footer {
    border-top: 1px solid #e9ecef;
    padding-top: 15px;
    margin-top: 15px;
}

/* 徽章兼容性 */
.member-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    vertical-align: middle;
    margin-left: 5px;
    line-height: 1.2;
}

.member-badge .badge-icon {
    font-size: 10px;
}

/* 加载状态兼容性 */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误状态兼容性 */
.error-message {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 10px 15px;
    margin: 10px 0;
}

.success-message {
    color: #155724;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    padding: 10px 15px;
    margin: 10px 0;
}

.warning-message {
    color: #856404;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 10px 15px;
    margin: 10px 0;
}

/* 工具提示兼容性 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* 响应式网格兼容性 */
.zibll-grid {
    display: grid;
    gap: 20px;
}

.zibll-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.zibll-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.zibll-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media screen and (max-width: 768px) {
    .zibll-grid-2,
    .zibll-grid-3,
    .zibll-grid-4 {
        grid-template-columns: 1fr;
    }
}

/* 主题兼容性修复 */
/* 修复某些主题的全局样式影响 */
.zibll-membership-page h1,
.zibll-membership-page h2,
.zibll-membership-page h3,
.zibll-membership-page h4,
.zibll-membership-page h5,
.zibll-membership-page h6 {
    margin: 0 0 15px 0;
    line-height: 1.4;
}

.zibll-membership-page p {
    margin: 0 0 15px 0;
    line-height: 1.6;
}

.zibll-membership-page ul,
.zibll-membership-page ol {
    margin: 0 0 15px 0;
    padding-left: 20px;
}

.zibll-membership-page li {
    margin: 5px 0;
}

/* 修复WordPress默认样式影响 */
.zibll-membership-page .wp-block-image {
    margin: 0;
}

.zibll-membership-page .wp-block-image img {
    max-width: 100%;
    height: auto;
}

/* 修复Bootstrap冲突 */
.zibll-membership-page .container,
.zibll-membership-page .row,
.zibll-membership-page .col {
    all: unset;
}

/* 修复Elementor冲突 */
.elementor-widget-zibll-membership .zibll-membership-page {
    all: unset;
}

/* 修复WooCommerce冲突 */
.woocommerce .zibll-membership-page {
    all: unset;
}

/* 修复Avada冲突 */
.fusion-body .zibll-membership-page {
    all: unset;
}

/* 修复Divi冲突 */
.et_pb_section .zibll-membership-page {
    all: unset;
}

/* 修复Astra冲突 */
.ast-container .zibll-membership-page {
    all: unset;
}

/* 修复GeneratePress冲突 */
.grid-container .zibll-membership-page {
    all: unset;
}

/* 修复OceanWP冲突 */
#content .zibll-membership-page {
    all: unset;
}

/* 修复Neve冲突 */
.nv-content-wrap .zibll-membership-page {
    all: unset;
}

/* 修复Twenty系列主题冲突 */
.entry-content .zibll-membership-page {
    all: unset;
}

/* 修复自定义CSS变量冲突 */
.zibll-membership-page {
    --primary-color: #007cba;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
}

/* 打印样式兼容性 */
@media print {
    .zibll-membership-page,
    .zibll-membership-comparison,
    .zibll-frontend-post-wrapper {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
    
    .zibll-modal {
        display: none !important;
    }
    
    .btn,
    .button {
        display: none !important;
    }
}

/* 高对比度模式兼容性 */
@media (prefers-contrast: high) {
    .zibll-membership-page,
    .zibll-membership-comparison,
    .zibll-frontend-post-wrapper {
        border: 2px solid currentColor;
    }
    
    .btn-primary {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
}

/* 减少动画兼容性 */
@media (prefers-reduced-motion: reduce) {
    .zibll-membership-page *,
    .zibll-membership-comparison *,
    .zibll-frontend-post-wrapper * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}