/**
 * Knowledge Base Shortcode Styles
 * Styles for [kb_grid] shortcode
 */

/* Wrapper */
.kb-shortcode-wrapper {
    margin: 24px 0;
    width: 100% !important;
    max-width: 100% !important;
}

/* Search Container */
.kb-shortcode-search-container,
.kb-shortcode-wrapper .kb-shortcode-search-container {
    position: relative !important;
    margin-bottom: 24px !important;
    z-index: 1001 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
}

/* Search Overlay - Modal-like darkening effect */
.kb-shortcode-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(10px);
}

.kb-shortcode-search-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.kb-shortcode-search-box,
.kb-shortcode-wrapper .kb-shortcode-search-box,
.kb-shortcode-search-container .kb-shortcode-search-box {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 100% !important;
}

.kb-shortcode-search-icon {
    position: absolute;
    left: 16px;
    color: #71717a;
    pointer-events: none;
}

.kb-shortcode-search-input,
.kb-shortcode-wrapper .kb-shortcode-search-input,
input.kb-shortcode-search-input,
input[type="text"].kb-shortcode-search-input,
.kb-shortcode-search-box input.kb-shortcode-search-input,
.kb-shortcode-search-container input.kb-shortcode-search-input,
.kb-shortcode-wrapper input[type="text"].kb-shortcode-search-input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    padding: 14px 44px 14px 48px !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    background: #18181b !important;
    border: 1px solid #27272a !important;
    border-radius: 12px !important;
    color: #ffffff !important;
    outline: none !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important;
    height: auto !important;
    line-height: normal !important;
    margin: 0 !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.kb-shortcode-search-input::placeholder,
.kb-shortcode-wrapper .kb-shortcode-search-input::placeholder {
    color: #71717a !important;
    opacity: 1 !important;
}

.kb-shortcode-search-input:focus,
.kb-shortcode-wrapper .kb-shortcode-search-input:focus {
    border-color: transparent !important;
    background: #1f1f23 !important;
    outline: 2px solid #FF0144 !important;
    outline-offset: 2px !important;
    box-shadow: none !important;
}

.kb-shortcode-search-clear,
.kb-shortcode-wrapper .kb-shortcode-search-clear,
button.kb-shortcode-search-clear,
span.kb-shortcode-search-clear {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #71717a !important;
    cursor: pointer !important;
    line-height: 1 !important;
    padding: 5px 10px 6px 10px!important;
    transition: all 0.2s ease !important;
    background: #3f3f46 !important;
    background-color: #3f3f46 !important;
    border: none !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    margin: 0 !important;
    text-decoration: none !important;
    min-width: auto !important;
    min-height: auto !important;
    width: auto !important;
    height: auto !important;
    align-items: center !important;
    justify-content: center !important;
}

.kb-shortcode-search-clear:hover,
.kb-shortcode-wrapper .kb-shortcode-search-clear:hover,
button.kb-shortcode-search-clear:hover,
span.kb-shortcode-search-clear:hover {
    color: #ffffff !important;
    background: #52525b !important;
    background-color: #52525b !important;
    border: none !important;
    box-shadow: none !important;
}

/* Search Results Dropdown */
.kb-shortcode-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.kb-shortcode-search-loading,
.kb-shortcode-search-empty,
.kb-shortcode-search-error {
    padding: 20px;
    text-align: center;
    color: #71717a;
    font-size: 14px;
}

.kb-shortcode-search-result,
.kb-shortcode-wrapper .kb-shortcode-search-result,
a.kb-shortcode-search-result {
    display: block;
    padding: 12px 16px;
    text-decoration: none !important;
    color: inherit;
    border-bottom: 1px solid #27272a;
    transition: background 0.15s ease;
}

.kb-shortcode-search-result:last-child {
    border-bottom: none;
}

.kb-shortcode-search-result:hover,
.kb-shortcode-search-result.active,
.kb-shortcode-wrapper .kb-shortcode-search-result:hover,
a.kb-shortcode-search-result:hover {
    background: #1f1f23;
    text-decoration: none !important;
}

