@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@500&family=Big+Shoulders+Inline+Display&family=Josefin+Sans:wght@300&display=block');

/* =========================================================
   GEAR CALCULATOR V.3.1 - MASTER STYLESHEET
   ========================================================= */

/* --- 1. BASE & LAYOUT CONTAINERS --- */

#bcalc-main-container,
#bcalc-compare-panel {
    display: block; 
    text-align: left; 
    background-color: #ffffff; 
    color: var(--bw-text-main); 
    border: none;
    border-radius: 12px; 
    padding: 25px; 
    margin: 0 auto; 
    width: 100%; 
    max-width: 900px; 
    box-sizing: border-box; 
}

#bcalc-main-container * { 
    box-sizing: border-box; 
}

.bcalc-outer-wrap {
    text-align: center; 
    width: 100%; 
    clear: both; 
    font-family: Tahoma, sans-serif; 
    padding: 0 20px; 
    box-sizing: border-box; 
}     

.bcalc-layout { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 20px; 
    justify-content: center; 
    align-items: stretch; 
}

.bcalc-box { 
    flex: 1 1 320px; 
    min-width: 320px; 
    min-height: 280px; 
    background: var(--bw-bg-light); 
    padding: 25px; 
    border-radius: 8px; 
    border: 1px solid var(--bw-border-light); 
    display: flex; 
    flex-direction: column;
}

.bcalc-tooltip-wrap:hover .bcalc-tooltip-box {
    display: block !important;
}

/* --- 2. TYPOGRAPHY & LABELS --- */

.bcalc-intro-wrapper {
    text-align: center; 
    margin: 0 auto 25px auto; 
}

.bcalc-intro-title {
    color: var(--bw-primary); 
    font-size: 1.6rem; 
    display: inline-block;
    font-family: Tahoma, sans-serif;
    font-weight: 800;
}

.bcalc-label { 
    display: block; 
    font-weight: bold; 
    font-size: 13px; 
    margin-bottom: 8px; 
    color: var(--bw-primary); 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}

.bcalc-mini-label { 
    position: absolute; 
    top: -18px; 
    font-size: 9px; 
    font-weight: bold; 
    color: var(--bw-text-muted); 
    text-transform: uppercase; 
    width: 60px; 
    text-align: center; 
    pointer-events: none; 
}

.formula-box { 
    display: block; 
    background: #fdfbf7; 
    padding: 10px 15px; 
    border-radius: 6px; 
    font-family: 'Courier New', monospace; 
    font-size: 13px; 
    color: #4a5568; 
    margin-top: 8px; 
    border-left: 4px solid var(--bw-primary-hover); 
    font-weight: bold;
}

/* --- 3. FORMS & INPUTS --- */

.bcalc-select { 
    width: 100%; 
    padding: 10px; 
    margin-bottom: 20px; 
    border: 1px solid var(--bw-border); 
    border-radius: 5px; 
    background: #fff; 
    cursor: pointer; 
    font-family: inherit; 
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.bcalc-select:focus, .bcalc-input:focus {
    border-color: #3182ce;
    outline: none;
}

/* Force number input spinner arrows to remain visible at all times */
.bcalc-custom-ring-input::-webkit-inner-spin-button,
.bcalc-custom-ring-input::-webkit-outer-spin-button {
    opacity: 1 !important;
    display: block !important;
}

.bcalc-input-grid { 
    position: relative; 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr)); 
    gap: 25px 10px; 
    align-items: start; 
    margin-top: 15px; 
}

.bcalc-val-input { 
    width: 60px; 
    height: 34px; 
    padding: 4px 8px; 
    border: 1px solid var(--bw-border); 
    border-radius: 4px; 
    text-align: center; 
    font-family: inherit; 
    font-size: 14px; 
}

.bcalc-radio-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    cursor: pointer; 
    font-size: 13px; 
    font-weight: bold; 
    color: var(--bw-primary); 
}

/* --- 3.1. NEW: CALCULATION MODE PANEL --- */
.bcalc-mode-panel {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 70px;
    background: #f8f9fb;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #eef0f5;
    margin-top: 10px;
    box-sizing: border-box;
}

.bcalc-mode-label {
    margin: 0 0 0 16px !important;
}

.bcalc-speed-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.bcalc-cadence-wrapper {
    align-items: center;
    gap: 8px;
    border-left: 1px solid #cbd5e0;
    padding-left: 15px;
}

.bcalc-rpm-label {
    font-size: 11px;
    font-weight: bold;
    color: #718096;
}

/* --- 3.2. NEW: COMPATIBILITY GUARD --- */
.bcalc-sidebar-diagnostic {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0; 
}

.bcalc-sidebar-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 12px;
}

.bcalc-toggle-wrap-vertical {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.bcalc-toggle-wrap-vertical .bcalc-label {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
}

.bcalc-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    flex-shrink: 0;
}

