/* ============================================================
   PCB PRICE CALCULATOR — calculator.css
   ============================================================ */

/* Hero */
.calc-hero {
    background: var(--color-bg-light);
    border-bottom: 1px solid var(--color-border);
    padding: 3rem 0 2.5rem;
}

.calc-hero__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}

.calc-hero__title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.15;
    margin-bottom: 0.5rem;
}

.calc-hero__desc {
    font-size: 1.0625rem;
    color: var(--color-text-muted);
    max-width: 480px;
}

.calc-hero__badges {
    display: flex;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.calc-hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--color-brand-light);
    color: var(--color-brand-dark);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.375rem 0.875rem;
    border-radius: 99px;
    border: 1px solid rgba(22,163,74,.2);
}

/* ---- Main layout ---- */
.calc-section { padding-top: 2rem; }

.calc-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    align-items: start;
}

/* ---- Parameter groups ---- */
.calc-params {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.calc-group {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 1.5rem;
}

.calc-group__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--color-border);
}

.calc-group__num {
    width: 24px;
    height: 24px;
    background: var(--color-brand);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.calc-field {
    margin-bottom: 1.125rem;
}

.calc-field:last-child { margin-bottom: 0; }

.calc-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-gray-600);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Tooltip */
.calc-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--color-gray-200);
    color: var(--color-gray-500);
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 50%;
    cursor: help;
    position: relative;
}

.calc-tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    white-space: normal;
    width: 220px;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 100;
    letter-spacing: 0;
    text-transform: none;
}

.calc-tooltip:hover::after { opacity: 1; }

/* ---- Chip selector (radio as pill buttons) ---- */
.calc-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.calc-chips--wrap { flex-wrap: wrap; }

.calc-chip { cursor: pointer; }

.calc-chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.calc-chip > span,
.calc-chip__main {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 0.4rem 0.875rem;
    border: 1.5px solid var(--color-gray-200);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-gray-500);
    background: #fff;
    transition: all 0.15s;
    user-select: none;
    line-height: 1;
}

.calc-chip--labeled {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.calc-chip--labeled .calc-chip__main {
    border-radius: 8px 8px 0 0;
    border-bottom: none;
    min-width: 80px;
}

.calc-chip__sub {
    display: block;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-gray-400);
    background: var(--color-gray-50);
    border: 1.5px solid var(--color-gray-200);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 0.15rem 0.5rem;
    width: 100%;
    text-align: center;
    transition: all 0.15s;
}

.calc-chip input[type="radio"]:checked + span,
.calc-chip input[type="radio"]:checked + .calc-chip__main {
    border-color: var(--color-brand);
    background: var(--color-brand-light);
    color: var(--color-brand-dark);
}

.calc-chip input[type="radio"]:checked + .calc-chip__main + .calc-chip__sub {
    border-color: var(--color-brand);
    background: rgba(220,252,231,.5);
    color: var(--color-brand);
}

.calc-chip:hover > span,
.calc-chip:hover .calc-chip__main {
    border-color: var(--color-brand);
    color: var(--color-brand);
}

/* ---- Size inputs ---- */
.calc-size-inputs {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.calc-size-input-wrap {
    position: relative;
    width: 110px;
}

.calc-input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1.5px solid var(--color-gray-200);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-primary);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -moz-appearance: textfield;
}

.calc-input::-webkit-outer-spin-button,
.calc-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.calc-input.gerber-filled {
    animation: gerberFill .6s ease forwards;
}
@keyframes gerberFill {
    0%   { background: #dcfce7; border-color: #16a34a; }
    100% { background: transparent; border-color: inherit; }
}

.calc-input:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(22,163,74,.12);
}

.calc-size-unit {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-gray-400);
    pointer-events: none;
}

.calc-size-sep {
    font-size: 1.125rem;
    font-weight: 300;
    color: var(--color-gray-400);
}

.calc-size-area {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-brand);
    background: var(--color-brand-light);
    padding: 0.3rem 0.625rem;
    border-radius: 6px;
    white-space: nowrap;
}

/* ---- Quantity custom input ---- */
.calc-qty-wrap { display: flex; flex-direction: column; gap: 0.5rem; }
.calc-qty-custom { display: flex; align-items: center; gap: 0.5rem; }
.calc-qty-custom .calc-input { width: 140px; }
.calc-qty-custom::before { content: 'or'; font-size: 0.8125rem; color: var(--color-gray-400); }

/* ---- Lead time selector ---- */
.calc-leadtime-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.calc-leadtime { cursor: pointer; }

