/* ---------- Base Fonts ---------- */
body {
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: #333333;
    line-height: 1.5;
    background-color: #f9f9f9;
}

/* Headings */
h1,
h2,
h3,
h4 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: #222222;
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 20px;
}

h3 {
    font-size: 16px;
}

/* Buttons: apply to primary-style buttons but avoid overriding Bootstrap outline variants or icon/link buttons */
button:not(.icon-btn):not(.btn-link):not([class*="btn-outline"]),
.btn:not([class*="btn-outline"]) {
    background-color: #007bff;
    /* Primary brand color */
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

button:not(.icon-btn):not(.btn-link):not([class*="btn-outline"]):hover,
.btn:not([class*="btn-outline"]):hover {
    background-color: #0056b3;
}

/* Explicit success button styles to override the broad .btn rule above
   Ensure .btn-success appears green by default (and on hover) */
.btn-success {
    /* slightly darker green with high alpha for a less-bright appearance */
    background-color: rgba(33, 136, 56, 0.95);
    color: #ffffff;
    border: none;
}

.btn-success:hover,
.btn-success:focus {
    background-color: rgba(33, 136, 56, 1);
}

/* Outline success (used for guest CTA) */
.btn-outline-success {
    background-color: transparent;
    color: rgba(33, 136, 56, 0.95);
    border: 1px solid rgba(33, 136, 56, 0.95);
}

.btn-outline-success:hover,
.btn-outline-success:focus {
    background-color: rgba(33, 136, 56, 0.08);
}

/* Ensure anchor buttons don't get underlined by general link hover rules */
a.btn,
a.btn:hover,
a.btn:focus {
    text-decoration: none;
}

/* Links */
a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- Calculator Page ---------- */
.calculator {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.calculator-form .form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.calculator-form .form-group {
    flex: 1;
}

.calculator-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.calculator-form input,
.calculator-form select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 14px;
}

.btn-calculate {
    display: block;
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background-color: #007bff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.2s;
}

.btn-calculate:hover {
    background-color: #0056b3;
}

.calculator-results {
    margin-top: 25px;
}

.calculator-results h2 {
    margin-bottom: 15px;
    color: var(--primary);
}

.calculator-results table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: transparent;
}

.calculator-results th,
.calculator-results td {
    padding: 12px;
    border-bottom: 1px solid var(--card-border);
    text-align: left;
    color: var(--text);
}

