/* =============================================================================
   Global Smart Search Widget
   Matches training-catalog theme: purple primary (#6916D9), dark (#1E1B44)
   ============================================================================= */

/* ---------- Trigger Button ---------- */

.tc-gsearch__trigger {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99990;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #6916D9 0%, #1E1B44 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(105, 22, 217, 0.35), 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tc-gsearch__trigger:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 12px 32px rgba(105, 22, 217, 0.45), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tc-gsearch__trigger:active {
    transform: scale(0.96);
}

.tc-gsearch__trigger svg {
    transition: transform 0.25s ease;
}

.tc-gsearch__trigger:hover svg {
    transform: rotate(-12deg);
}

/* ---------- Overlay ---------- */

.tc-gsearch__overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(10, 8, 26, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 16px 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.tc-gsearch__overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ---------- Modal ---------- */

.tc-gsearch__modal {
    width: 100%;
    max-width: 680px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(105, 22, 217, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 72vh;
    transform: translateY(-20px) scale(0.97);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.25s ease;
}

.tc-gsearch__overlay.active .tc-gsearch__modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* ---------- Input Area ---------- */

.tc-gsearch__input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
}

.tc-gsearch__input-icon {
    flex-shrink: 0;
    color: #6916D9;
    opacity: 0.7;
}

.tc-gsearch__input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 17px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #1a1a1a;
    background: transparent;
    caret-color: #6916D9;
}

.tc-gsearch__input::placeholder {
    color: #9CA3AF;
}

/* Loading spinner */
.tc-gsearch__loading {
    display: none;
    flex-shrink: 0;
}

.tc-gsearch__loading.active {
    display: flex;
}

.tc-gsearch__spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid #e5e7eb;
    border-top-color: #6916D9;
    border-radius: 50%;
    animation: tcSearchSpin 0.6s linear infinite;
}

@keyframes tcSearchSpin {
    to { transform: rotate(360deg); }
}

/* Keyboard shortcut badge */
.tc-gsearch__kbd {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 600;
    color: #9CA3AF;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
}

/* ---------- Results Area ---------- */

.tc-gsearch__results {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scroll-behavior: smooth;
}

.tc-gsearch__results::-webkit-scrollbar {
    width: 6px;
}

.tc-gsearch__results::-webkit-scrollbar-track {
    background: transparent;
}

.tc-gsearch__results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* Empty state */
.tc-gsearch__empty {
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.tc-gsearch__empty p {
    color: #9CA3AF;
    font-size: 14px;
    margin: 0;
}

.tc-gsearch__hints {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.tc-gsearch__hints span {
    display: inline-block;
    padding: 4px 12px;
    background: #f3f4f6;
    border-radius: 999px;
    font-size: 12px;
    color: #6B7280;
    font-weight: 500;
}

/* No results state */
.tc-gsearch__no-results {
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.tc-gsearch__no-results p {
    color: #9CA3AF;
    font-size: 14px;
    margin: 0;
}

.tc-gsearch__no-results p:first-of-type {
    font-size: 16px;
    color: #4B5563;
    font-weight: 600;
}

/* Category group */
.tc-gsearch__group {
    padding: 0;
}

.tc-gsearch__group-header {
    padding: 10px 24px 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tc-gsearch__group-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #6916D9;
    opacity: 0.6;
}

.tc-gsearch__group-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6916D9;
    opacity: 0.8;
}

/* Result item */
.tc-gsearch__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 24px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
    border-left: 3px solid transparent;
}

.tc-gsearch__item:hover,
.tc-gsearch__item.active {
    background: linear-gradient(90deg, rgba(105, 22, 217, 0.06), rgba(105, 22, 217, 0.02));
    border-left-color: #6916D9;
}

.tc-gsearch__item-body {
    flex: 1;
    min-width: 0;
}

.tc-gsearch__item-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tc-gsearch__item:hover .tc-gsearch__item-title,
.tc-gsearch__item.active .tc-gsearch__item-title {
    color: #6916D9;
}

.tc-gsearch__item-excerpt {
    font-size: 12px;
    color: #6B7280;
    margin: 2px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

.tc-gsearch__item-excerpt mark {
    background: rgba(105, 22, 217, 0.15);
    color: #6916D9;
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}

.tc-gsearch__item-badge {
    flex-shrink: 0;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(105, 22, 217, 0.1);
    color: #6916D9;
    border-radius: 6px;
    align-self: center;
}

.tc-gsearch__item-arrow {
    flex-shrink: 0;
    align-self: center;
    color: #d1d5db;
    transition: color 0.15s ease, transform 0.15s ease;
}

.tc-gsearch__item:hover .tc-gsearch__item-arrow,
.tc-gsearch__item.active .tc-gsearch__item-arrow {
    color: #6916D9;
    transform: translateX(2px);
}

/* ---------- Footer ---------- */

.tc-gsearch__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}

.tc-gsearch__footer-keys {
    display: flex;
    gap: 16px;
    align-items: center;
}

.tc-gsearch__footer-keys span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #9CA3AF;
}

