/* ==========================================================================
   Mulhern Lacing Lookup — lacing-options.css  v1.2.0
   ========================================================================== */

/* --- Arrow link trigger --------------------------------------------------- */
.mll-wrapper {
    display: block;
    margin: 2px 0 6px 0;
}

.mll-arrow-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 0;
    margin: 0 0 0 16px;
    font-size: 15px;
    font-weight: 500;
    color: #1a5c8a;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.15s ease;
}

.mll-arrow-link:hover,
.mll-arrow-link:focus-visible {
    color: #154d75;
    outline: none;
}

.mll-arrow-icon {
    font-size: 17px;
    line-height: 1;
    display: inline-block;
    transform: translateY(1px);
    text-decoration: none;
}

.mll-arrow-text {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* --- Overlay -------------------------------------------------------------- */
.mll-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: mllFadeIn 0.18s ease;
}

@keyframes mllFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* --- Modal box ------------------------------------------------------------ */
.mll-modal {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
    width: 100%;
    max-width: 800px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mllSlideUp 0.2s ease;
}

@keyframes mllSlideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* --- Header --------------------------------------------------------------- */
.mll-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #1a5c8a;
    color: #fff;
    flex-shrink: 0;
}

.mll-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
}

.mll-modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s ease;
    flex-shrink: 0;
}

.mll-modal-close:hover { color: #fff; }

/* --- Modal body ----------------------------------------------------------- */
/*
 * overflow must NOT be set here — any overflow value other than visible on an
 * ancestor between a sticky element and its scroll container breaks sticky.
 * Scrolling is handled by .mll-table-wrap instead.
 */
.mll-modal-body {
    flex: 1;
    overflow: visible;
    padding: 0;
    min-height: 0; /* needed for flex children to shrink correctly */
}

/* --- Thickness summary bar ------------------------------------------------ */
.mll-thickness-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 12px 20px;
    background: #f0f6fb;
    border-bottom: 1px solid #d0e3f0;
    font-size: 13px;
}

.mll-thickness-block {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mll-thickness-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #1a5c8a;
}

.mll-thickness-range {
    color: #333;
}

.mll-thickness-range strong {
    color: #1a5c8a;
}

/* --- Color key legend (mobile only — rendered by JS when recessed rows exist) */
.mll-color-key {
    display: flex;
    gap: 20px;
    padding: 8px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e0eaf2;
    font-size: 12px;
    flex-wrap: wrap;
}

.mll-key-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.mll-key-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Normal lacing — blue swatch + blue text to match row color */
.mll-key-normal {
    color: #1a5c8a;
}
.mll-key-normal .mll-key-swatch {
    background: #1a5c8a;
}

/* Recessed Cover — green swatch + green text to match row color */
.mll-key-recessed {
    color: #2a6e2a;
}
.mll-key-recessed .mll-key-swatch {
    background: #2a6e2a;
}

/* --- Results table -------------------------------------------------------- */
/*
 * .mll-table-wrap is the SOLE scroll container for both axes.
 * This is required for position:sticky on thead th to work — sticky needs
 * the scroll container to be a direct ancestor with no intervening overflow
 * set on anything in between.
 */
.mll-table-wrap {
    padding: 0 20px 16px;
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(88vh - 200px);
}

.mll-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 14px;
}

/* --- Sticky thead --------------------------------------------------------- */
/*
 * .mll-table-wrap is the scroll container (overflow-y: auto).
 * position: sticky + top: 0 pins thead th to the top of that container.
 * background must be explicitly set — sticky cells lose inherited background.
 */
.mll-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* --- Sortable column headers ---------------------------------------------- */
.mll-table thead tr {
    background: #1a5c8a;
    color: #fff;
}

.mll-table thead th {
    padding: 9px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background: #1a5c8a; /* must restate for sticky to paint correctly */
}

.mll-sortable {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.mll-sortable:hover {
    background: #154d75 !important;
}

.mll-sortable:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -3px;
}