.calculator-results th {
    background: var(--table-header-bg, var(--primary));
    color: var(--table-header-text, #ffffff);
    text-align: left;
}

.calculator-results tr:nth-child(even) {
    background: color-mix(in srgb, var(--card-bg) 96%, transparent);
}

.calculator-results tr:hover {
    background: var(--info-overlay);
}

.calculator-results .total-row {
    font-weight: 600;
    background: var(--info-overlay);
}

/* ---------- Estimate Page ---------- */
.estimate {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.estimate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.estimate-header img.logo {
    max-height: 60px;
    margin-bottom: 10px;
}

.estimate h2 {
    margin-bottom: 15px;
}

.estimate h4 {
    margin-top: 20px;
    margin-bottom: 10px;
}

/* Estimate form section header: explicit light/dark contrast */
.estimate-section-header {
    background-color: #f3f5f7;
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

.estimate-section-header .small {
    color: #1f2933;
}

body.theme-light .estimate-section-header {
    background-color: #f3f5f7 !important;
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

body.theme-light .estimate-section-header .small {
    color: #1f2933 !important;
}

body.theme-dark .estimate-section-header {
    background-color: #1a1c1f;
    border-bottom-color: rgba(255, 255, 255, 0.10) !important;
}

body.theme-dark .estimate-section-header .small {
    color: #e9ecef;
}

@media (prefers-color-scheme: dark) {
    body:not(.theme-light) .estimate-section-header {
        background-color: #1a1c1f;
        border-bottom-color: rgba(255, 255, 255, 0.10) !important;
    }

    body:not(.theme-light) .estimate-section-header .small {
        color: #e9ecef;
    }
}

.estimate table {
    width: 100%;
    border-collapse: collapse;
}

.estimate th,
.estimate td {
    padding: 12px;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

.estimate th {
    background-color: #007bff;
    color: #fff;
    text-align: left;
}

.estimate tr:nth-child(even) {
    background-color: #f9f9f9;
}

.estimate tr:hover {
    background-color: #e6f0ff;
}

.estimate .totals,
.estimate .total-row {
    font-weight: 600;
    background-color: #e6f0ff;
}

.estimate .profit {
    color: #28a745;
}

.estimate-footer {
    margin-top: 30px;
    font-size: 12px;
    color: #666666;
    border-top: 1px solid #ddd;
    padding-top: 10px;
}

/* Panel Size select: align vertically with neighboring controls and match height */
.panel-size-control {
    min-width: 160px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.panel-size-control .form-label {
    margin-bottom: .25rem;
}

.panel-size-control .form-select {
    height: 42px;
    padding: .5rem .75rem;
    border-radius: 6px;
    border: 1px solid #ccc;
    box-sizing: border-box;
    margin-top: 0;
    /* align to top of label/control */
}

/* End temporary debug rules (removed) */

/* Mobile: stack estimate controls vertically for small screens */
@media (max-width: 767.98px) {

    #estimate-type-standard .d-flex.align-items-start,
    #estimate-type-standard .row.align-items-end {
        flex-direction: column;
        gap: .75rem;
        align-items: stretch;
    }

    #estimate-type-standard .d-flex.align-items-start>.flex-grow-1,
    #estimate-type-standard .d-flex.align-items-start>.panel-size-control,
    #estimate-type-standard .d-flex.align-items-start>#mud-type-control,
    #estimate-type-standard .d-flex.align-items-start>.d-flex.ms-2 {
        width: 100%;
        min-width: 0;
    }

    /* Inside the panel-size group, stack the small controls vertically */
    #estimate-type-standard .panel-size-control .d-flex.gap-3 {
        flex-direction: column;
        gap: .5rem;
        align-items: stretch;
    }

    /* Make selects and inputs full width on mobile */
    #estimate-type-standard .panel-size-control .form-select,
    #estimate-type-standard input.form-control {
        width: 100% !important;
    }

    /* Move Preview button nearer previous control and align left */
    #estimate-type-standard .d-flex.ms-2,
    #estimate-type-standard .w-100.w-xl-auto {
        margin-left: 0 !important;
        align-self: flex-start;
    }
}

/* Medium screens: removed grid layout — below desktop we stack like mobile */

/* Stack like mobile for any screen below desktop */
@media (max-width: 1199.98px) {

    /* Strong stacking override to ensure mobile layout below desktop.
       Target `.estimate-controls` (and `.d-flex.estimate-controls`) where it's actually applied. */
    .d-flex.estimate-controls,
    .estimate-controls {
        display: flex !important;
        flex-direction: column !important;
        gap: .75rem !important;
        align-items: stretch !important;
    }

    /* Make every direct child of .estimate-controls full-width when stacked below desktop */
    .estimate-controls>* {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    #estimate-type-standard .panel-size-control .d-flex.gap-3 {
        flex-direction: column !important;
        gap: .5rem !important;
        align-items: stretch !important;
    }

    #estimate-type-standard .panel-size-control .form-select,
    #estimate-type-standard input.form-control {
        width: 100% !important;
    }

    .estimate-controls .d-flex.ms-2 {
        margin-left: 0 !important;
        align-self: flex-start !important;
    }

    /* Ensure radio choices and preview button are full-width on narrower screens */
    #estimate-type-standard .p-2.border .form-check.form-check-inline {
        display: block !important;
        width: 100% !important;
        margin-bottom: .5rem !important;
    }

    .estimate-controls button#submit-estimate {
        width: 100% !important;
    }

}

/* Removed custom half-control rules; using Bootstrap row/cols for two-column behavior. */

