/* ================================================================
   flexbox.css · Flexbox 弹性盒子专属样式
   ================================================================ */

.section-panel { display: none; animation: fadeIn 0.35s ease; }
.section-panel.active { display: block; }

.flex-container-visual {
    position: relative;
    width: 100%;
    min-height: 300px;
    background: rgba(15, 23, 42, 0.6);
    border: 2px dashed var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 30px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 20px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.flex-axis {
    position: absolute;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.5s ease;
    z-index: 10;
}

.main-axis {
    top: 10px;
    left: 30px;
    right: 30px;
    border-top: 1px dashed rgba(6, 182, 212, 0.6);
}
.main-axis::after {
    content: '→';
    position: absolute;
    right: 0;
    top: -10px;
    color: var(--accent-cyan);
    font-size: 16px;
}
.main-axis .axis-label {
    background: #0f172a;
    padding: 0 8px;
    color: var(--accent-cyan);
}

.cross-axis {
    top: 30px;
    bottom: 30px;
    left: 10px;
    border-left: 1px dashed rgba(236, 72, 153, 0.6);
}
.cross-axis::after {
    content: '↓';
    position: absolute;
    bottom: 0;
    left: -8px;
    color: var(--accent-pink);
    font-size: 16px;
}
.cross-axis .axis-label {
    background: #0f172a;
    padding: 4px 0;
    color: var(--accent-pink);
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* 动态生成的子项 */
.flex-item {
    /* 如果未开启 flex，这里将作为基础尺寸 */
    flex: 0 0 100px;
    height: 80px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 800;
    position: relative;
    transition: all 0.6s cubic-bezier(0.34, 1.2, 0.64, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    padding: 4px;
}

/* 基础尺寸标签 */
.flex-item .item-size-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.flex-item .item-order-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--accent-orange);
    color: #000;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 800;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 2;
}

.flex-theory-area h4 {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.theory-card {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 12px;
}

.theory-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.theory-row:last-child { border-bottom: none; }

.theory-row.highlight {
    color: var(--accent-cyan);
    font-weight: 700;
}

.theory-row .val {
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-weight: 600;
}

.theory-row.highlight .val {
    color: var(--accent-cyan);
}

.theory-row code {
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent-pink);
}

.flex-item-control-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--bg-tertiary);
}
.flex-item-control-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.flex-item-control-row .control-group {
    flex: 1;
    margin-bottom: 0;
}

.flex-disabled .control-group,
.flex-disabled #flexItemsControlsList {
    opacity: 0.35;
    pointer-events: none;
}

.control-panel .code-output {
    margin-top: 16px;
    background: #0a0f1a;
    border: 1px solid var(--bg-tertiary);
}

/* 弹窗 Modal 部分保持原样 */
.flex-cases-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.flex-cases-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.flex-modal-content {
    background: var(--bg-secondary);
    width: 90%;
    max-width: 1100px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}
.flex-cases-modal.show .flex-modal-content {
    transform: translateY(0);
}

.flex-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.flex-modal-header h3 {
    font-size: 18px;
    color: var(--accent-cyan);
    margin: 0;
}
.flex-modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}
.flex-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.flex-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}
.flex-modal-body::-webkit-scrollbar { width: 8px; }
.flex-modal-body::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }

.flex-cases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.case-card {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.case-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-cyan);
}
.case-demo-box {
    height: 140px;
    background: #0f172a;
    border: 1px dashed var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 10px;
    display: flex;
}
.case-item {
    background: var(--content-color);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.case-center { justify-content: center; align-items: center; }
.case-nav { justify-content: space-between; align-items: center; }
.case-nav .case-item:first-child { background: var(--accent-purple); }
.case-nav .case-item:not(:first-child) { background: var(--bg-tertiary); color: var(--text-secondary); }
.case-sidebar { padding: 0; overflow: hidden; }
.case-sidebar .case-item { border-radius: 0; }
.case-sidebar .sidebar { width: 80px; flex-shrink: 0; background: var(--accent-pink); }
.case-sidebar .content { flex: 1; background: var(--content-color); }
.case-equal { gap: 10px; }
.case-equal .case-item { flex: 1; }
.case-wrap { gap: 10px; flex-wrap: wrap; align-content: flex-start; }
.case-wrap .case-item { width: calc(33.33% - 7px); height: 50px; box-sizing: border-box; }

.case-card .code-output {
    padding: 10px;
    font-size: 11px;
    line-height: 1.6;
    margin-top: auto;
    background: #0f172a;
    border: 1px solid var(--bg-tertiary);
}

@media (max-width: 900px) {
    .flex-theory-area { width: 100%; }
}