/* Rules Page - 重新設計 */

/* ============================================
   規則頁面佈局
   ============================================ */

.rules-page {
    padding-bottom: var(--spacing-lg);
    max-width: 820px;
}

/* 頁面標頭 */
.rules-head {
    margin-bottom: var(--spacing-md);
}

.rules-page .section-title {
    font-size: clamp(2.2rem, 5vw, 3.2rem);
    margin-bottom: 0.4rem;
}

.rules-page .section-title-sub {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-family: var(--font-body);
    font-weight: 400;
    margin-bottom: var(--spacing-md);
    letter-spacing: 0.03em;
}

/* ============================================
   規則分頁標籤 Tab Bar
   ============================================ */

.rules-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: var(--spacing-md);
    position: relative;
}

.rules-tabs::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        var(--border-color) 0%,
        rgba(249, 115, 22, 0.25) 40%,
        rgba(148, 163, 184, 0.15) 70%,
        transparent 100%
    );
}

.rules-tab-btn {
    position: relative;
    padding: 0.6rem 1.2rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    letter-spacing: 0.02em;
    z-index: 1;
}

.rules-tab-btn .tab-icon {
    font-size: 0.95rem;
    opacity: 0.7;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.rules-tab-btn:hover {
    color: var(--primary-light);
    background: rgba(249, 115, 22, 0.06);
    border-color: rgba(249, 115, 22, 0.12);
}

.rules-tab-btn:hover .tab-icon {
    opacity: 1;
    transform: scale(1.1);
}

.rules-tab-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.rules-tab-btn.active {
    color: var(--primary-color);
    border-color: rgba(249, 115, 22, 0.3);
    background: rgba(249, 115, 22, 0.07);
    font-weight: 600;
}

.rules-tab-btn.active .tab-icon {
    opacity: 1;
}

.rules-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--primary-color);
    border-radius: 2px 2px 0 0;
    box-shadow: 0 0 8px var(--primary-glow);
}

/* ============================================
   分頁面板
   ============================================ */

.rules-panel {
    display: none;
    animation: rulesFadeIn 0.3s ease;
}

.rules-panel.active {
    display: block;
}

@keyframes rulesFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   規則卡片主體
   ============================================ */

.rule-box {
    background: linear-gradient(145deg, rgba(18, 18, 31, 0.95) 0%, rgba(13, 13, 26, 0.9) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-md);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
    position: relative;
    overflow: hidden;
}

/* 卡片左側彩色條紋 */
.rule-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 0 2px 2px 0;
    opacity: 0.6;
    transition: opacity var(--transition-normal);
}

/* 卡片背景光暈 */
.rule-box::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.04) 0%, transparent 70%);
    pointer-events: none;
}

.rule-box:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-card-hover);
}

.rule-box:hover::before {
    opacity: 1;
}

/* 卡片標題區 */
.rule-box-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid rgba(249, 115, 22, 0.1);
}

.rule-box-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--primary-color);
    flex-shrink: 0;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.rule-box:hover .rule-box-icon {
    background: rgba(249, 115, 22, 0.16);
    box-shadow: 0 0 16px rgba(249, 115, 22, 0.2);
}

.rule-box h3 {
    color: var(--text-main);
    font-size: 1.2rem;
    font-family: var(--font-body);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.03em;
}

.rule-box p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
    line-height: 1.7;
    font-size: 0.95rem;
}

/* ============================================
   規則清單項目
   ============================================ */

.rule-list {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.rule-item {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.rule-item:hover {
    background: rgba(249, 115, 22, 0.04);
}

.rule-item-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: var(--font-heading);
    margin-top: 0.15rem;
}

.rule-item-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.rule-item-icon.deny {
    color: #F87171;
}

.rule-item-icon.allow {
    color: #4ADE80;
}

.rule-item-icon.warn {
    color: #FBBF24;
}

.rule-item-icon.info {
    color: var(--accent-color);
}

.rule-item-text {
    color: var(--text-light);
    font-size: 0.97rem;
    line-height: 1.7;
    font-weight: 400;
}

.rule-item-text strong {
    color: #FBBF24;
    font-weight: 600;
}

/* 分隔線 */
.rule-divider {
    height: 1px;
    background: rgba(249, 115, 22, 0.07);
    margin: 0.5rem 0;
}

/* 標籤 Badge */
.rule-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    vertical-align: middle;
    margin-left: 0.4rem;
}

.rule-badge.deny {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.25);
    color: #F87171;
}

.rule-badge.allow {
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.2);
    color: #4ADE80;
}

.rule-badge.warn {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: #FBBF24;
}

/* ============================================
   違規處理特殊樣式
   ============================================ */

.rule-box--violation {
    border-color: rgba(248, 113, 113, 0.2);
}

.rule-box--violation::before {
    background: linear-gradient(180deg, #F87171 0%, #FCA5A5 100%);
}

.rule-box--violation::after {
    background: radial-gradient(circle, rgba(248, 113, 113, 0.05) 0%, transparent 70%);
}

.rule-box--violation:hover {
    border-color: rgba(248, 113, 113, 0.4);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(248, 113, 113, 0.1);
}

.rule-box--violation .rule-box-icon {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.2);
    color: #F87171;
}

.rule-box--violation:hover .rule-box-icon {
    background: rgba(248, 113, 113, 0.16);
    box-shadow: 0 0 16px rgba(248, 113, 113, 0.2);
}

.rule-box--violation .rule-box-header {
    border-bottom-color: rgba(248, 113, 113, 0.1);
}

.rule-box--violation .rule-item-num {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.2);
    color: #F87171;
}

.rule-box--violation .rule-item:hover {
    background: rgba(248, 113, 113, 0.04);
}

/* ============================================
   允許/禁止 分組區塊
   ============================================ */

.rule-group {
    margin-bottom: 0.75rem;
}

.rule-group:last-child {
    margin-bottom: 0;
}

.rule-group-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
    padding: 0 0.85rem;
    color: var(--text-subtle);
}

.rule-group-label.deny { color: rgba(248, 113, 113, 0.7); }
.rule-group-label.allow { color: rgba(74, 222, 128, 0.7); }
.rule-group-label.warn { color: rgba(251, 191, 36, 0.7); }
.rule-group-label.info { color: rgba(148, 163, 184, 0.7); }

/* ============================================
   響應式設計
   ============================================ */

@media (max-width: 768px) {
    .rules-page {
        padding-bottom: var(--spacing-lg);
    }

    .rules-tabs {
        gap: 0.35rem;
    }

    .rules-tab-btn {
        font-size: 0.82rem;
        padding: 0.5rem 0.8rem;
        gap: 0.3rem;
    }

    .rule-box {
        padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-sm);
    }

    .rule-item {
        padding: 0.6rem 0.65rem;
    }
}