/* Desktop and up: two-column grid layout */
@media (min-width: 1200px) {
    .estimate-controls {
        display: grid;
        grid-template-columns: 1fr 360px;
        gap: .75rem;
        align-items: start;
    }

    /* Left content area (wrapped .w-100) occupies column 1 */
    .estimate-controls>.w-100 {
        grid-column: 1 / 2;
    }

    /* Sidebar controls occupy column 2 */
    .estimate-controls>.panel-size-control,
    .estimate-controls>.d-flex.ms-2 {
        grid-column: 2 / 3;
        width: 100%;
        min-width: 0;
    }

    .estimate-controls .panel-size-control .d-flex.gap-3 {
        flex-direction: row;
        gap: .5rem;
        align-items: flex-start;
        flex-wrap: nowrap;
    }

    .estimate-controls button#submit-estimate {
        width: 100%;
    }
}

/* Spacing for stacked layout inserted below in the stacked media block */

/* Ensure all controls in the estimate form are full-width on small screens */
@media (max-width: 767.98px) {

    /* Make labeled blocks full width */
    #estimate-type-standard .d-flex.flex-column,
    #estimate-type-standard .d-flex.flex-column>label.form-label,
    #estimate-type-standard .d-flex.flex-column>.form-control,
    #estimate-type-standard .d-flex.flex-column>.form-select,
    #estimate-type-standard .panel-size-control,
    #estimate-type-standard #mud-type-control,
    #estimate-type-standard .flex-grow-1 {
        width: 100% !important;
    }

    /* Stack radio choices vertically and make them full width */
    #estimate-type-standard .p-2.border .form-check.form-check-inline {
        display: block;
        width: 100%;
        margin-bottom: .5rem;
    }

    /* Make preview button full width */
    #estimate-type-standard button#submit-estimate {
        width: 100%;
    }
}

/* ---------- Dashboard Page ---------- */
.dashboard {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard table {
    width: 100%;
    border-collapse: collapse;
}

.dashboard th,
.dashboard td {
    padding: 10px;
    border: 1px solid #ccc;
    text-align: left;
}

.dashboard th {
    background-color: #007bff;
    color: #fff;
}

.dashboard tr:nth-child(even) {
    background-color: #f9f9f9;
}

.dashboard tr:hover {
    background-color: #e6f0ff;
}

.dashboard .btn-action,
.dashboard .btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    margin-right: 5px;
}

/* Final Price column style */
.dashboard td.final-price {
    color: #28a745;
    font-weight: 600;
}

/* Totals row for dashboard */
.dashboard tfoot tr {
    font-weight: 600;
    background-color: #e6f0ff;
}

/* ---------- Icon Buttons (Minimal / Borderless) ---------- */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    /* smaller tap target */
    height: 26px;
    font-size: 14px;
    /* smaller icon */
    color: #555;
    background: transparent;
    border: none;
    /* REMOVE border */
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
    text-decoration: none;
}

/* Default hover */
.icon-btn:hover {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.08);
}

/* PDF icon subtle distinction */
.icon-btn.pdf {
    color: #c62828;
}

.icon-btn.pdf:hover {
    color: #c62828;
    background-color: rgba(198, 40, 40, 0.12);
}

/* Tooltip using title attribute */
.icon-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
}

.icon-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, .2);
    border-top-color: rgba(0, 0, 0, .6);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}

.icon-btn.is-loading {
    pointer-events: none;
    opacity: 0.6;
}

/* Accessible focus styles for icon buttons */
.icon-btn:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 3px;
    border-radius: 4px;
}

/* Remove default focus for mouse users */
.icon-btn:focus:not(:focus-visible) {
    outline: none;
}

/* Slight emphasis when focused */
.icon-btn:focus-visible i,
.icon-btn:focus-visible .icon {
    transform: scale(1.1);
}

