/**
 * 电阻在线计算器 - 前端样式
 * 主题色通过容器上的 --rc-primary 变量控制（短代码 theme 属性 / 后台设置）
 */

.rcalc-wrap {
    --rc-primary: #2271b1;
    --rc-primary-soft: rgba(34, 113, 177, .09);
    --rc-border: #dcdfe5;
    --rc-text: #23282d;
    --rc-muted: #6b7280;
    --rc-bg: #fff;
    --rc-radius: 12px;
    max-width: 880px;
    margin: 0 auto 24px;
    padding: 0;
    color: var(--rc-text);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.rcalc-wrap *,
.rcalc-wrap *::before,
.rcalc-wrap *::after {
    box-sizing: border-box;
}

/* ---------- 标签页 ---------- */
.rcalc-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 18px;
    padding: 6px;
    background: #f1f3f5;
    border-radius: var(--rc-radius);
}

.rcalc-tab {
    flex: 1 1 auto;
    min-width: 96px;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--rc-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
    white-space: nowrap;
}

.rcalc-tab:hover {
    background: rgba(0, 0, 0, .045);
    color: var(--rc-text);
}

.rcalc-tab.is-active {
    background: var(--rc-bg);
    color: var(--rc-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
}

.rcalc-panel {
    display: none;
}

.rcalc-panel.is-active {
    display: block;
    animation: rcalc-fade .22s ease;
}

@keyframes rcalc-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

/* ---------- 卡片 / 栅格 ---------- */
.rcalc-card {
    background: var(--rc-bg);
    border: 1px solid var(--rc-border);
    border-radius: var(--rc-radius);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}

.rcalc-card + .rcalc-card {
    margin-top: 16px;
}

.rcalc-card-title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
}

.rcalc-hint {
    margin: 0 0 14px;
    color: var(--rc-muted);
    font-size: 13px;
}

.rcalc-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
}

.rcalc-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 16px;
}

@media (max-width: 620px) {
    .rcalc-grid,
    .rcalc-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ---------- 表单控件 ---------- */
.rcalc-field label,
.rcalc-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--rc-muted);
}

.rcalc-wrap input[type="text"],
.rcalc-wrap input[type="number"],
.rcalc-wrap select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--rc-border);
    border-radius: 8px;
    background: #fff;
    color: var(--rc-text);
    font-size: 15px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.rcalc-wrap input:focus,
.rcalc-wrap select:focus {
    outline: none;
    border-color: var(--rc-primary);
    box-shadow: 0 0 0 3px var(--rc-primary-soft);
}

.rcalc-wrap input.is-invalid {
    border-color: #d94a4a;
}

.rcalc-unit {
    display: inline-block;
    margin-left: 4px;
    color: var(--rc-muted);
    font-size: 13px;
}

.rcalc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--rc-primary);
    border-radius: 8px;
    background: var(--rc-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s ease;
}

.rcalc-btn:hover {
    filter: brightness(1.08);
}

.rcalc-btn.is-ghost {
    background: transparent;
    color: var(--rc-primary);
}

.rcalc-btn.is-small {
    padding: 6px 11px;
    font-size: 13px;
}

.rcalc-btn.is-danger {
    border-color: #d94a4a;
    background: #d94a4a;
}

.rcalc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

/* ---------- 结果区 ---------- */
.rcalc-result {
    margin-top: 18px;
    padding: 16px 18px;
    border: 1px solid var(--rc-border);
    border-left: 4px solid var(--rc-primary);
    border-radius: 10px;
    background: var(--rc-primary-soft);
}

.rcalc-result-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: .3px;
    word-break: break-word;
}

.rcalc-result-sub {
    margin-top: 4px;
    color: var(--rc-muted);
    font-size: 13px;
}

.rcalc-result.is-error {
    border-left-color: #d94a4a;
    background: rgba(217, 74, 74, .07);
    color: #a52828;
}

.rcalc-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
    font-size: 14px;
}

