/* Shared calculator styles - matches original ASP.NET look with Bootstrap integration */

/* ── Responsive wrapper ── */
.calc-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Main table ── */
.calc-table {
    width: 100%;
    max-width: 650px;
    border-collapse: collapse;
    line-height: 1.8;
}

.calc-table td {
    padding: 2px 4px;
    vertical-align: bottom;
    font-size: 0.9rem;
}

/* Column widths */
.calc-table .col-label {
    text-align: left;
    white-space: nowrap;
}

.calc-table .col-symbol {
    text-align: center;
    width: 60px;
}

.calc-table .col-value {
    width: 100px;
    text-align: right;
}

.calc-table .col-units {
    text-align: left;
    width: 120px;
}

/* Inlet/Outlet comparison columns (used in calculators with paired inlet/outlet values) */
.calc-table .col-io {
    width: 80px;
    text-align: center;
}

/* ── Section headers ── */
.calc-table .section-header td {
    font-weight: 700;
    padding-top: 12px;
}

.calc-table .section-header-outputs td {
    font-weight: 700;
    padding-top: 16px;
    border-top: 2px solid #0d6efd;
}

.calc-table .section-spacer td {
    height: 8px;
}

/* ── Input fields ── */
.calc-input {
    width: 100px;
    text-align: right;
    font-size: 0.9rem;
    padding: 2px 6px;
    border: 1px solid #ced4da;
    border-radius: 3px;
    background-color: #e9ecef;
}

.calc-input:focus {
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.25);
}

/* ── Output values ── */
.calc-output {
    font-weight: 700;
}

.calc-output-row td {
    font-weight: 700;
}

/* ── Unit dropdown ── */
.calc-unit-select {
    font-size: 0.85rem;
    padding: 2px 4px;
    border: 1px solid #ced4da;
    border-radius: 3px;
    width: 120px;
}

/* ── Primary action bar (Calculate + Reset, between inputs and outputs) ── */
.calc-primary-action-bar {
    text-align: center;
    padding: 16px 0 8px 0;
}

.calc-primary-action-bar .btn {
    min-width: 90px;
    margin: 0 4px;
}

/* ── Document action bar (Print + Save + Delete, below outputs) ── */
.calc-document-action-bar {
    text-align: center;
    padding: 12px 0;
}

.calc-document-action-bar .btn {
    min-width: 90px;
    margin: 0 4px;
}

/* Legacy button bar (kept for backwards compatibility) */
.calc-button-bar {
    text-align: center;
    padding: 16px 0;
}

.calc-button-bar .btn {
    min-width: 90px;
    margin: 0 4px;
}

/* ── Sticky calculate button (for long forms) ── */
.calc-sticky-calculate {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1040;
    display: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    font-size: 1.2rem;
    padding: 0;
    line-height: 56px;
}

.calc-sticky-calculate.visible {
    display: block;
}

/* ── Error messages ── */
.calc-errors {
    color: #dc3545;
    font-size: 0.9rem;
    margin-bottom: 16px;
    padding: 12px 16px;
    background-color: #fff3f3;
    border: 1px solid #f5c2c7;
    border-radius: 4px;
}

.calc-errors ul {
    margin-bottom: 0;
}

/* ── Info/success messages ── */
.calc-message {
    font-size: 0.9rem;
    margin-top: 8px;
}

.calc-message.success {
    color: #198754;
}

/* ── Saved calculations bar ── */
.calc-saved-bar {
    font-size: 0.9rem;
    margin-bottom: 16px;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.calc-saved-bar label {
    margin-right: 8px;
    font-weight: 500;
}

.calc-saved-bar select {
    font-size: 0.85rem;
    padding: 2px 8px;
    min-width: 200px;
}

.calc-saved-bar .description {
    margin-top: 4px;
    font-style: italic;
    color: #6c757d;
}

/* ── Save modal ── */
.calc-save-modal .form-label {
    font-weight: 500;
}

/* ── Responsive: tablet ── */
@media (max-width: 768px) {
    .calc-table td {
        font-size: 0.8rem;
    }

    .calc-input {
        width: 80px;
        font-size: 0.8rem;
    }

    .calc-unit-select {
        width: 100px;
        font-size: 0.75rem;
    }

    .calc-primary-action-bar .btn,
    .calc-document-action-bar .btn,
    .calc-button-bar .btn {
        min-width: 70px;
        font-size: 0.8rem;
        margin: 2px;
    }

    .calc-saved-bar .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .calc-saved-bar select {
        min-width: 100%;
    }
}

/* ── Responsive: phone ── */
@media (max-width: 576px) {
    .calc-table .col-symbol {
        display: none;
    }

    .calc-sticky-calculate {
        bottom: 12px;
        right: 12px;
    }
}

/* ── Print styles ── */
@media print {
    .calc-primary-action-bar,
    .calc-document-action-bar,
    .calc-button-bar,
    .calc-saved-bar,
    .calc-sticky-calculate,
    .navbar,
    footer {
        display: none !important;
    }

    /* Hide instructions accordion — collapsed content won't show anyway */
    .accordion {
        display: none !important;
    }

    .calc-input {
        border: none;
        background: transparent;
    }

    .calc-unit-select {
        border: none;
        background: transparent;
        appearance: none;
        -webkit-appearance: none;
    }

    .calc-table .section-header-outputs td {
        border-top-color: #000;
    }

    /* Prevent overflow containers from clipping content in print */
    .calc-table-responsive {
        overflow: visible !important;
    }

    /* Ensure diagram images fit within the printable area */
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }

    /* Keep tables and sections together across page breaks */
    .calc-table {
        page-break-inside: avoid;
    }
}