/* Mobile: ensure collapsed navbar items (login/register/toggle) are left-aligned */
@media (max-width: 767.98px) {
    .navbar-system-theme .navbar-collapse .navbar-nav {
        justify-content: flex-start !important;
        text-align: left !important;
        width: 100%;
    }

    .navbar-system-theme .navbar-collapse .nav-link {
        text-align: left !important;
        width: 100%;
    }

    .navbar-system-theme .navbar-collapse .nav-item {
        width: 100%;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* Tooltip using title attribute */
.dashboard .icon-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: #333;
    color: #fff;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    transform: translateY(-150%);
    z-index: 1000;
}

/* ---------- Dashboard Summary Cards ---------- */
.dashboard-summary-cards {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.dashboard-summary-cards .card {
    flex: 1;
    min-width: 180px;
    background-color: #ffffff;
    border-radius: 8px;
    padding: 12px 15px 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dashboard-summary-cards .card-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.dashboard-summary-cards .card-title {
    font-weight: 500;
    font-size: 14px;
    color: #555;
    margin-bottom: 6px;
}

@media (prefers-color-scheme: dark) {
    .dashboard-summary-cards .card-title {
        color: var(--text);
    }
}

.dashboard-summary-cards .card-value {
    font-weight: 600;
    font-size: 20px;
    color: #007bff;
}

.dashboard-summary-cards .card-subtext {
    margin-top: auto;
    padding-top: 4px;
}

.dashboard-summary-cards .card-orange {
    background-color: #ffe6cc;
}

.dashboard-summary-cards .card-orange .card-value {
    font-weight: 700;
    color: #ff6600;
}

.dashboard-summary-cards .card-teal {
    background-color: #ccf0eb;
}

.dashboard-summary-cards .card-teal .card-value {
    font-weight: 700;
    color: #00897b;
}

/* ---------- Section panel headings ---------- */
.section-panel-heading {
    font-size: 1.3rem;
    font-weight: 600;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid;
    margin-bottom: 1.25rem;
    display: inline-block;
}
.section-heading-estimates {
    color: #0d6efd;
    border-color: #0d6efd;
}
.section-heading-invoices {
    color: #ff6600;
    border-color: #ff6600;
}

/* ---------- Dashboard Pagination ---------- */
.dashboard-pagination {
    display: flex;
    list-style: none;
    padding-left: 0;
    margin-top: 20px;
    gap: 6px;
}

.dashboard-pagination .page-item {
    margin-right: 0;
}

.dashboard-pagination .page-item + .page-item {
    margin-left: 2px;
}

.dashboard-pagination .page-item.prev .page-link,
.dashboard-pagination .page-item.next .page-link,
.dashboard-pagination .page-item.first .page-link,
.dashboard-pagination .page-item.last .page-link {
    margin: 0 1px;
}

.dashboard-pagination .page-item .page-link {
    display: block;
    min-width: 34px;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 600;
    color: #0d6efd;
    background-color: #fff;
    border: 1px solid rgba(13, 110, 253, 0.28);
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-pagination .page-item .page-link:hover {
    background-color: rgba(13, 110, 253, 0.10);
    border-color: rgba(13, 110, 253, 0.55);
}

.dashboard-pagination .page-item.active .page-link {
    background-color: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
    cursor: default;
}

.dashboard-pagination .page-item.disabled .page-link {
    color: #8f959c;
    pointer-events: none;
    background-color: #f2f4f7;
    border-color: #d9dee5;
}

/* Keyboard accessibility */
.dashboard-pagination .page-item .page-link:focus {
    outline: none;
    box-shadow: 0 0 0 0.18rem rgba(13, 110, 253, 0.22);
}

/* Dark mode overrides */
body.theme-dark .dashboard-pagination .page-item .page-link {
    color: #d9e7ff;
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.16);
}

body.theme-dark .dashboard-pagination .page-item .page-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.28);
    color: #ffffff;
}

body.theme-dark .dashboard-pagination .page-item.active .page-link {
    background-color: #2f7efc;
    border-color: #2f7efc;
    color: #ffffff;
}

body.theme-dark .dashboard-pagination .page-item.disabled .page-link {
    color: rgba(255, 255, 255, 0.36);
    background-color: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.10);
}