.kb-shortcode-search-result:hover .kb-shortcode-search-result-title,
.kb-shortcode-search-result.active .kb-shortcode-search-result-title {
    color: var(--result-highlight-color, #60a5fa);
}

.kb-shortcode-search-result-kb {
    font-size: 10px;
    font-weight: 500;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.kb-shortcode-search-result-title {
    font-size: 15px;
    font-weight: 500;
    color: #ffffff;
    transition: color 0.15s ease;
}

/* Grid Container */
.kb-shortcode-grid {
    display: grid;
    gap: 24px;
}

.kb-shortcode-grid-1-cols {
    grid-template-columns: 1fr;
}

.kb-shortcode-grid-2-cols {
    grid-template-columns: repeat(2, 1fr);
}

.kb-shortcode-grid-3-cols {
    grid-template-columns: repeat(3, 1fr);
}

.kb-shortcode-grid-4-cols {
    grid-template-columns: repeat(4, 1fr);
}

/* Card */
.kb-shortcode-card,
.kb-shortcode-wrapper .kb-shortcode-card,
a.kb-shortcode-card {
    display: flex;
    flex-direction: column;
    background: #09090b;
    border: 1px solid #27272a;
    border-radius: 12px;
    padding: 24px;
    text-decoration: none !important;
    color: inherit;
    transition: all 0.2s ease;
    min-height: 200px;
}

.kb-shortcode-card:hover,
.kb-shortcode-wrapper .kb-shortcode-card:hover,
a.kb-shortcode-card:hover {
    background: #1f1f23;
    border-color: #3f3f46;
    transform: translateY(-2px);
    text-decoration: none !important;
}

.kb-shortcode-card:hover .kb-shortcode-card-title {
    color: var(--kb-highlight-color, #60a5fa);
}

.kb-shortcode-card:hover .kb-shortcode-card-link {
    color: var(--kb-hover-color, #93c5fd);
}

/* Card Content */
.kb-shortcode-card-content {
    flex: 1;
}

.kb-shortcode-card-logo {
    margin-bottom: 16px;
}

.kb-shortcode-card-logo img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.kb-shortcode-card-title,
.kb-shortcode-card:hover .kb-shortcode-card-title {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 12px 0;
    line-height: 1.3;
    transition: color 0.2s ease;
    text-decoration: none !important;
}

.kb-shortcode-card-description,
.kb-shortcode-card:hover .kb-shortcode-card-description {
    font-size: 14px;
    color: #a1a1aa;
    line-height: 1.6;
    margin: 0;
    text-decoration: none !important;
}

/* Card Footer */
.kb-shortcode-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
}

.kb-shortcode-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kb-shortcode-card-count {
    font-size: 13px;
    color: #71717a;
}

.kb-shortcode-card-updated {
    font-size: 11px;
    color: #52525b;
}

.kb-shortcode-card-link {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: var(--kb-highlight-color, #60a5fa);
    text-transform: uppercase;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Empty State */
.kb-grid-empty {
    text-align: center;
    padding: 40px;
    color: #71717a;
    font-size: 14px;
}

/* Responsive */
@media screen and (max-width: 1024px) {
    .kb-shortcode-grid-4-cols {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (max-width: 768px) {
    .kb-shortcode-grid-3-cols,
    .kb-shortcode-grid-4-cols {
        grid-template-columns: repeat(2, 1fr);
    }

    .kb-shortcode-card {
        padding: 20px;
    }
}

@media screen and (max-width: 480px) {
    .kb-shortcode-grid-2-cols,
    .kb-shortcode-grid-3-cols,
    .kb-shortcode-grid-4-cols {
        grid-template-columns: 1fr;
    }
}

/* Light Theme Support (for sites with light backgrounds) */
.kb-theme-light .kb-shortcode-card {
    background: #ffffff;
    border-color: #e4e4e7;
}

.kb-theme-light .kb-shortcode-card:hover {
    background: #fafafa;
    border-color: #d4d4d8;
}

.kb-theme-light .kb-shortcode-card-title {
    color: #18181b;
}

.kb-theme-light .kb-shortcode-card-description {
    color: #52525b;
}

.kb-theme-light .kb-shortcode-card-footer {
    border-top-color: #e4e4e7;
}

.kb-theme-light .kb-shortcode-card-count {
    color: #71717a;
}

/* Light Theme - Search */
.kb-theme-light .kb-shortcode-search-input {
    background: #ffffff;
    border-color: #e4e4e7;
    color: #18181b;
}

.kb-theme-light .kb-shortcode-search-input::placeholder {
    color: #a1a1aa;
}

.kb-theme-light .kb-shortcode-search-input:focus {
    border-color: #d4d4d8;
    background: #fafafa;
}

.kb-theme-light .kb-shortcode-search-icon {
    color: #a1a1aa;
}

.kb-theme-light .kb-shortcode-search-clear,
.kb-theme-light .kb-shortcode-wrapper .kb-shortcode-search-clear {
    color: #a1a1aa !important;
    background: transparent !important;
    background-color: transparent !important;
}

.kb-theme-light .kb-shortcode-search-clear:hover,
.kb-theme-light .kb-shortcode-wrapper .kb-shortcode-search-clear:hover {
    color: #71717a !important;
    background: transparent !important;
    background-color: transparent !important;
}

.kb-theme-light .kb-shortcode-search-results {
    background: #ffffff;
    border-color: #e4e4e7;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.kb-theme-light .kb-shortcode-search-loading,
.kb-theme-light .kb-shortcode-search-empty,
.kb-theme-light .kb-shortcode-search-error {
    color: #71717a;
}

.kb-theme-light .kb-shortcode-search-result {
    border-bottom-color: #e4e4e7;
}

.kb-theme-light .kb-shortcode-search-result:hover,
.kb-theme-light .kb-shortcode-search-result.active {
    background: #fafafa;
}

.kb-theme-light .kb-shortcode-search-result-kb {
    color: #71717a;
}

.kb-theme-light .kb-shortcode-search-result-title {
    color: #18181b;
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus visible styles for keyboard navigation */
.kb-shortcode-search-input:focus-visible,
.kb-shortcode-wrapper .kb-shortcode-search-input:focus-visible {
    outline: 2px solid #FF0144 !important;
    outline-offset: 2px !important;
    border-color: transparent !important;
}

.kb-shortcode-card:focus-visible {
    outline: 2px solid var(--kb-highlight-color, #60a5fa);
    outline-offset: 2px;
}

.kb-shortcode-search-result:focus-visible {
    outline: 2px solid var(--result-highlight-color, #60a5fa);
    outline-offset: -2px;
    background: #1f1f23;
}

.kb-shortcode-search-clear:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Light theme focus styles */
.kb-theme-light .kb-shortcode-search-input:focus-visible {
    outline-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

.kb-theme-light .kb-shortcode-card:focus-visible {
    outline-color: var(--kb-highlight-color, #3b82f6);
}

.kb-theme-light .kb-shortcode-search-result:focus-visible {
    outline-color: var(--result-highlight-color, #3b82f6);
    background: #fafafa;
}

/* Minimum touch target size (44x44px) - applied when visible */
.kb-shortcode-search-clear[style*="display: flex"],
.kb-shortcode-search-clear[style*="display:flex"] {
    min-width: 44px;
    min-height: 44px;
}

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

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .kb-shortcode-card,
    .kb-shortcode-search-input,
    .kb-shortcode-search-result,
    .kb-shortcode-search-clear,
    .kb-shortcode-card-title,
    .kb-shortcode-card-link {
        transition: none !important;
    }

    .kb-shortcode-card:hover {
        transform: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    .kb-shortcode-card {
        border-width: 2px;
    }

    .kb-shortcode-search-input {
        border-width: 2px;
    }

    .kb-shortcode-search-results {
        border-width: 2px;
    }

    .kb-shortcode-search-result.active,
    .kb-shortcode-search-result:focus-visible {
        outline-width: 3px;
    }
}

/* ========================================
   PLUGIN OVERRIDE PROTECTION
   Maximum specificity overrides to prevent
   other plugins from breaking styles
   ======================================== */
body .kb-shortcode-wrapper,
html body .kb-shortcode-wrapper,
#main .kb-shortcode-wrapper,
.site-content .kb-shortcode-wrapper,
.entry-content .kb-shortcode-wrapper,
article .kb-shortcode-wrapper {
    width: 100% !important;
    max-width: 100% !important;
}

body .kb-shortcode-wrapper .kb-shortcode-search-container,
html body .kb-shortcode-wrapper .kb-shortcode-search-container {
    width: 100% !important;
    max-width: 100% !important;
}

body .kb-shortcode-wrapper .kb-shortcode-search-box,
html body .kb-shortcode-wrapper .kb-shortcode-search-box {
    width: 100% !important;
    max-width: 100% !important;
}

body .kb-shortcode-wrapper .kb-shortcode-search-input,
html body .kb-shortcode-wrapper .kb-shortcode-search-input,
body .kb-shortcode-wrapper input.kb-shortcode-search-input,
html body .kb-shortcode-wrapper input.kb-shortcode-search-input,
body .kb-shortcode-wrapper input[type="text"].kb-shortcode-search-input,
html body .kb-shortcode-wrapper input[type="text"].kb-shortcode-search-input,
body input#kb-shortcode-search,
html body input#kb-shortcode-search {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}