.bcalc-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.bcalc-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s ease;
    border-radius: 24px;
}

.bcalc-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s ease;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.bcalc-switch input:checked + .bcalc-slider {
    background-color: #0f172a; 
}

.bcalc-switch input:checked + .bcalc-slider:before {
    transform: translateX(24px);
}

.bcalc-badge {
    padding: 12px;
    border-radius: 6px;
    font-size: 0.85rem; 
    font-weight: 500;
    line-height: 1.4;
    display: none; 
    animation: slideDown 0.3s ease-out;
    width: 100%;
    box-sizing: border-box;
}

.bcalc-badge.optimal { background-color: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.bcalc-badge.custom { background-color: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.bcalc-badge.warning { background-color: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 4. BUTTONS --- */

.bcalc-btn-row {
    display: flex; 
    width: 100%; 
    margin: 12px auto; 
    gap: 12px; 
    justify-content: center; 
}

.bcalc-btn-pri, .bcalc-btn-sec {
    flex: 1; 
    max-width: 270px !important;
    padding: 12px; 
    border-radius: 6px; 
    cursor: pointer; 
    font-weight: bold; 
    font-size: 13px; 
    transition: all 0.2s; 
    text-decoration: none; 
    box-shadow: 3px 3px 3px 0px rgba(0,0,0,.2);
}

.bcalc-btn-pri { 
    background: var(--bw-primary); 
    color: #fff; 
    border: none; 
}

.bcalc-btn-sec { 
    background: #f1f3f5; 
    color: #4a5568; 
    border: none;
}

.bcalc-btn-pri:hover, .bcalc-btn-sec:hover { 
    color: #ffffff !important; 
    background-color: var(--bw-primary-hover) !important; 
}

.bcalc-btn-stale { 
    animation: button-recalc-glow 1.5s infinite ease-in-out; 
    border: 1px solid #4299e1 !important; 
    background: #3182ce !important; 
}

@keyframes button-recalc-glow {
    0% { box-shadow: 0 0 5px rgba(66, 153, 225, 0.4); }
    50% { box-shadow: 0 0 20px rgba(66, 153, 225, 0.9); }
    100% { box-shadow: 0 0 5px rgba(66, 153, 225, 0.4); }
}

/* --- 5. SNAPSHOT & TABLE (RESULTS) --- */

.bcalc-snapshot { 
    background: #f1f3f9; 
    border: 1px solid var(--bw-primary); 
    border-radius: 8px; 
    padding: 15px 20px; 
    margin-top: 25px; 
    display: none; 
    text-align: center; 
}

.bcalc-snap-title { 
    font-size: 1.6rem; 
    font-weight: bold; 
    color: var(--bw-primary); 
    margin-bottom: 12px; 
    padding-bottom: 8px; 
    border-bottom: 2px solid var(--bw-border); 
    letter-spacing: 1px; 
}

.bcalc-snap-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 20px; padding: 8px 0; }
.bcalc-snap-row:not(:last-child) { border-bottom: 1px solid var(--bw-border); }
.bcalc-snap-item { display: flex; align-items: baseline; gap: 8px; }
.bcalc-snap-lab { font-size: 12px; font-weight: bold; color: var(--bw-text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.bcalc-snap-val { font-size: 15px; font-weight: bold; color: #2d3748; }

.bcalc-table-wrap { overflow-x: auto; margin-top: 15px; border-radius: 8px; border: 1px solid #e2e8f0; display: none; }
.bcalc-table { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.bcalc-table th { background-color: var(--bw-primary); color: white; padding: 12px 8px; font-size: 13px; text-transform: uppercase; text-align: center; }
.bcalc-table td { padding: 12px 8px; text-align: center; font-size: 14px; font-weight: bold; border-radius: 4px; }

.bcalc-legend { margin-top: 15px; padding: 12px; font-size: 11px; color: #4a5568; background: var(--bw-bg-light); border-radius: 6px; display: none; border: 1px solid var(--bw-border-light); }
.legend-swatch { display: inline-block; width: 14px; height: 14px; margin-right: 5px; border-radius: 3px; vertical-align: middle; border: 1px solid rgba(0,0,0,0.2); }

/* --- 6. MODAL STYLES & GHOST TIPS --- */

.bcalc-modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0; 
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.6); 
    backdrop-filter: blur(4px);
}

.bcalc-modal-content {
    background-color: #ffffff; 
    padding: 35px 30px; 
    border-radius: 12px;
    width: 95%; 
    max-width: 450px; 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    max-height: 85vh; 
    overflow-y: auto; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    font-family: 'Tahoma', sans-serif;
}

.bcalc-close { 
    position: absolute; 
    right: 20px; 
    top: 15px; 
    color: #a0aec0; 
    font-size: 28px; 
    font-weight: bold; 
    cursor: pointer; 
}
.bcalc-close:hover { color: var(--bw-primary); }

.bcalc-modal-grid { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 20px; 
    margin-top: 15px; 
}

.bcalc-ghost-tip {
    display: none;
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    color: #ffffff !important;
    padding: 15px 20px;
    border-radius: 10px;
    font-family: 'Tahoma', sans-serif;
    font-size: 16px !important;
    line-height: 1.5;
    max-width: 380px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.modal-head {
    font-family: Tahoma, sans-serif;
    font-size: 1.7em;
    font-weight: 800; 
    color: var(--bw-primary);
    margin-bottom: 10px; 
    border-bottom: 2px solid var(--bw-border); 
    padding-bottom: 10px;
}

.modal-subhead {
    color: var(--bw-primary); 
    font-size: 1em;
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 2px; 
    margin: 5px 0;
}

/* Add interactive affordance to hoverable tooltip terms */
.bcalc-tooltip-hover {
    text-decoration: underline dotted 2px #a0aec0;
    text-underline-offset: 4px;
    cursor: help;
}

/* --- 7. COMPARE GARAGE (V3.0) --- */

#bcalc-compare-panel {
    display: none; 
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin: 30px auto 0; 
    width: 100%;
    max-width: 900px; 
    box-sizing: border-box;
}

.bcalc-compare-card {
    background: #ffffff;
    border: 1px solid var(--bw-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.bcalc-compare-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--bw-border-light);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.bcalc-compare-card-title {
    font-weight: bold;
    color: var(--bw-primary);
    font-size: 1.2rem;
    margin: 0; 
}

.bcalc-remove-compare {
    cursor: pointer; 
    background: #f1f3f5; 
    border: 1px solid #e2e8f0; 
    color: #4a5568; 
    border-radius: 4px; 
    padding: 4px 10px; 
    font-size: 0.8em;
    transition: all 0.2s ease;
}

.bcalc-remove-compare:hover {
    background: var(--bw-primary-hover);
    color: #ffffff;
    border-color: var(--bw-primary-hover);
}

.bcalc-compare-stats {
    margin-bottom: 15px; 
    font-size: 0.9em; 
    line-height: 1.4;
    color: #2d3748; 
}

.bcalc-compare-table-wrap {
    overflow-x: auto;
}

.bcalc-add-another {
    cursor: pointer;
    background: #e2e8f0;
    border: 1px solid #cbd5e0;
    color: #2d3748;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.8em;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.bcalc-add-another:hover {
    background: #cbd5e0;
    color: #1a202c;
}

.bcalc-garage-span {
    grid-column: 1 / -1; 
}

.bcalc-garage-instructions {
    text-align: left; 
    background: #f8fafc;
    border: 1px dashed #cbd5e0;
    border-radius: 8px;
    padding: 15px 20px;
    color: #4a5568;
    font-size: 0.95em;
    line-height: 1.5;
}

.bcalc-compare-card-footer {
    margin-top: 15px; 
    border-top: 1px solid #edf2f7; 
    padding-top: 12px; 
    text-align: right;
}

.bcalc-print-label {
    cursor: pointer; 
    font-weight: bold; 
    color: var(--bw-primary); 
    display: flex; 
    align-items: center; 
    justify-content: flex-end; 
    gap: 8px;
    font-size: 0.9em;
}

/* Ensure Comparison Panel text matches the clean sans-serif style of the Single Results panel */
#bcalc-compare-panel, 
#bcalc-compare-panel *,
.bcalc-compare-card-header,
.bcalc-compare-stats {
    font-family: Tahoma, sans-serif !important;
}

/* --- 8. MOBILE RESPONSIVE BREAKPOINTS --- */

@media (max-width: 568px) {
    .bcalc-box { 
        min-width: 100%; 
        max-width: 100%; 
        min-height: auto; 
        padding: 15px; 
    }
    
    /* UPDATED: Accommodates the new Mode Panel classes */
    .bcalc-mode-panel { 
        height: auto !important; 
        flex-direction: column; 
        align-items: flex-start !important; 
        gap: 12px !important; 
    }
    
    .bcalc-speed-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .bcalc-cadence-wrapper {
        border-left: none;
        border-top: 1px solid #cbd5e0;
        padding-left: 0;
        padding-top: 8px;
        width: 100%;
    }
    
    .bcalc-btn-row { 
        flex-direction: column; 
        align-items: center; 
    }
    
    .bcalc-btn-pri, .bcalc-btn-sec { 
        width: 100%; 
    }
    
    .bcalc-snap-row { 
        flex-direction: column; 
        align-items: center; 
        gap: 10px; 
    }
    
    .bcalc-modal-content { 
        padding: 25px 20px; 
        margin: 10% auto; 
    }
    
    .bcalc-modal-grid { 
        grid-template-columns: 1fr; 
        gap: 15px; 
    }
}
