/**
 * DNCG Search Public Styles - Enhanced v2.0
 */

/* Search Form Container */
.dncg-search-form-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.dncg-search-form {
    display: flex !important;
    gap: 0 !important;
    max-width: 900px !important;
    width: 100% !important;
    margin: 0 auto !important;
    align-items: stretch !important;
    background: #F8F9FA !important;
    border-radius: 50px !important;
    overflow: hidden !important;
    border: 3px solid #107F9E !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.dncg-search-form:focus-within {
    border-color: #f89020 !important;
    box-shadow: 0 4px 20px rgba(16, 127, 158, 0.3) !important;
}

.dncg-search-input-wrapper {
    flex: 1 !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
    min-width: 0 !important;
}

.dncg-search-input {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    padding: 1.4rem 1.75rem !important;
    font-size: 1.15rem !important;
    color: #333 !important;
    box-shadow: none !important;
    margin: 0 !important;
    height: auto !important;
    min-height: auto !important;
    line-height: 1.4 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    box-sizing: border-box !important;
}

.dncg-search-input::placeholder {
    color: #999 !important;
    opacity: 1 !important;
}

.dncg-search-input:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
}

.dncg-search-button {
    background: #107F9E !important;
    color: white !important;
    border: none !important;
    padding: 1.4rem 2.5rem !important;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    margin: 0 !important;
    height: auto !important;
    min-height: auto !important;
    line-height: 1 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    box-sizing: border-box !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    flex-shrink: 0 !important;
}

.dncg-search-button:hover {
    background: #0D6A84 !important;
    transform: translateX(-2px) !important;
}

.dncg-search-button:focus {
    outline: 3px solid white !important;
    outline-offset: -3px !important;
}

.dncg-search-button:active {
    transform: scale(0.98) !important;
}

/* Autocomplete Dropdown - Enhanced */
.dncg-search-autocomplete {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
    margin-top: 8px !important;
    z-index: 1000 !important;
    max-height: 400px !important;
    overflow-y: auto !important;
    border: 1px solid #e0e0e0 !important;
}

.dncg-autocomplete-group {
    border-bottom: 2px solid #f0f0f0;
}

.dncg-autocomplete-group:last-child {
    border-bottom: none;
}

.dncg-autocomplete-heading {
    padding: 12px 20px 8px;
    background: linear-gradient(to right, #f8f9fa 0%, #fff 100%);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: #107F9E;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dncg-autocomplete-item {
    display: block;
    padding: 0;
    text-decoration: none;
    color: #2d2d2d;
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
}

.dncg-autocomplete-item:hover,
.dncg-autocomplete-item.dncg-autocomplete-selected {
    background: linear-gradient(to right, #e6f4f8 0%, #f0f9fb 100%);
    border-left-color: #107F9E;
}

.dncg-autocomplete-item-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
}

.dncg-autocomplete-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}

.dncg-autocomplete-text {
    flex: 1;
    min-width: 0;
}

.dncg-autocomplete-title {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 15px;
    color: #1e1e1e;
    line-height: 1.3;
}

.dncg-autocomplete-title strong {
    color: #107F9E;
    font-weight: 700;
}

.dncg-autocomplete-meta {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    line-height: 1.2;
}

/* Loading state */
.dncg-loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.dncg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #107F9E;
    border-radius: 50%;
    animation: dncg-spin 1s linear infinite;
}

@keyframes dncg-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Section highlight animation */
.dncg-section-highlight {
    animation: dncg-highlight 1.5s ease;
}

@keyframes dncg-highlight {
    0%, 100% {
        background: inherit;
    }
    50% {
        background: #fff9e6;
    }
}

/* Filtered view notice */
.dncg-filtered-notice {
    background: #f0f8ff;
    border: 2px solid #107F9E;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin-bottom: 2rem;
    max-width: 100%;
    box-sizing: border-box;
}

.dncg-filtered-notice h2 {
    margin: 0 0 10px;
    font-size: 16px;
    color: #107F9E;
}

.dncg-filtered-notice p {
    margin: 0 0 15px;
    color: #646970;
}

.dncg-back-link {
    display: inline-block;
    padding: 10px 20px;
    background: #107F9E;
    color: white !important;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: background 0.2s;
}

.dncg-back-link:hover {
    background: #0D6A84;
}

/* Search Results Page Specific Styling */
.dncg-search-results {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.dncg-search-results .search-results-header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    max-width: 900px;
    width: calc(100% - 2rem);
    margin: 0 auto 3rem auto;
    box-sizing: border-box;
}

.dncg-search-results .search-results-header h1 {
    text-align: center;
    color: #16254C;
    font-size: 2rem;
    margin: 0 0 2rem 0;
    line-height: 1.2;
    font-weight: 700;
    word-wrap: break-word;
}