.calc-leadtime input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.calc-leadtime__inner {
    border: 1.5px solid var(--color-gray-200);
    border-radius: 10px;
    padding: 0.625rem 0.875rem;
    text-align: center;
    min-width: 80px;
    transition: all 0.15s;
    background: #fff;
}

.calc-leadtime__days {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-primary);
}

.calc-leadtime__label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.calc-leadtime__surcharge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-brand);
    margin-top: 0.2rem;
}

.calc-leadtime__restriction {
    font-size: 0.65rem;
    color: var(--color-gray-400);
    margin-top: 0.15rem;
    background: var(--color-gray-100);
    border-radius: 4px;
    padding: 0.1rem 0.3rem;
}

.calc-leadtime input[type="radio"]:checked + .calc-leadtime__inner {
    border-color: var(--color-brand);
    background: var(--color-brand-light);
}

.calc-leadtime input[type="radio"]:checked + .calc-leadtime__inner .calc-leadtime__days { color: var(--color-brand-dark); }

.calc-leadtime:hover .calc-leadtime__inner { border-color: var(--color-brand); }

/* ---- Surface finish grid ---- */
.calc-finish-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.calc-finish { cursor: pointer; }

.calc-finish input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.calc-finish__inner {
    border: 1.5px solid var(--color-gray-200);
    border-radius: 10px;
    padding: 0.625rem 0.75rem;
    transition: all 0.15s;
    background: #fff;
    height: 100%;
}

.calc-finish__name {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.2rem;
}

.calc-finish__price {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-brand);
}

.calc-finish__note {
    font-size: 0.6875rem;
    color: var(--color-gray-400);
    margin-top: 0.15rem;
}

.calc-finish input[type="radio"]:checked + .calc-finish__inner {
    border-color: var(--color-brand);
    background: var(--color-brand-light);
}

.calc-finish:hover .calc-finish__inner { border-color: var(--color-brand); }

/* ---- Color swatches ---- */
.calc-colors {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.calc-color { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }

.calc-color input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.calc-color__swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    box-shadow: 0 0 0 1.5px var(--color-gray-200);
    transition: all 0.15s;
    display: block;
}

.calc-color input[type="radio"]:checked + .calc-color__swatch {
    box-shadow: 0 0 0 3px var(--color-brand);
    transform: scale(1.15);
}

.calc-color:hover .calc-color__swatch { transform: scale(1.1); }

.calc-color__name {
    font-size: 0.7rem;
    color: var(--color-gray-500);
    font-weight: 500;
}

/* ============================================================
   RIGHT PANEL
   ============================================================ */

.calc-panel {
    position: sticky;
    top: calc(var(--header-height) + 1.5rem);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* PCB Preview */
.calc-preview {
    background: linear-gradient(160deg, #0a1628 0%, #0d2137 60%, #0f2847 100%);
    border-radius: 16px;
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
    position: relative;
}
/* Subtle star/noise texture */
.calc-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 18px 18px;
    pointer-events: none;
}

/* Scene wrapper — perspective tilt */
.calc-preview__scene {
    position: relative;
    width: 100%;
    filter: drop-shadow(0 12px 32px rgba(0,0,0,.55));
    transition: transform .3s ease;
}
.calc-preview__scene:hover {
    transform: perspective(600px) rotateX(3deg) rotateY(-2deg) scale(1.02);
}

/* SVG fills the scene */
.calc-preview__svg {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    overflow: hidden;
}

/* Board base & mask colour transition */
#pcb-board-base,
#pcb-mask {
    transition: fill 0.35s ease;
}

/* Gerber parsing loading state */
.calc-preview__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 160px;
    color: #c8a96e;
    font-size: .8rem;
    font-weight: 600;
    opacity: .75;
}
.calc-preview__loading .spinner-icon {
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Shine / reflection overlay */
.calc-preview__shine {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 45%;
    background: linear-gradient(180deg, rgba(255,255,255,.07) 0%, transparent 100%);
    border-radius: 8px 8px 0 0;
    pointer-events: none;
}

/* Badge row */
.calc-preview__badge {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 1;
}
.calc-preview__badge span {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255,255,255,.75);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,.12);
    padding: 0.22rem 0.7rem;
    border-radius: 99px;
    backdrop-filter: blur(4px);
    letter-spacing: .02em;
}

/* Price card */
.calc-price-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 1.5rem;
}

.calc-price-card__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.calc-price-card__per { font-weight: 400; text-transform: none; font-size: 0.75rem; color: var(--color-gray-400); }