/* ---------- Status Badge Tooltip with Delay ---------- */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 12px;
    cursor: default;
    position: relative;
}

/* Draft badge style */
.status-draft {
    background-color: #f0f0f0;
    color: #555;
}

/* Sent badge style */
.status-sent {
    background-color: #28a745;
    color: #fff;
}

/* Tooltip using title attribute fallback */
.status-badge[title]::after {
    content: attr(title);
    position: absolute;
    bottom: 125%;
    /* above the badge */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    transition-delay: 0.3s;
    /* delay before appearing */
}

/* Small arrow below tooltip */
.status-badge[title]::before {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    transition-delay: 0.3s;
    /* match tooltip delay */
}

/* Show tooltip on hover */
.status-badge[title]:hover::after,
.status-badge[title]:hover::before {
    opacity: 1;
    transition-delay: 0s;
    /* show immediately when hovered */
}

.estimate-expired {
    background-color: transparent;
}

.estimate-expired .status-badge {
    background-color: #dc3545;
    color: #fff;
}

/* ---------- Bordered Tables for Estimate & Guest ---------- */
.bordered-table {
    width: 100%;
    border-collapse: collapse;
}

.bordered-table td,
.bordered-table th {
    border: 1px solid #ccc;
    padding: 10px;
    text-align: left;
}

/* Apply zebra striping only in light theme */
body.theme-light .bordered-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Hover effect on all rows */
.bordered-table tr:hover {
    background-color: #e6f0ff;
}

/* Light-theme specific: soften the hover and ensure dark text for readability */
body.theme-light .bordered-table tr:hover {
    background-color: rgba(102, 166, 255, 0.12) !important;
    color: #212529 !important;
}

/* Apply the same soft hover and readable text color to all table variants in light mode */
body.theme-light table tr:hover,
body.theme-light .table tr:hover,
body.theme-light .calculator-results tr:hover,
body.theme-light .totals-table tr:hover,
body.theme-light .calculator-results tbody tr:hover {
    background-color: rgba(102, 166, 255, 0.12) !important;
    color: #212529 !important;
}

/* Centralized styling for app data tables to ensure identical appearance */
.app-data-table {
    width: 100%;
    border-collapse: collapse;
}

.app-data-table th,
.app-data-table td {
    border: 1px solid #ccc;
    padding: 10px;
    text-align: left;
}

/* Header: match dashboard header appearance in light mode */
body.theme-light .app-data-table thead tr {
    background-color: #212529 !important;
}

body.theme-light .app-data-table thead th {
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.06) !important;
}

/* Hover: soft highlight and readable text for rows */
body.theme-light .app-data-table tbody tr:hover,
body.theme-light .app-data-table tbody tr:hover td {
    background-color: rgba(102, 166, 255, 0.12) !important;
    color: #212529 !important;
}

/* Dark mode variants to remain consistent */
body.theme-dark .app-data-table thead tr {
    background-color: color-mix(in srgb, var(--card-bg) 80%, #212529 20%) !important;
}

body.theme-dark .app-data-table thead th {
    color: var(--text) !important;
}

body.theme-dark .app-data-table tbody tr:hover,
body.theme-dark .app-data-table tbody tr:hover td {
    background-color: #2e2e2e !important;
    color: var(--text) !important;
}

/* Rounded corners for app data table headers */
.app-data-table {
    /* use separate collapse so border-radius applies cleanly */
    border-collapse: separate !important;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
}

.app-data-table thead th:first-child {
    border-top-left-radius: 8px;
}

.app-data-table thead th:last-child {
    border-top-right-radius: 8px;
}

/* Ensure header background respects rounded corners */
.app-data-table thead th {
    background-clip: padding-box;
}

/* Stronger, very-specific selectors for calculator quick results/modal to override any other rules */
body.theme-light table.table.calculator-results tbody tr:hover,
body.theme-light .table.table.calculator-results tbody tr:hover,
body.theme-light #quickResultModal .modal-content table.calculator-results tbody tr:hover,
body.theme-light #quickResultModal table.calculator-results tbody tr:hover {
    background-color: rgba(102, 166, 255, 0.16) !important;
    color: #212529 !important;
}

