/*
 * Auction fees calculator, styled like the customs clearance calculator. Scoped under
 * the wrapper, with !important only where the Motors theme's global button styles would
 * otherwise win.
 */
.afc-calculator {
    --afc-red: #d71e0f;
    --afc-red-soft: #fdf1f0;
    --afc-text: #1f2328;
    --afc-muted: #6b7280;
    --afc-line: #e3e5e8;
    --afc-panel: #f6f7f9;
    --afc-control-height: 48px;
    --afc-radius: 10px;

    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: 24px;
    width: 100%;
    box-sizing: border-box;
    padding: 24px;
    background: #fff;
    border-radius: 14px;
    color: var(--afc-text);
}

.afc-calculator *,
.afc-calculator *::before,
.afc-calculator *::after {
    box-sizing: border-box;
}

.afc-calculator [hidden] {
    display: none !important;
}

/* Form */
.afc-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
    margin: 0;
}

.afc-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.afc-calculator .afc-label {
    display: block;
    margin: 0;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    color: var(--afc-muted);
}

.afc-calculator .afc-control {
    display: block;
    width: 100%;
    height: var(--afc-control-height);
    margin: 0;
    padding: 0 14px;
    border: 1px solid var(--afc-line);
    border-radius: var(--afc-radius);
    background-color: #fff;
    box-shadow: none;
    font-family: inherit;
    font-size: 15px;
    line-height: normal;
    color: var(--afc-text);
    transition: border-color 0.2s ease;
}

.afc-calculator .afc-control:hover {
    border-color: #c4c8cf;
}

.afc-calculator .afc-control:focus {
    border-color: var(--afc-red);
    outline: none;
}

/* Option buttons: equal-width segments that fill the row. */
.afc-options {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 8px;
}

.afc-calculator .afc-option {
    display: flex;
    align-items: center;
    justify-content: center;
    position: static !important;
    min-width: 0;
    height: var(--afc-control-height);
    margin: 0;
    padding: 0 8px !important;
    border: 1px solid var(--afc-line) !important;
    border-radius: var(--afc-radius) !important;
    background: #fff !important;
    box-shadow: none !important;
    font-family: inherit;
    font-size: 14px !important;
    font-weight: 400 !important;
    line-height: 1.2 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--afc-text) !important;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.afc-calculator .afc-option:hover {
    border-color: #c4c8cf !important;
}

.afc-calculator .afc-option:focus-visible {
    outline: 2px solid var(--afc-red);
    outline-offset: 2px;
}

.afc-calculator .afc-option.active {
    border-color: var(--afc-red) !important;
    background: var(--afc-red-soft) !important;
    color: var(--afc-red) !important;
    font-weight: 600 !important;
}

/* Results */
.afc-results {
    display: flex;
    flex-direction: column;
    align-self: start;
    min-width: 0;
    padding: 20px;
    border-radius: 12px;
    background: var(--afc-panel);
}

.afc-total {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--afc-line);
}

.afc-calculator .afc-total strong {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--afc-text);
}

.afc-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    font-size: 14px;
    line-height: 1.4;
}

.afc-total + .afc-row {
    margin-top: 6px;
}

.afc-row span {
    color: var(--afc-muted);
}

.afc-row b {
    flex-shrink: 0;
    font-weight: 600;
    color: var(--afc-text);
}

/* The fee total opens into its parts. */
.afc-fees summary {
    list-style: none;
    cursor: pointer;
}

.afc-fees summary::-webkit-details-marker {
    display: none;
}

.afc-fees summary span::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin: 0 0 3px 8px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.afc-fees[open] summary span::after {
    margin-bottom: -1px;
    transform: rotate(-135deg);
}

.afc-lines {
    margin: 0 0 4px;
    padding-left: 12px;
    border-left: 2px solid var(--afc-line);
}

.afc-lines .afc-row {
    padding: 6px 0;
    font-size: 13px;
}

/* Tablet: results drop under the form. */
@media (max-width: 1024px) {
    .afc-calculator {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Phone */
@media (max-width: 600px) {
    .afc-calculator {
        --afc-control-height: 46px;

        gap: 16px;
        padding: 16px;
        border-radius: 12px;
    }

    .afc-form {
        gap: 16px;
    }

    .afc-calculator .afc-option {
        font-size: 13px !important;
    }

    .afc-results {
        padding: 16px;
    }

    .afc-calculator .afc-total strong {
        font-size: 30px;
    }
}
