/* =========================================================
   CANADA SKILLPATH — GLOBAL COURSE SEARCH
   Responsive styling for course search and results
========================================================= */

.csp-global-search {
    position: relative;
    z-index: 50;
    width: min(calc(100% - 32px), 860px);
    margin: 12px auto 18px;
    font-family: Inter, Arial, sans-serif;
}

.csp-search-form {
    position: relative;
    width: 100%;
}

.csp-search-label {
    display: block;
    margin: 0 0 7px 3px;
    color: #111e3b;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.csp-search-field {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 0 16px;
    color: #23558c;
    background: #ffffff;
    border: 1px solid #dbe5f1;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(17, 30, 59, 0.07);
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
    box-sizing: border-box;
}

.csp-search-field:focus-within {
    border-color: #3978b7;
    box-shadow:
        0 0 0 4px rgba(57, 120, 183, 0.12),
        0 10px 28px rgba(17, 30, 59, 0.09);
}

.csp-search-field > i {
    flex: 0 0 auto;
    font-size: 17px;
}

.csp-search-field input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    padding: 15px 0;
    color: #1f2937;
    background: transparent;
    border: 0;
    outline: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: none;
}

.csp-search-field input::placeholder {
    color: #8490a2;
    opacity: 1;
}

.csp-search-field input:focus {
    outline: none;
    box-shadow: none;
}

.csp-search-clear {
    display: grid;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    padding: 0;
    place-items: center;
    color: #667085;
    background: #f1f5fa;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition:
        background 0.18s ease,
        color 0.18s ease;
}

.csp-search-clear:hover {
    color: #111e3b;
    background: #e2eaf4;
}

.csp-search-clear:focus-visible {
    outline: 2px solid #3978b7;
    outline-offset: 3px;
}

.csp-search-clear[hidden],
.csp-search-results[hidden] {
    display: none !important;
}

/* Search results dropdown */

.csp-search-results {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    left: 0;
    z-index: 100;
    max-height: min(65vh, 520px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px;
    background: #ffffff;
    border: 1px solid #e1e8f1;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(17, 30, 59, 0.18);
    box-sizing: border-box;
    overscroll-behavior: contain;
}

.csp-search-count {
    margin: 3px 8px 8px;
    color: #667085;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Individual course result */

.csp-search-result {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 14px;
    padding: 13px 14px;
    color: #1f2937;
    border-radius: 12px;
    text-decoration: none;
    transition:
        background 0.18s ease,
        transform 0.18s ease;
}

.csp-search-result:hover,
.csp-search-result:focus-visible {
    background: #f1f6fc;
    transform: translateX(2px);
}

.csp-search-result:focus-visible {
    outline: 2px solid #3978b7;
    outline-offset: 2px;
}

.csp-search-result-title {
    grid-column: 1 / -1;
    color: #111e3b;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.5;
}

.csp-search-result-description {
    min-width: 0;
    color: #667085;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.csp-search-duration {
    align-self: start;
    padding: 4px 8px;
    color: #23558c;
    background: #edf4fb;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

/* View all search results */

.csp-search-all {
    display: block;
    margin-top: 7px;
    padding: 12px 14px;
    color: #ffffff;
    background: #23558c;
    border: 1px solid #23558c;
    border-radius: 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    transition:
        background 0.18s ease,
        border-color 0.18s ease;
}

.csp-search-all:hover {
    color: #ffffff;
    background: #111e3b;
    border-color: #111e3b;
}

.csp-search-all:focus-visible {
    outline: 2px solid #3978b7;
    outline-offset: 3px;
}

/* Loading, empty and error messages */

.csp-search-message {
    margin: 0;
    padding: 18px 14px;
    color: #667085;
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
}

.csp-search-message.is-error {
    color: #b42318;
}

.csp-search-message.is-loading {
    color: #23558c;
}

/* Tablet and mobile */

@media (max-width: 600px) {
    .csp-global-search {
        width: calc(100% - 24px);
        margin: 10px auto 14px;
    }

    .csp-search-label {
        font-size: 11px;
    }

    .csp-search-field {
        gap: 10px;
        min-height: 52px;
        padding: 0 13px;
        border-radius: 14px;
    }

    .csp-search-field input {
        padding: 13px 0;
        font-size: 14px;
    }

    .csp-search-results {
        max-height: 60vh;
        padding: 8px;
        border-radius: 14px;
    }

    .csp-search-result {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
        padding: 12px;
    }

    .csp-search-result-title {
        grid-column: auto;
    }

    .csp-search-duration {
        justify-self: start;
    }
}

/* Reduced motion accessibility */

@media (prefers-reduced-motion: reduce) {
    .csp-search-field,
    .csp-search-clear,
    .csp-search-result,
    .csp-search-all {
        transition: none;
    }

    .csp-search-result:hover,
    .csp-search-result:focus-visible {
        transform: none;
    }
}