/* Ensure table cells inherit the hover color so text remains readable */
body.theme-light table.table.calculator-results tbody tr:hover td,
body.theme-light #quickResultModal table.calculator-results tbody tr:hover td {
    background-color: rgba(102, 166, 255, 0.16) !important;
    color: inherit !important;
}

/* Apply styles for the total row */
.bordered-table .total-row td {
    font-weight: 600;
    background-color: #dff0d8;
}

.bordered-table.totals-table {
    margin-top: 20px;
}

@media (prefers-color-scheme: dark) {

    .bordered-table td,
    .bordered-table th {
        border-color: var(--card-border);
    }

    /* Dark mode for even rows */
    .bordered-table tr:nth-child(even) {
        background-color: color-mix(in srgb, var(--card-bg)) !important;
    }

    /* Ensure hover works for all rows in dark mode */
    .bordered-table tr:hover {
        background-color: #2e2e2e !important;
        /* Make hover work for all rows */
    }
}


/* ---------- Scope Options (Checkbox Group) ---------- */
.scope-options {
    display: inline-flex;
    /* horizontal layout */
    gap: 40px;
    /* space between checkboxes */
    margin-bottom: 25px;
}

.scope-options label {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    /* prevent wrapping of label text */
    font-weight: normal;
}

.scope-options input[type="checkbox"] {
    margin-right: 8px;
    /* space between checkbox and label text */
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {

    .calculator,
    .estimate,
    .dashboard {
        padding: 15px;
    }

    .calculator-form .form-row {
        flex-direction: column;
    }

    .estimate-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard table,
    .calculator-results table,
    .estimate table {
        font-size: 13px;
    }

    .dashboard th:nth-child(3),
    .dashboard td:nth-child(3),
    .dashboard th:nth-child(4),
    .dashboard td:nth-child(4) {
        display: none;
    }

    .dashboard-summary-cards {
        flex-direction: column;
    }

    .dashboard-pagination {
        flex-wrap: wrap;
    }

    .dashboard-pagination .page-item {
        margin-bottom: 5px;
    }
}


/* ---------- Mobile-friendly adjustments ---------- */
@media (max-width: 480px) {
    .status-badge[title]::after {
        bottom: auto;
        top: 125%;
        /* show below badge on small screens */
        left: 50%;
        transform: translateX(-50%);
        white-space: normal;
        /* allow wrapping if needed */
        max-width: 200px;
        text-align: center;
    }

    .status-badge[title]::before {
        bottom: auto;
        top: 115%;
        left: 50%;
        transform: translateX(-50%) rotate(180deg);
        /* arrow points up */
        border-color: transparent transparent rgba(0, 0, 0, 0.85) transparent;
    }
}

/* Shared plan card base */
.plan-card {
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.plan-card:hover {
    transform: translateY(-2px);
}

/* Free plan (neutral) */
.plan-free {
    opacity: 0.95;
}

/* Pro plan highlight */
.plan-pro {
    border: 2px solid var(--bs-primary);
    background: linear-gradient(135deg,
            rgba(var(--bs-primary-rgb), 0.08),
            rgba(var(--bs-primary-rgb), 0.02));
}

/* Dark mode safety */
body.dark .plan-pro,
[data-theme="dark"] .plan-pro {
    background: linear-gradient(135deg,
            rgba(var(--bs-primary-rgb), 0.18),
            rgba(var(--bs-primary-rgb), 0.06));
}

/* Badge */
.plan-badge {
    position: absolute;
    top: -12px;
    right: 16px;
    background: var(--bs-primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    letter-spacing: 0.04em;
}

.plan-pro {
    transform: scale(1.02);
}

input[type="checkbox"] {
    border-color: var(--bs-secondary);
}