/* DIP Practical — Components */

/* --- Section Card --- */
.section-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}
.section-card:hover { box-shadow: var(--shadow-md); }
.section-card h3 {
    color: var(--accent);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--surface-3);
}
.section-card p { color: var(--text-secondary); line-height: 1.6; margin-bottom: 0.5rem; }
.section-card label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; color: var(--text); }

/* --- Theory Box --- */
.theory-box {
    border-left: 4px solid var(--accent);
    background: var(--accent-light);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 0.875rem 1rem;
    margin: 0.75rem 0;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-secondary);
}
.theory-box strong { color: var(--text); }

/* --- Analysis Box --- */
.analysis-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem 1.5rem;
    margin-top: 1.25rem;
}
.analysis-box h4 { color: var(--accent); margin: 0 0 0.5rem; font-size: 1.05rem; }
.analysis-box ol { padding-left: 1.25rem; color: var(--text-secondary); }
.analysis-box li { margin-bottom: 0.4rem; line-height: 1.6; }
.analysis-box li:last-child { margin-bottom: 0; }

/* --- Result Image --- */
.result-img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin: 0.75rem 0;
}

/* --- Image Picker (Chapter + Image selects) --- */
.picker-bar {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.625rem 0.75rem;
    margin-bottom: 1rem;
}

.image-picker {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.375rem;
}
.image-picker:last-child { margin-bottom: 0; }

.picker-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 55px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.chapter-select, .image-select {
    padding: 0.6rem 2rem 0.6rem 0.75rem;
    min-height: 44px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-1);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.chapter-select { flex: 0 1 260px; }
.image-select { flex: 1 1 280px; min-width: 0; }

.chapter-select:hover, .image-select:hover { border-color: var(--border-hover); }
.chapter-select:focus, .image-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,70,229,0.12); }
[data-theme="dark"] .chapter-select:focus,
[data-theme="dark"] .image-select:focus { box-shadow: 0 0 0 2px rgba(129,140,248,0.15); }

.chapter-select:disabled, .image-select:disabled { opacity: 0.6; cursor: wait; border-style: dashed; }

.picker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
}

/* --- Run Button --- */
.btn-run {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.4rem;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.375rem;
    box-shadow: 0 1px 3px rgba(79,70,229,0.3);
    transition: background 0.15s, transform 0.15s var(--ease-spring), box-shadow 0.15s;
}
.btn-run:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,0.35); }
.btn-run:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(79,70,229,0.3); }
.btn-run:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; border: 2px solid var(--border); }

/* --- Quick-select Pair Buttons --- */
.btn-pair {
    display: inline-flex;
    align-items: center;
    padding: 0.6rem 1rem;
    min-height: 44px;
    background: var(--surface-1);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    margin: 0.15rem;
    transition: all 0.15s;
}
.btn-pair:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* --- Properties Table --- */
.props-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0.75rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.props-table th, .props-table td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
.props-table th { background: var(--surface-2); font-weight: 600; color: var(--text-muted); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
.props-table td { color: var(--text); }
.props-table tr:last-child td { border-bottom: none; }
.props-table tr:nth-child(even) td { background: var(--surface-2); }

/* --- Slider Group --- */
.slider-group { margin: 0.75rem 0; }
.slider-group label { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.3rem; }
.slider-group .slider-val { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); font-weight: 700; background: var(--accent-light); padding: 0.1rem 0.4rem; border-radius: var(--radius-sm); }
.slider-group input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: var(--surface-3); outline: none; }
.slider-group input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 2px 6px rgba(79,70,229,0.3); }

/* --- Stats Inline --- */
.stats-inline { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.stats-inline span { display: inline-flex; align-items: center; gap: 0.25rem; background: var(--surface-2); padding: 0.3rem 0.6rem; border-radius: var(--radius-md); font-size: 0.8rem; color: var(--text-muted); border: 1px solid var(--border); }
.stats-inline strong { font-family: var(--font-mono); color: var(--text); }

/* --- DS Grid (for P2 downsampling) --- */
.ds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; margin: 0.75rem 0; }
.ds-item { text-align: center; }
.ds-item img { width: 100%; border-radius: var(--radius-md); border: 1px solid var(--border); }
.ds-item .ds-label { font-weight: 600; font-size: 0.85rem; margin-top: 0.35rem; color: var(--text-muted); }

/* --- Colab Badge --- */
.colab-badge { display: inline-block; margin-bottom: 1rem; }
.colab-badge img { height: 24px; transition: opacity 0.15s; }
.colab-badge:hover img { opacity: 0.8; }

/* --- Formula Box --- */
.formula-box { text-align: center; font-size: 1.15rem; padding: 0.75rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); margin: 0.75rem 0; }

/* --- Grid Row --- */
.grid-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.75rem 0; }
.grid-row > * { flex: 1 1 240px; min-width: 0; }

/* --- Mobile --- */
@media (max-width: 640px) {
    .section-card { padding: 1rem; }
    .ds-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .grid-row { flex-direction: column; }
    .stats-inline { flex-direction: column; }
    .picker-grid { grid-template-columns: 1fr; }
    .chapter-select { flex: 1 1 100%; }
    .image-select { flex: 1 1 100%; }
}
