/*!
 * MX Static Search styles
 * Uses --mxmc-* design tokens with fallbacks so the widget adapts to your site theme.
 */

.mx-search-wrap {
    position: relative;
    width: 100%;
    font-family: var(--mxmc-font-family, inherit);
}

.mx-search-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--mxmc-border, #e5e7eb);
    border-radius: var(--mxmc-radius-lg, 12px);
    font-size: 16px; /* 16px prevents iOS zoom on focus */
    line-height: 1.4;
    background: var(--mxmc-surface, #ffffff);
    color: var(--mxmc-text, #111827);
    outline: none;
    box-sizing: border-box;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.mx-search-input::placeholder {
    color: var(--mxmc-text-muted, #9ca3af);
}

.mx-search-input:focus {
    border-color: var(--mxmc-accent, #d97706);
    box-shadow: 0 0 0 3px var(--mxmc-accent-ring, rgba(217, 119, 6, 0.18));
}

.mx-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: var(--mxmc-z-dropdown, 9999);
    background: var(--mxmc-surface, #ffffff);
    border: 1px solid var(--mxmc-border, #e5e7eb);
    border-radius: var(--mxmc-radius-lg, 14px);
    box-shadow: var(--mxmc-shadow-lg, 0 16px 40px rgba(15, 23, 42, 0.12));
    overflow: hidden;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mx-search-item {
    display: grid;
    grid-template-columns: minmax(72px, auto) 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    text-decoration: none;
    color: var(--mxmc-text, #111827);
    border-bottom: 1px solid var(--mxmc-border-subtle, #f3f4f6);
}

.mx-search-item:last-child {
    border-bottom: none;
}

.mx-search-item:hover,
.mx-search-item.is-active,
.mx-search-item:focus {
    background: var(--mxmc-accent-soft, #fff7ed);
    outline: none;
}

.mx-search-symbol {
    font-weight: 700;
    color: var(--mxmc-text, #111827);
    letter-spacing: 0.02em;
}

.mx-search-name {
    font-size: 14px;
    color: var(--mxmc-text-secondary, #374151);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.mx-search-type {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mxmc-text-muted, #6b7280);
    background: var(--mxmc-chip-bg, #f3f4f6);
    padding: 4px 8px;
    border-radius: var(--mxmc-radius-pill, 999px);
    white-space: nowrap;
}

/* Right-hand meta group: compliance pill + type chip */
.mx-search-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* Compliance pill — shape + colour + text, so it reads without relying on colour alone */
.mx-c {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 4px 9px 4px 7px;
    border-radius: var(--mxmc-radius-pill, 999px);
    white-space: nowrap;
    line-height: 1;
}

.mx-c-ico {
    flex: 0 0 auto;
    display: block;
}

.mx-c--ok {
    color: var(--mxmc-ok, #15803d);
    background: var(--mxmc-ok-soft, #e7f6ec);
}

.mx-c--no {
    color: var(--mxmc-no, #b91c1c);
    background: var(--mxmc-no-soft, #fdeaea);
}

.mx-c--na {
    color: var(--mxmc-text-muted, #6b7280);
    background: var(--mxmc-chip-bg, #f3f4f6);
    font-weight: 600;
    padding: 4px 9px;
}

.mx-search-item mark {
    background: var(--mxmc-highlight, rgba(217, 119, 6, 0.18));
    color: inherit;
    padding: 0;
    border-radius: 2px;
}

.mx-search-empty {
    padding: 14px;
    color: var(--mxmc-text-muted, #6b7280);
    font-size: 14px;
    text-align: center;
}

/* Screen-reader-only live region */
.mx-search-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mobile refinements */
@media (max-width: 480px) {
    .mx-search-results {
        max-height: 70vh;
    }
    .mx-search-item {
        grid-template-columns: minmax(60px, auto) 1fr auto;
        gap: 8px;
        padding: 12px 12px;
    }
    .mx-search-name {
        font-size: 13px;
    }
    .mx-search-meta {
        gap: 6px;
    }
    /* Compact the compliant / not-compliant pills to icon-only, but keep the
       label available to screen readers (clipped, not display:none). */
    .mx-c--ok,
    .mx-c--no {
        padding: 5px;
    }
    .mx-c--ok .mx-c-txt,
    .mx-c--no .mx-c-txt {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    /* "Unrated" carries little value on a small screen — reclaim the space. */
    .mx-c--na {
        display: none;
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .mx-search-input {
        transition: none;
    }
}