.rcalc-table th,
.rcalc-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--rc-border);
    text-align: left;
}

.rcalc-table th {
    color: var(--rc-muted);
    font-weight: 600;
}

.rcalc-table td.rcalc-num {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* ---------- 电阻图形 ---------- */
.rcalc-resistor {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 22px 0 8px;
}

.rcalc-lead {
    width: 46px;
    height: 6px;
    background: linear-gradient(180deg, #cfd4da, #9aa1ab);
    border-radius: 3px;
}

.rcalc-body {
    position: relative;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    width: 320px;
    height: 78px;
    padding: 0 24px;
    border-radius: 34px;
    background: linear-gradient(180deg, #f6dfb4 0%, #dcae66 50%, #b98340 100%);
    box-shadow: inset 0 -10px 16px rgba(0, 0, 0, .18), 0 5px 12px rgba(0, 0, 0, .14);
}

.rcalc-band {
    width: 13px;
    height: 100%;
    border-radius: 2px;
    background: transparent;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, .3);
    transition: background .2s ease;
}

.rcalc-band.is-tcr {
    margin-left: 16px;
}

.rcalc-band.is-none {
    box-shadow: none;
}

@media (max-width: 620px) {
    .rcalc-lead { width: 26px; }
    .rcalc-body { width: 240px; height: 64px; padding: 0 18px; }
    .rcalc-band { width: 10px; }
}

/* ---------- 色环选择器 ---------- */
.rcalc-band-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--rc-border);
}

.rcalc-band-row:last-child {
    border-bottom: 0;
}

.rcalc-band-row.is-hidden {
    display: none;
}

.rcalc-band-name {
    flex: 0 0 96px;
    font-size: 13px;
    font-weight: 600;
    color: var(--rc-muted);
}

.rcalc-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.rcalc-swatch {
    position: relative;
    width: 40px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, .16);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
    transition: transform .12s ease, box-shadow .12s ease;
}

.rcalc-swatch:hover {
    transform: translateY(-2px);
}

.rcalc-swatch.is-selected {
    box-shadow: 0 0 0 3px var(--rc-primary);
    transform: translateY(-2px);
}

.rcalc-swatch.is-hidden {
    display: none;
}

.rcalc-swatch.is-light {
    color: #333;
    text-shadow: none;
}

.rcalc-swatch.is-none {
    background-image: linear-gradient(45deg, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),
                      linear-gradient(45deg, #ddd 25%, #fff 25%, #fff 75%, #ddd 75%);
    background-size: 10px 10px;
    background-position: 0 0, 5px 5px;
}

.rcalc-band-value {
    flex: 0 0 auto;
    margin-left: auto;
    color: var(--rc-text);
    font-size: 13px;
    font-weight: 600;
}

/* ---------- 动态电阻列表 ---------- */
.rcalc-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.rcalc-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.rcalc-list li input {
    flex: 1 1 auto;
}

.rcalc-list li .rcalc-index {
    flex: 0 0 34px;
    color: var(--rc-muted);
    font-size: 13px;
}

/* ---------- 参考表 ---------- */
.rcalc-ref {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--rc-border);
    color: var(--rc-muted);
    font-size: 13px;
}

.rcalc-ref code {
    padding: 1px 5px;
    border-radius: 4px;
    background: #f1f3f5;
    font-size: 12.5px;
}

.rcalc-formula {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #f8f9fa;
    color: var(--rc-muted);
    font-size: 13px;
}

.rcalc-formula code {
    color: var(--rc-text);
    font-size: 13px;
}

.rcalc-error-text {
    margin-top: 6px;
    color: #d94a4a;
    font-size: 13px;
}

.rcalc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- 后台设置页 ---------- */
.rcalc-admin {
    max-width: 760px;
}

.rcalc-admin fieldset {
    margin: 0 0 14px;
    padding: 0;
    border: 0;
}

.rcalc-admin legend {
    margin-bottom: 6px;
    font-weight: 600;
}
