/**
 * Documentation Search - Modal Styles
 * 
 * Full-screen modal search overlay
 * 
 * @package WebtronDocs
 * @version 1.0.0
 */

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    --wds-modal-bg: rgba(0, 0, 0, 0.85);
    --wds-modal-content-bg: rgba(22, 22, 26, 0.98);
    --wds-modal-border: rgba(255, 255, 255, 0.1);
    --wds-modal-radius: 20px;
    --wds-modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --wds-modal-max-width: 680px;
}


/* ============================================
   SEARCH TRIGGER BUTTON
   ============================================ */
.wds-search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wds-search-trigger:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.wds-search-trigger:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.wds-search-trigger__icon {
    flex-shrink: 0;
    opacity: 0.7;
}

.wds-search-trigger__text {
    flex-grow: 1;
    text-align: left;
    opacity: 0.7;
}

.wds-search-trigger__kbd {
    display: flex;
    gap: 4px;
    opacity: 0.5;
}

.wds-search-trigger__kbd kbd {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.3;
}

/* Compact variant for nav */
.wds-search-trigger--compact {
    padding: 8px 12px;
}

.wds-search-trigger--compact .wds-search-trigger__text {
    display: none;
}

/* Icon-only variant */
.wds-search-trigger--icon-only {
    padding: 10px;
    border-radius: 50%;
}

.wds-search-trigger--icon-only .wds-search-trigger__text,
.wds-search-trigger--icon-only .wds-search-trigger__kbd {
    display: none;
}


/* ============================================
   MODAL OVERLAY
   ============================================ */
.wds-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--wds-modal-bg);
    z-index: 99999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 20px 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.wds-modal.wds-modal--open {
    opacity: 1;
    visibility: visible;
}

/* Prevent body scroll when modal is open */
body.wds-modal-open {
    overflow: hidden;
}


/* ============================================
   MODAL CONTENT
   ============================================ */
.wds-modal__content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: var(--wds-modal-max-width);
    background: var(--wds-modal-content-bg);
    border: 1px solid var(--wds-modal-border);
    border-radius: var(--wds-modal-radius);
    box-shadow: var(--wds-modal-shadow);
    transform: translateY(-20px) scale(0.98);
    transition: transform 0.2s ease;
    overflow: hidden;
}

.wds-modal.wds-modal--open .wds-modal__content {
    transform: translateY(0) scale(1);
}


/* ============================================
   MODAL HEADER / SEARCH INPUT
   ============================================ */
.wds-modal__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--wds-modal-border);
}

.wds-modal__icon {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
}

.wds-modal__input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 18px;
    font-family: inherit;
    padding: 0;
    margin: 0;
}

.wds-modal__input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.wds-modal__close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.15s ease;
}

.wds-modal__close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.wds-modal__close kbd {
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
}

/* Mobile: Hide kbd and show X icon */
@media (max-width: 768px) {
    .wds-modal__close kbd {
        display: none;
    }
    
    .wds-modal__close::before {
        content: "\f00d";
        font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free", "FontAwesome";
        font-weight: 900;
        font-size: 16px;
    }
}


/* ============================================
   MODAL BODY / RESULTS
   ============================================ */
.wds-modal__body {
    max-height: 60vh;
    overflow-y: auto;
}

/* Empty state */
.wds-modal__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

.wds-modal__empty-icon {
    margin-bottom: 16px;
    opacity: 0.3;
}

.wds-modal__empty-text {
    font-size: 15px;
}

.wds-modal__empty-hint {
    margin-top: 8px;
    font-size: 13px;
    opacity: 0.7;
}

/* Loading state */
.wds-modal__loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 24px;
    color: rgba(255, 255, 255, 0.6);
}

.wds-modal--loading .wds-modal__loading {
    display: flex;
}

.wds-modal--loading .wds-modal__empty,
.wds-modal--loading .wds-modal__results {
    display: none;
}

.wds-modal__spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: wds-spin 0.8s linear infinite;
}

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

/* Results list */
.wds-modal__results {
    padding: 8px;
}

.wds-modal__results:empty {
    display: none;
}

/* No results */
.wds-modal__no-results {
    padding: 32px 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}


/* ============================================
   RESULT ITEM
   ============================================ */
.wds-modal__result {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    text-decoration: none;
    color: #fff;
    transition: background 0.15s ease;
}

.wds-modal__result:hover,
.wds-modal__result.wds-modal__result--focused {
    background: rgba(255, 255, 255, 0.08);
}

.wds-modal__result-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

.wds-modal__result-icon svg {
    display: block;
}

.wds-modal__result-content {
    flex: 1;
    min-width: 0;
}

.wds-modal__result-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
    line-height: 1.4;
}

.wds-modal__result-title mark {
    background: rgba(255, 215, 0, 0.3);
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

.wds-modal__result-excerpt {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wds-modal__result-excerpt mark {
    background: rgba(255, 215, 0, 0.2);
    color: inherit;
    border-radius: 2px;
}

.wds-modal__result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.wds-modal__result-type {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wds-modal__result-tag {
    display: inline-block;
    padding: 2px 8px;
    background: color-mix(in srgb, var(--wp--preset--color--primary, #2372ce) 20%, transparent);
    border-radius: 4px;
    color: color-mix(in srgb, var(--wp--preset--color--primary, #2372ce) 100%, white 30%);
    font-size: 10px;
    font-weight: 500;
}


/* ============================================
   MODAL FOOTER
   ============================================ */
.wds-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--wds-modal-border);
    background: rgba(0, 0, 0, 0.2);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

.wds-modal__footer-shortcuts {
    display: flex;
    gap: 16px;
}

.wds-modal__footer-shortcut {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wds-modal__footer-shortcut kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    font-family: inherit;
    font-size: 10px;
}


/* ============================================
   MOBILE STYLES
   ============================================ */
@media (max-width: 768px) {
    .wds-modal {
        padding: 0;
        align-items: stretch;
    }
    
    .wds-modal__content {
        max-width: none;
        border-radius: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .wds-modal__body {
        flex-grow: 1;
        max-height: none;
    }
    
    .wds-modal__footer {
        display: none;
    }
    
    .wds-search-trigger__kbd {
        display: none;
    }
}
