/**
 * Advanced Content Toggle Plugin CSS - 优化版本
 * 版本: 2.0.0
 * 增强安全性、性能和兼容性
 */

/* 基础样式 */
.act-toggle {
    margin-bottom: 20px;
    background-color: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    font-family: inherit;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
    position: relative;
}

.act-toggle:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* 标题样式 */
.act-toggle-title {
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    background-color: #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    user-select: none;
    position: relative;
    border: none;
    width: 100%;
    text-align: left;
}

.act-toggle-title:hover {
    background-color: #e8e8e8;
}

.act-toggle-title:focus {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

.act-toggle-text {
    flex-grow: 1;
    line-height: 1.4;
}

/* 图标样式 - 优化动画性能 */
.act-toggle-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 12px;
    position: relative;
    flex-shrink: 0;
    transform: translateZ(0); /* 启用硬件加速 */
}

.act-toggle-icon:before,
.act-toggle-icon:after {
    content: '';
    position: absolute;
    background-color: #555;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform; /* 优化动画性能 */
}

/* 水平线 */
.act-toggle-icon:before {
    width: 100%;
    height: 2px;
    top: 9px;
    left: 0;
}

/* 垂直线 */
.act-toggle-icon:after {
    width: 2px;
    height: 100%;
    top: 0;
    left: 9px;
}

/* 展开状态图标 */
.act-toggle.expanded .act-toggle-icon:after {
    transform: rotate(90deg);
    opacity: 0;
}

/* 内容区域 */
.act-toggle-content {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: #fff;
}

.act-toggle.expanded .act-toggle-content {
    padding: 20px;
    max-height: 9999px; /* 使用更大的值确保内容完全显示 */
}

/* hide短代码特殊样式 */
.act-toggle.act-hide {
    border-color: #ffc107;
    background-color: #fff8e1;
}

.act-toggle.act-hide .act-toggle-title {
    background-color: #fff3cd;
    color: #856404;
}

.act-toggle.act-hide .act-toggle-title:hover {
    background-color: #ffeaa7;
}

.act-toggle.act-hide .act-toggle-icon:before,
.act-toggle.act-hide .act-toggle-icon:after {
    background-color: #856404;
}

/* 登录要求提示 */
.act-hide-login-required {
    padding: 15px 20px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
}

/* 预设主题样式 */
.act-toggle.act-blue {
    border-color: #ccddf1;
    background-color: #f0f7ff;
}

.act-toggle.act-blue .act-toggle-title {
    background-color: #e6f0fa;
    color: #0066cc;
}

.act-toggle.act-blue .act-toggle-title:hover {
    background-color: #d1e4f7;
}

.act-toggle.act-blue .act-toggle-icon:before,
.act-toggle.act-blue .act-toggle-icon:after {
    background-color: #0066cc;
}

.act-toggle.act-green {
    border-color: #d0f0c0;
    background-color: #f0fff0;
}

.act-toggle.act-green .act-toggle-title {
    background-color: #e6f7e6;
    color: #28a745;
}

.act-toggle.act-green .act-toggle-title:hover {
    background-color: #d4f1d4;
}

.act-toggle.act-green .act-toggle-icon:before,
.act-toggle.act-green .act-toggle-icon:after {
    background-color: #28a745;
}

.act-toggle.act-red {
    border-color: #fad0d0;
    background-color: #fff5f5;
}

.act-toggle.act-red .act-toggle-title {
    background-color: #fde8e8;
    color: #dc3545;
}

.act-toggle.act-red .act-toggle-title:hover {
    background-color: #fbdada;
}

.act-toggle.act-red .act-toggle-icon:before,
.act-toggle.act-red .act-toggle-icon:after {
    background-color: #dc3545;
}

/* 自动展开状态指示 */
.act-toggle[data-auto-expanded="true"] .act-toggle-title:after {
    content: "自动展开";
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #666;
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
}

/* 无障碍支持 */
.act-toggle-title[aria-expanded="true"] .act-toggle-icon:after {
    transform: rotate(90deg);
    opacity: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .act-toggle-title {
        padding: 12px 15px;
        font-size: 15px;
    }
    
    .act-toggle.expanded .act-toggle-content {
        padding: 15px;
    }
    
    .act-toggle-icon {
        width: 18px;
        height: 18px;
        margin-right: 10px;
    }
    
    .act-toggle-icon:before {
        top: 8px;
    }
    
    .act-toggle-icon:after {
        left: 8px;
    }
}

@media (max-width: 480px) {
    .act-toggle {
        margin-bottom: 15px;
        border-radius: 4px;
    }
    
    .act-toggle-title {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .act-toggle.expanded .act-toggle-content {
        padding: 12px;
    }
}

/* 打印样式 */
@media print {
    .act-toggle {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .act-toggle-content {
        max-height: none !important;
        padding: 15px !important;
        overflow: visible !important;
    }
    
    .act-toggle-title {
        background-color: #f5f5f5 !important;
    }
    
    .act-toggle-icon {
        display: none;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .act-toggle {
        border-width: 2px;
        border-color: #000;
    }
    
    .act-toggle-title {
        background-color: #fff;
        color: #000;
        border-bottom: 2px solid #000;
    }
    
    .act-toggle-icon:before,
    .act-toggle-icon:after {
        background-color: #000;
    }
}

/* 减少动画偏好支持 */
@media (prefers-reduced-motion: reduce) {
    .act-toggle-content,
    .act-toggle-icon:before,
    .act-toggle-icon:after,
    .act-toggle-title {
        transition: none;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .act-toggle {
        background-color: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .act-toggle-title {
        background-color: #3a3a3a;
        color: #e0e0e0;
    }
    
    .act-toggle-title:hover {
        background-color: #4a4a4a;
    }
    
    .act-toggle-content {
        background-color: #2d2d2d;
    }
    
    .act-toggle-icon:before,
    .act-toggle-icon:after {
        background-color: #e0e0e0;
    }
}

/* 兼容性修复 */
.act-toggle * {
    box-sizing: border-box;
}

/* 防止与其他插件/主题冲突 */
.act-toggle .act-toggle-title,
.act-toggle .act-toggle-content {
    font-family: inherit;
    line-height: inherit;
}

/* 性能优化 - 使用 contain 属性 */
.act-toggle {
    contain: layout style;
}

.act-toggle-content {
    contain: layout;
}