.calc-price-total {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.calc-price-currency {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-brand);
}

.calc-price-amount {
    font-size: 3rem;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1;
    transition: all 0.25s ease;
    font-variant-numeric: tabular-nums;
}

.calc-price-amount.is-updating {
    opacity: 0.5;
    transform: scale(0.96);
}

.calc-price-per-unit {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1.125rem;
}

/* Breakdown */
.calc-breakdown {
    background: var(--color-gray-50);
    border-radius: 8px;
    padding: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.calc-breakdown__row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.calc-breakdown__row span:last-child { font-weight: 600; color: var(--color-primary); }

.calc-breakdown__row--lead span:last-child { color: var(--color-brand); }

.calc-breakdown__row--shipping {
    border-top: 1px dashed var(--color-gray-200);
    padding-top: 0.4rem;
    margin-top: 0.2rem;
}

.calc-breakdown__row--shipping span:last-child { color: var(--color-text-muted); font-weight: 400; }

/* Note */
.calc-note {
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--color-gray-400);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.calc-note svg { flex-shrink: 0; margin-top: 1px; }

/* Order button */
.calc-order-btn {
    width: 100%;
    justify-content: center;
    gap: 0.625rem;
    margin-bottom: 0.625rem;
}

.calc-turnaround {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    justify-content: center;
}

.calc-turnaround strong { color: var(--color-brand-dark); }

/* Trust */
.calc-trust {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.calc-trust__item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.calc-trust__item svg { color: var(--color-brand); flex-shrink: 0; }

/* ============================================================
   FAQ grid
   ============================================================ */
.calc-faq-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.calc-faq-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem;
}

.calc-faq-card__q {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.625rem;
}

.calc-faq-card__a {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    line-height: 1.7;
}

/* ============================================================
   GERBER UPLOAD — calc-group--gerber
   ============================================================ */
.calc-group--gerber .calc-group__num {
    background: #f0fdf4;
    color: #16a34a;
    border: 1.5px solid #86efac;
    width: 28px;
    height: 28px;
}
.calc-group__optional {
    font-size: .78rem;
    font-weight: 500;
    color: #94a3b8;
    margin-left: .25rem;
}

/* Drop zone */
.calc-gerber-upload {
    position: relative;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color .18s, background .18s;
    overflow: hidden;
}
.calc-gerber-upload:hover,
.calc-gerber-upload.is-dragover {
    border-color: var(--color-brand);
    background: #eff6ff;
}
.calc-gerber-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2;
}
.calc-gerber-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: 1.75rem 1rem;
    pointer-events: none;
}
.calc-gerber-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: background .18s;
}
.calc-gerber-upload:hover .calc-gerber-icon,
.calc-gerber-upload.is-dragover .calc-gerber-icon {
    background: #dbeafe;
    color: var(--color-brand);
}
.calc-gerber-text {
    text-align: center;
    font-size: .85rem;
    color: #475569;
    line-height: 1.5;
    margin: 0;
}
.calc-gerber-text strong { color: var(--color-brand); }
.calc-gerber-text span   { font-size: .78rem; color: #94a3b8; }

/* Selected state */
.calc-gerber-selected {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .85rem 1rem;
    background: #f0fdf4;
    border-top: 1px solid #86efac;
    font-size: .875rem;
    color: #166534;
    font-weight: 600;
}
.calc-gerber-filename {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.calc-gerber-remove {
    border: none;
    background: #dcfce7;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #16a34a;
    transition: background .15s;
    flex-shrink: 0;
    padding: 0;
}
.calc-gerber-remove:hover { background: #bbf7d0; }

/* Hint text */
.calc-gerber-hint {
    display: flex;
    align-items: flex-start;
    gap: .35rem;
    font-size: .78rem;
    color: #94a3b8;
    margin: .6rem 0 0;
    line-height: 1.5;
}
.calc-gerber-hint svg { flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
    .calc-layout { grid-template-columns: 1fr 300px; }
}

@media (max-width: 860px) {
    .calc-layout { grid-template-columns: 1fr; }
    .calc-panel { position: static; }
    .calc-faq-grid { grid-template-columns: repeat(2, 1fr); }
    .calc-finish-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    .calc-faq-grid { grid-template-columns: 1fr; }
    .calc-hero__inner { flex-direction: column; }
    .calc-finish-grid { grid-template-columns: repeat(2, 1fr); }
    .calc-leadtime-options { gap: 0.375rem; }
    .calc-leadtime__inner { min-width: 64px; padding: 0.5rem; }
}
