/* =========================
   MATERIAL CALCULATOR
   All rules scoped under .calc-panel to avoid
   conflicts with default.css
========================= */

.calc-panel {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow: visible;
}

/* ── LEFT COLUMN ── */
.calc-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    box-sizing: border-box;
}

/* ── SLIDER BLOCK ── */
.calc-slider-block {
    margin-bottom: 16px;
}

.calc-slider-block:last-child {
    margin-bottom: 0;
}

.calc-slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.calc-slider-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: rgb(216, 221, 231);
    min-width: 0;
    overflow: hidden;
}

.calc-slider-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.calc-slider-icon img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.calc-slider-val {
    font-family: 'Segoe UI', monospace;
    font-size: 16px;
    font-weight: 700;
    background: rgb(216, 221, 231);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 24px;
    text-align: right;
    flex-shrink: 0;
}

.calc-slider-marks {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

.calc-slider-marks span {
    font-size: 10px;
    color: rgba(150, 155, 170, 0.7);
}

.calc-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 14px 0;
}

.calc-section-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 99px;
    background: rgba(171,177,255,0.08);
    color: #abb1ff;
    border: 1px solid rgba(171,177,255,0.2);
    margin-bottom: 12px;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── TOGGLE SWITCHES ── */
.calc-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.calc-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.calc-toggle-row input[type=checkbox] {
    display: none;
}

.calc-toggle-pill {
    width: 51px;
    height: 26px;
    border-radius: 99px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    position: relative;
    transition: background 0.25s, border-color 0.25s;
    flex-shrink: 0;
}

.calc-toggle-pill::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    top: 4px;
    left: 4px;
    transition: transform 0.25s, background 0.25s;
}

.calc-toggle-row input:checked + .calc-toggle-pill {
    background: rgba(171,177,255,0.15);
    border-color: rgba(171,177,255,0.5);
}

.calc-toggle-row input:checked + .calc-toggle-pill::after {
    background: #abb1ff;
    transform: translateX(25px);
}

.calc-toggle-text {
    font-size: 12px;
    color: rgba(150, 150, 165);
    transition: color 0.2s;
    flex: 1;
}

.calc-toggle-row:has(input:checked) .calc-toggle-text {
    color: rgb(216, 221, 231);
}

.calc-toggle-note {
    font-size: 10px;
    color: rgba(150, 155, 170, 0.5);
    flex-shrink: 1;
    min-width: 0;
    word-break: break-word;
}

.calc-toggle-row.calc-locked {
    opacity: 0.3;
    pointer-events: none;
}