/* Override any theme styles on search results page */
.dncg-search-results .dncg-search-form input[type="text"],
.dncg-search-results .dncg-search-input {
    padding: 1.4rem 1.75rem !important;
    font-size: 1.15rem !important;
    line-height: 1.4 !important;
}

.dncg-search-results .dncg-search-button {
    padding: 1.4rem 2.5rem !important;
    font-size: 1.1rem !important;
}

/* Jump to Section Navigation */
.dncg-search-navigation {
    max-width: 100%;
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
    padding: 0 1rem;
    margin-bottom: 2rem;
}

.dncg-search-navigation h2 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-bottom: 1.5rem;
}

.dncg-jump-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    max-width: 100%;
    width: 100%;
}

.dncg-jump-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
    box-sizing: border-box;
    min-width: 0;
    overflow: hidden;
}

.dncg-jump-link:hover {
    border-color: #107F9E;
    background: #f0f9fb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 127, 158, 0.15);
}

.dncg-jump-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.dncg-jump-label {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

.dncg-jump-count {
    background: #107F9E;
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Result Cards */
.dncg-search-results .result-card,
.dncg-search-results .search-result,
.dncg-search-results [class*="result-card"],
.dncg-search-results article {
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    word-wrap: break-word;
}

.dncg-search-results .result-card h2,
.dncg-search-results .result-card h3,
.dncg-search-results .result-card h4,
.dncg-search-results .search-result h2,
.dncg-search-results .search-result h3,
.dncg-search-results article h2,
.dncg-search-results article h3 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.dncg-search-results .result-card p,
.dncg-search-results .search-result p,
.dncg-search-results article p {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Container constraints */
.dncg-search-results .container,
.dncg-search-results .content-wrapper,
.dncg-search-results main,
.dncg-search-results [class*="container"] {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .dncg-search-form {
        flex-direction: column !important;
        border-radius: 12px !important;
        margin: 0 auto 2rem !important;
        max-width: calc(100% - 2rem) !important;
    }
    
    .dncg-search-input {
        padding: 1.1rem 1.25rem !important;
        font-size: 1rem !important;
        border-radius: 12px 12px 0 0 !important;
    }
    
    .dncg-search-button {
        padding: 1.1rem 1.5rem !important;
        font-size: 1rem !important;
        justify-content: center !important;
        border-radius: 0 0 12px 12px !important;
    }
    
    .dncg-search-autocomplete {
        max-height: 350px !important;
        border-radius: 8px !important;
    }

    .dncg-autocomplete-item-content {
        padding: 10px 16px;
        gap: 10px;
    }

    .dncg-autocomplete-icon {
        font-size: 1.25rem;
        width: 28px;
    }

    .dncg-autocomplete-title {
        font-size: 14px;
    }

    .dncg-autocomplete-meta {
        font-size: 12px;
    }

    .dncg-search-results .search-results-header {
        padding: 1.75rem 1.25rem;
        margin: 0 1rem 2rem 1rem;
        width: calc(100% - 2rem);
        border-radius: 12px;
    }

    .dncg-search-results .search-results-header h1 {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
    }

    /* Jump navigation - single column on mobile */
    .dncg-search-navigation {
        padding: 0 0.5rem;
    }

    .dncg-jump-nav {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
        display: grid !important;
    }
    
    .dncg-jump-link {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0.85rem;
    }

    .dncg-jump-icon {
        font-size: 1.5rem;
    }

    .dncg-jump-label {
        font-size: 0.9rem;
    }

    .dncg-jump-count {
        font-size: 0.8rem;
        padding: 0.2rem 0.5rem;
    }

    /* Result cards */
    .dncg-search-results .result-card,
    .dncg-search-results .search-result,
    .dncg-search-results article {
        margin: 0 1rem 1rem 1rem;
        width: calc(100% - 2rem);
    }
}

@media (max-width: 480px) {
    .dncg-search-form {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08) !important;
        max-width: calc(100% - 1rem) !important;
        margin: 0 0.5rem 1.5rem !important;
    }

    .dncg-search-input {
        padding: 1rem 1rem !important;
        font-size: 0.95rem !important;
    }

    .dncg-search-button {
        padding: 1rem !important;
        font-size: 0.95rem !important;
    }

    .dncg-search-results .search-results-header {
        padding: 1.25rem 1rem;
        margin: 0 0.5rem 1.5rem 0.5rem;
        width: calc(100% - 1rem);
    }

    .dncg-search-results .search-results-header h1 {
        font-size: 1.4rem;
        margin-bottom: 1.25rem;
    }

    /* Tighter spacing on very small screens */
    .dncg-search-navigation {
        padding: 0 0.25rem;
    }

    .dncg-jump-nav {
        gap: 0.5rem;
    }

    .dncg-jump-link {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .dncg-jump-icon {
        font-size: 1.25rem;
    }

    .dncg-jump-label {
        font-size: 0.85rem;
    }

    .dncg-result-card,
    .dncg-search-results .search-result,
    .dncg-search-results article {
        margin: 0 0.5rem 1rem 0.5rem;
        width: calc(100% - 1rem);
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .dncg-search-results .search-results-header {
        width: calc(100% - 4rem);
        margin: 0 2rem 3rem 2rem;
    }

    .dncg-search-results .search-results-header h1 {
        font-size: 2.2rem;
    }

    /* Two columns on tablet */
    .dncg-jump-nav {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) {
    .dncg-search-results .search-results-header h1 {
        font-size: 2.5rem;
    }

    /* Four columns on desktop if space allows */
    .dncg-jump-nav {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

/**
 * Featured Results Bar Styles
 * Add to your public/css/search.css
 */

/* Featured Bar Container */
.dncg-search-featured-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Header */
.dncg-featured-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.dncg-featured-icon {
    font-size: 24px;
}

.dncg-featured-title {
    color: white;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

/* Custom Message Box */
.dncg-featured-message {
    background: rgba(255, 255, 255, 0.95);
    border-left: 4px solid #fbbf24;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 15px;
    line-height: 1.6;
    color: #1e293b;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dncg-featured-message p {
    margin: 0 0 8px 0;
}

.dncg-featured-message p:last-child {
    margin-bottom: 0;
}

.dncg-featured-message a {
    color: #2563eb;
    font-weight: 600;
    text-decoration: underline;
    transition: color 0.2s;
}

.dncg-featured-message a:hover {
    color: #1e40af;
}

/* Grid Layout */
.dncg-featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

@media (min-width: 768px) {
    .dncg-featured-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .dncg-featured-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Featured Card */
.dncg-featured-card {
    background: white;
    border-radius: 6px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.dncg-featured-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Badge */
.dncg-featured-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 10px;
    border-radius: 4px;
    width: fit-content;
}

.dncg-featured-badge .badge-icon {
    font-size: 14px;
}

/* Card Title */
.dncg-featured-card-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.dncg-featured-card-title a {
    color: #1a202c;
    text-decoration: none;
    transition: color 0.2s;
}

.dncg-featured-card-title a:hover {
    color: #667eea;
}

/* Meta Info */
.dncg-featured-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: #718096;
}

.dncg-featured-meta span {
    display: inline-flex;
    align-items: center;
}

.dncg-featured-meta span::before {
    content: "•";
    margin-right: 8px;
    color: #cbd5e0;
}

.dncg-featured-meta span:first-child::before {
    content: none;
}

/* Excerpt */
.dncg-featured-excerpt {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #4a5568;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* CTA Button */
.dncg-featured-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
    width: fit-content;
}

.dncg-featured-cta:hover {
    background: #5568d3;
    color: white;
}

.dncg-featured-cta .cta-arrow {
    transition: transform 0.2s;
}

.dncg-featured-cta:hover .cta-arrow {
    transform: translateX(4px);
}

/* Post Type Specific Colors */
.dncg-featured-card[data-type="page"] .dncg-featured-badge {
    color: #48bb78;
    background: rgba(72, 187, 120, 0.1);
}

.dncg-featured-card[data-type="page"] .dncg-featured-cta {
    background: #48bb78;
}

.dncg-featured-card[data-type="page"] .dncg-featured-cta:hover {
    background: #38a169;
}

.dncg-featured-card[data-type="subject_area"] .dncg-featured-badge {
    color: #ed8936;
    background: rgba(237, 137, 54, 0.1);
}

.dncg-featured-card[data-type="subject_area"] .dncg-featured-cta {
    background: #ed8936;
}

.dncg-featured-card[data-type="subject_area"] .dncg-featured-cta:hover {
    background: #dd6b20;
}

/* Divider */
.dncg-search-divider {
    text-align: center;
    position: relative;
    margin: 32px 0;
    overflow: hidden;
}

.dncg-search-divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, #e2e8f0, transparent);
}

.dncg-search-divider span {
    position: relative;
    background: white;
    padding: 0 16px;
    color: #718096;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Mobile Responsiveness */
@media (max-width: 767px) {
    .dncg-search-featured-bar {
        padding: 16px;
        margin-bottom: 24px;
    }
    
    .dncg-featured-title {
        font-size: 16px;
    }
    
    .dncg-featured-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .dncg-featured-card {
        padding: 16px;
    }
    
    .dncg-featured-card-title {
        font-size: 16px;
    }
}

/* Alternative: Subtle/Professional Style */
.dncg-search-featured-bar.subtle {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-left: 4px solid #667eea;
}

.dncg-search-featured-bar.subtle .dncg-featured-title {
    color: #2d3748;
}

.dncg-search-featured-bar.subtle .dncg-featured-card {
    border: 1px solid #e2e8f0;
}