.mll-sort-icon {
    display: inline-block;
    margin-left: 4px;
    font-size: 11px;
    vertical-align: middle;
    line-height: 1;
    transition: opacity 0.15s ease;
}

.mll-sort-idle   { opacity: 0.45; }
.mll-sort-active { opacity: 1; }

/* --- Table body ----------------------------------------------------------- */
.mll-table tbody tr {
    border-bottom: 1px solid #e8eef3;
    transition: background 0.1s ease;
}

.mll-table tbody tr:nth-child(even) { background: #f7fafc; }
.mll-table tbody tr:hover           { background: #eaf3fb; }

.mll-table td {
    padding: 8px 12px;
    color: #333;
    vertical-align: middle;
}

/* Type group divider row */
.mll-type-group td {
    background: #ddeaf4 !important;
    font-weight: 700;
    font-size: 12px;
    color: #1a5c8a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 12px;
}

/* Recessed Cover badge (desktop only — hidden on mobile via color coding) */
.mll-badge-recessed {
    display: inline-block;
    background: #eaf4ea;
    color: #2a6e2a;
    border: 1px solid #aad4aa;
    border-radius: 3px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

/* N/A for null values */
.mll-na {
    color: #aaa;
    font-style: italic;
    font-size: 12px;
}

/* --- Empty state ---------------------------------------------------------- */
.mll-no-results {
    padding: 36px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.mll-no-results svg {
    display: block;
    margin: 0 auto 12px;
    opacity: 0.3;
}

/* --- Loading spinner ------------------------------------------------------ */
.mll-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 52px 20px;
    gap: 14px;
    color: #666;
    font-size: 14px;
}

.mll-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #d0e3f0;
    border-top-color: #1a5c8a;
    border-radius: 50%;
    animation: mllSpin 0.7s linear infinite;
}

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

/* --- Error state ---------------------------------------------------------- */
.mll-error {
    padding: 28px 20px;
    text-align: center;
    color: #c0392b;
    font-size: 14px;
}

/* --- Footer --------------------------------------------------------------- */
.mll-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #e0eaf2;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
    background: #f8fafc;
}

.mll-close-btn {
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.mll-close-btn:hover { background: #5a6268; }

/* --- Responsive (phones <=600px) ----------------------------------------- */
@media (max-width: 600px) {
    .mll-modal {
        max-height: 93vh;
    }

    .mll-modal-header h3 {
        font-size: 15px;
    }

    .mll-thickness-summary {
        flex-direction: column;
        gap: 10px;
    }

    /* Tighten table-wrap max-height to account for key bar */
    .mll-table-wrap {
        max-height: calc(93vh - 240px);
    }

    .mll-table {
        font-size: 12px;
    }

    /* Allow "Min. Pulley Dia." header to wrap onto three lines */
    .mll-table thead th {
        white-space: normal;
        line-height: 1.3;
        padding: 7px 8px;
        text-align: center;
    }

    /* Keep Type and Size left-aligned; they're short enough */
    .mll-table thead th:nth-child(1),
    .mll-table thead th:nth-child(2) {
        text-align: left;
    }

    .mll-table td {
        padding: 7px 8px;
        text-align: center;
    }

    /* Type and Size cells left-aligned */
    .mll-table td:nth-child(1),
    .mll-table td:nth-child(2) {
        text-align: left;
    }

    /* --- Mobile row color coding ----------------------------------------- */
    /*
     * Normal lacing rows — blue text (matches the key swatch)
     * Overrides the default #333 on td and the alternating row backgrounds.
     * We use color only (not background) to keep the zebra stripe readable.
     */
    .mll-table tbody tr.mll-row-normal td {
        color: #1a5c8a;
    }

    /*
     * Recessed Cover rows — green text (matches the key swatch)
     */
    .mll-table tbody tr.mll-row-recessed td {
        color: #2a6e2a;
    }

    /* N/A inherits the row color on mobile for visual consistency */
    .mll-table tbody tr.mll-row-normal   .mll-na,
    .mll-table tbody tr.mll-row-recessed .mll-na {
        color: inherit;
        opacity: 0.55;
    }
}