.tc-gsearch__footer-keys kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 600;
    color: #6B7280;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

.tc-gsearch__footer-count {
    font-size: 12px;
    color: #9CA3AF;
    font-weight: 500;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
    .tc-gsearch__overlay {
        padding: 4vh 8px;
    }

    .tc-gsearch__modal {
        max-height: 85vh;
        border-radius: 12px;
    }

    .tc-gsearch__input-wrap {
        padding: 16px;
    }

    .tc-gsearch__item {
        padding: 10px 16px;
    }

    .tc-gsearch__group-header {
        padding: 10px 16px 6px;
    }

    .tc-gsearch__footer {
        padding: 10px 16px;
    }

    .tc-gsearch__footer-keys {
        gap: 10px;
    }

    .tc-gsearch__trigger {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }
}

/* ---------- Skeleton loading ---------- */

.tc-gsearch__skeleton {
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tc-gsearch__skeleton-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tc-gsearch__skeleton-bar {
    height: 14px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: tcSearchShimmer 1.5s infinite ease-in-out;
    border-radius: 6px;
}

.tc-gsearch__skeleton-bar--sm {
    width: 40%;
    height: 10px;
}

.tc-gsearch__skeleton-bar--md {
    width: 75%;
}

.tc-gsearch__skeleton-bar--lg {
    width: 90%;
}

@keyframes tcSearchShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Inline Shortcode Bar [global_search] ---------- */

.tc-gsearch-inline {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.tc-gsearch-inline__bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tc-gsearch-inline__bar:hover {
    border-color: #6916D9;
    box-shadow: 0 0 0 3px rgba(105, 22, 217, 0.08), 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.tc-gsearch-inline__icon {
    flex-shrink: 0;
    color: #6916D9;
    opacity: 0.6;
}

.tc-gsearch-inline__bar:hover .tc-gsearch-inline__icon {
    opacity: 1;
}

.tc-gsearch-inline__text {
    flex: 1;
    font-size: 15px;
    color: #9CA3AF;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    user-select: none;
}

.tc-gsearch-inline__kbd {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    color: #9CA3AF;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

@media (max-width: 640px) {
    .tc-gsearch-inline__kbd {
        display: none;
    }

    .tc-gsearch-inline__bar {
        padding: 12px 16px;
    }
}

/* ---------- Icon Only Version ---------- */

.tc-gsearch-icon-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    color: #6916D9;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tc-gsearch-icon-only:hover {
    border-color: #6916D9;
    background: #fdfbff;
    transform: scale(1.05) translateY(-1px);
    box-shadow: 0 4px 12px rgba(105, 22, 217, 0.1);
}

.tc-gsearch-icon-only svg {
    transition: transform 0.2s ease;
}

.tc-gsearch-icon-only:hover svg {
    transform: scale(1.1);
}

/* =============================================================================
   Search Term Highlight – Destination Page
   Applied by search-highlight.js when ?tc_highlight=<term> is present
   ============================================================================= */

mark.tc-search-highlight {
    background: #fef08a;          /* warm yellow */
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
    font-weight: inherit;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* The very first match gets a brief pulse so the user's eye is drawn to it */
mark.tc-search-highlight--first {
    animation: tcHighlightPulse 1.8s ease 0.4s both;
}

@keyframes tcHighlightPulse {
    0%   { background: #fbbf24; box-shadow: 0 0 0 0   rgba(251, 191,  36, 0.70); }
    30%  { background: #fde047; box-shadow: 0 0 0 6px rgba(251, 191,  36, 0.30); }
    60%  { background: #fef08a; box-shadow: 0 0 0 10px rgba(251, 191,  36, 0.10); }
    100% { background: #fef08a; box-shadow: 0 0 0 0   rgba(251, 191,  36, 0); }
}