/* ── RIGHT COLUMN ── */
.calc-results {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── SECTION TAG ── */
.calc-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 4px 12px;
    border-radius: 99px;
    background: rgba(171,177,255,0.08);
    color: #abb1ff;
    border: 1px solid rgba(171,177,255,0.2);
    margin-bottom: 12px;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calc-sub {
    font-size: 14px;
    color: rgb(150, 155, 170);
    margin-bottom: 14px;
    font-weight: 600;
}

/* ── MATERIAL GRID ── */
.calc-mat-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.calc-mat-item {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 12px 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 110px;
    gap: 4px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    transition: opacity 0.2s, border-color 0.2s;
}

.calc-mat-item.calc-zero {
    opacity: 0.22;
}

.calc-mat-item:not(.calc-zero) {
    border-color: rgba(255,255,255,0.1);
}

/* rarity underline bar */
.calc-mat-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.calc-rarity-2::after { background: #4caf7d; }
.calc-rarity-3::after { background: #5b8dd9; }
.calc-rarity-4::after { background: #9d6fd4; }
.calc-rarity-5::after { background: #f0c050; }

.calc-mat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calc-mat-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.calc-mat-name {
    font-size: 13px;
    color: rgba(180, 185, 200, 0.9);
    text-align: center;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    width: 100%;
    padding: 0 4px;
    box-sizing: border-box;
    overflow-wrap: break-word;
}

.calc-mat-qty {
    font-size: 15px;
    font-weight: 700;
    color: rgb(216, 221, 231);
}

.calc-mat-item:not(.calc-zero) .calc-mat-qty {
    background: rgb(216, 221, 231);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── SUMMARY GRID ── */
.calc-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}

.calc-summary-item {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 72px;
    min-width: 0;        /* prevent grid blowout */
    overflow: hidden;
    box-sizing: border-box;
}

.calc-summary-label {
    font-size: 13px;
    color: rgba(180, 185, 200, 0.85);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;        /* lets flex children shrink below their content size */
    overflow: hidden;
}

/* truncate long label text with ellipsis */
.calc-summary-label span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calc-summary-label img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
}

.calc-summary-val {
    font-size: 20px;
    font-weight: 700;
    background: rgb(216, 221, 231);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    word-break: break-all;
    overflow-wrap: break-word;
}

.calc-exp-note {
    font-size: 13px;
    color: rgb(150, 155, 170);
    margin-top: 8px;
}

.default-title-longtext {
    background: linear-gradient(90deg, #8f91ff, #e0aaff, #ffa1b5, #ffbdb4);
    background-clip: text;
    color: transparent;
    font-weight: 700;
    margin-left: 25px;
    font-size: 17px;
    text-transform: uppercase;
    font-family: 'Segoe UI', sans-serif;
}

/* ── RESPONSIVE ── */
@media (max-width: 1000px) {
    .calc-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .calc-panel {
        gap: 14px;
    }

    .calc-mat-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 7px;
        min-width: 0;
        box-sizing: border-box;
    }

    .calc-mat-item {
        padding: 8px 5px 14px;
    }

    .calc-mat-icon {
        width: 34px;
        height: 34px;
    }

    .calc-mat-qty {
        font-size: 12px;
    }

    .calc-mat-name {
        font-size: 11px;
    }

    .calc-summary-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .default-title-longtext {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .calc-mat-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        min-width: 0;
        box-sizing: border-box;
    }

    .calc-mat-item {
        padding: 7px 4px 13px;
    }

    .calc-mat-icon {
        width: 30px;
        height: 30px;
    }

    .calc-mat-name {
        font-size: 9px;
    }

    .calc-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .calc-slider-name {
        font-size: 12px;
    }
}

/* ── 320px AND BELOW ── */
@media (max-width: 320px) {
    .calc-panel {
        gap: 10px;
    }

    /* 2-column mat grid — 3 col is too tight at 320px */
    .calc-mat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 5px;
    }

    .calc-mat-item {
        padding: 6px 3px 12px;
        min-height: 90px;
    }

    .calc-mat-icon {
        width: 26px;
        height: 26px;
    }

    .calc-mat-qty {
        font-size: 11px;
    }

    .calc-mat-name {
        font-size: 9px;
        padding: 0 2px;
    }

    /* Single-column summary so minmax(100px) doesn't overflow */
    .calc-summary-grid {
        grid-template-columns: 1fr;
    }

    .calc-summary-val {
        font-size: 17px;
    }

    /* Shrink slider icon so label row fits */
    .calc-slider-icon {
        width: 28px;
        height: 28px;
    }

    .calc-slider-icon img {
        width: 20px;
        height: 20px;
    }

    .calc-slider-name {
        font-size: 11px;
        gap: 5px;
    }

    .calc-slider-val {
        font-size: 13px;
    }

    /* Reduce tag padding & letter-spacing to prevent overflow */
    .calc-tag {
        font-size: 10px;
        letter-spacing: 0.05em;
        padding: 3px 8px;
    }

    .calc-toggle-text {
        font-size: 11px;
    }

    .calc-toggle-note {
        font-size: 9px;
    }

    .calc-section-label {
        font-size: 10px;
        letter-spacing: 0.05em;
    }

    .calc-sub {
        font-size: 11px;
    }

        .default-title-longtext {
        font-size: 11px;
    }
}