/* Modern Results Page Styling - Bulletproof for Python HTML Output */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #0a0e14;
    background-image: 
        radial-gradient(at 20% 10%, rgba(255,140,66,0.08) 0px, transparent 50%),
        radial-gradient(at 80% 90%, rgba(255,140,66,0.05) 0px, transparent 50%);
    color: rgba(255,255,255,0.87);
    min-height: 100vh;
}

/* Results Container */
.results-container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px 80px;
}

/* Results Header */
.results-header {
    text-align: center;
    margin-bottom: 40px;
}

.results-logo {
    margin-bottom: 24px;
}

.results-logo img {
    max-width: 450px;
    filter: drop-shadow(0 4px 16px rgba(255,140,66,0.3));
}

.search-info {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 24px 32px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 32px;
}

.search-term {
    font-size: 20px;
    color: rgba(255,255,255,0.95);
    margin-bottom: 12px;
}

.search-term strong {
    color: #ed6a1a;
    font-weight: 600;
}

.search-meta {
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    line-height: 1.6;
}

.search-meta p {
    margin: 8px 0;
}

/* Speed Options Navigation - Enhanced with Context */
.speed-nav {
    background: linear-gradient(135deg, #1a1d23 0%, #0f1114 100%);
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 
        0 4px 20px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.05);
    margin-bottom: 32px;
    border: 1px solid rgba(255,255,255,0.12);
}

.speed-nav-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.speed-nav-title {
    font-size: 20px;
    color: rgba(255,255,255,0.95);
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.speed-nav-description {
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.speed-buttons-wrapper {
    text-align: center;
}

.speed-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.speed-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 100px;
}

.speed-btn-name {
    font-weight: 600;
    font-size: 13px;
}

.speed-btn-count {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    font-weight: 500;
}

.speed-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,140,66,0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.speed-btn:hover .speed-btn-count {
    color: rgba(255,140,66,0.8);
}

.speed-btn.active {
    background: rgba(255,140,66,0.15);
    border: 2px solid #ff8c42;
    color: rgba(255,255,255,0.95);
    box-shadow: 
        0 0 16px rgba(255,140,66,0.4),
        inset 0 0 12px rgba(255,140,66,0.2);
    font-weight: 600;
}

.speed-btn.active .speed-btn-name {
    color: #ff8c42;
}

.speed-btn.active .speed-btn-count {
    color: rgba(255,140,66,0.7);
}

.new-search-btn {
    background: linear-gradient(135deg, #ff8c42 0%, #ff6b1a 100%);
    border: none;
    color: #0a0e14;
    padding: 12px 28px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 
        0 0 16px rgba(255,140,66,0.5),
        0 4px 12px rgba(0,0,0,0.4);
    display: inline-block;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.new-search-btn:hover {
    box-shadow: 
        0 0 24px rgba(255,140,66,0.7),
        0 6px 16px rgba(0,0,0,0.5);
    transform: translateY(-2px);
}

.premium-search-btn {
    background: rgba(255,140,66,0.15);
    border: 2px solid rgba(255,140,66,0.5);
    color: #ff8c42;
    padding: 12px 28px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 
        0 0 16px rgba(255,140,66,0.3),
        0 4px 12px rgba(0,0,0,0.4);
    display: inline-block;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.premium-search-btn:hover {
    background: linear-gradient(135deg, #ff8c42 0%, #ff6b1a 100%);
    color: #0a0e14;
    border-color: #ff8c42;
    box-shadow: 
        0 0 24px rgba(255,140,66,0.7),
        0 6px 16px rgba(0,0,0,0.5);
    transform: translateY(-2px);
}

/* View Toggle */
.view-toggle {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.view-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-btn:hover {
    border-color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.8);
}

.view-btn.active {
    background: linear-gradient(135deg, #ff8c42 0%, #ff6b1a 100%);
    border-color: #ff8c42;
    color: #0a0e14;
    font-weight: 700;
    box-shadow: 
        0 0 16px rgba(255,140,66,0.5),
        0 4px 12px rgba(0,0,0,0.4);
}

/* Results Count */
.results-count {
    text-align: center;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 20px;
    font-weight: 600;
    padding: 16px 28px;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.15);
    display: inline-block;
    min-width: 250px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.results-count strong {
    color: #ff8c42;
    font-size: 20px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

/* Searching animation */
#results-counter {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255,140,66, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255,140,66, 0);
    }
}

/* New result fade in animation */
.results-item {
    animation: fadeInResult 0.4s ease-out;
}

@keyframes fadeInResult {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* CRITICAL: Results Grid - Bulletproof for Python HTML */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
    width: 100%;
}

/* CRITICAL: Result Item - Must contain Python's HTML properly */
.results-item {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
    /* DO NOT use display: flex - breaks Python HTML */
    display: block !important;
    position: relative;
    min-height: 180px;
    overflow: visible;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.results-item:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    border-color: #ed6a1a;
}

/* Results Item Header */
.results-item-header {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    /* Use clearfix pattern */
    overflow: auto;
}

.results-item-header::after {
    content: "";
    display: table;
    clear: both;
}

.results-item-icon {
    float: left;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(255,255,255,0.15);
    margin-right: 12px;
    position: relative;
}

.results-item-icon img {
    max-width: 28px;
    max-height: 28px;
    border-radius: 4px;
    object-fit: contain;
}

/* Fallback icon when favicon fails to load */
.results-item-icon img[src*="favicon.ico"] {
    /* Show a default icon on error */
}

.results-item-icon::before {
    content: '🌐';
    font-size: 20px;
    position: absolute;
    opacity: 0.3;
    z-index: 0;
}

.results-item-icon img {
    position: relative;
    z-index: 1;
}

.results-item-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255,255,255,0.95);
    margin: 10px 0 0 0;
    line-height: 1.3;
}

.results-item-header p {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255,255,255,0.95);
    margin: 10px 0 0 0;
    line-height: 1.3;
}

/* Results Item Content */
.results-item-content {
    margin-bottom: 0;
    /* Use clearfix */
    overflow: visible;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Ensure any nested content from Python never forces horizontal overflow */
.results-item img,
.results-item table,
.results-item iframe,
.results-item pre,
.results-item code {
    max-width: 100%;
}

.results-item a {
    word-break: break-all;
}

.results-item-content::after {
    content: "";
    display: table;
    clear: both;
}

.results-item-content p {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    line-height: 1.6;
    margin: 8px 0;
}

.results-item-content strong {
    color: rgba(255,255,255,0.95);
    font-weight: 600;
}

/* Button Wrapper */
.results-button-wrapper {
    margin-top: 12px;
    /* Use clearfix */
    overflow: visible;
}

.results-button-wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/* Hide Python's clear div completely */
.results-item-content > div[style*="clear"],
.results-item div[style*="clear: both;"],
div[style="clear: both;"] {
    display: none !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    visibility: hidden !important;
}

/* Buttons */
.results-button,
.pretty-button.results-button {
    background: linear-gradient(135deg, #ff8c42 0%, #ed6a1a 100%) !important;
    color: white !important;
    border: none !important;
    padding: 8px 20px !important;
    border-radius: 20px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    display: inline-block !important;
    margin: 0 8px 8px 0 !important;
    box-shadow: 0 2px 8px rgba(255,140,66, 0.3) !important;
    transition: all 0.3s ease !important;
    float: left !important;
}

.results-button:hover,
.pretty-button.results-button:hover {
    background: linear-gradient(135deg, #ff9d5c 0%, #f07a2a 100%) !important;
    box-shadow: 0 4px 12px rgba(255,140,66, 0.4) !important;
    transform: translateY(-2px) !important;
    color: white !important;
    z-index: 10 !important;
    position: relative !important;
}

/* LIST VIEW Specific */
.results-grid.list-view {
    grid-template-columns: 1fr;
    gap: 12px;
}

.list-view .results-item {
    min-height: auto;
    padding: 14px 18px;
}

.list-view .results-item-header {
    display: inline-block;
    width: auto;
    border: none;
    padding: 0;
    margin: 0 16px 0 0;
    vertical-align: middle;
}

.list-view .results-item-icon {
    width: 36px;
    height: 36px;
    margin: 0;
    display: inline-block;
    vertical-align: middle;
}

.list-view .results-item-title {
    display: inline-block;
    margin: 0 0 0 10px;
    font-size: 15px;
    vertical-align: middle;
    min-width: 150px;
}

.list-view .results-item-header p {
    display: inline-block;
    margin: 0 0 0 10px;
    font-size: 15px;
    vertical-align: middle;
    min-width: 150px;
}

.list-view .results-item-content {
    display: inline-block;
    vertical-align: middle;
    width: auto;
}

.list-view .results-item-content > p:not(:first-child) {
    display: none;
}

.list-view .results-item-content p {
    margin: 0;
    display: inline-block;
}

.list-view .results-button-wrapper {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    float: none;
    margin: 0;
    width: auto;
}

.list-view .results-button {
    margin: 0 0 0 8px !important;
    padding: 6px 16px !important;
    font-size: 12px !important;
    float: none !important;
}

/* No Results / Messages */
.results-message {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 48px 32px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    border: 1px dashed rgba(255,255,255,0.15);
}

.results-message p {
    font-size: 16px;
    color: rgba(255,255,255,0.6);
    margin: 12px 0;
}

/* Footer - Dark Cyber */
.modern-footer {
    background: rgba(0,0,0,0.4);
    padding: 40px 20px 24px;
    text-align: center;
    margin-top: 60px;
    border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

.modern-footer a {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 13px;
    margin: 0 12px;
    transition: color 0.3s ease;
}

.modern-footer a:hover {
    color: #ff8c42;
}

.modern-footer p {
    margin: 12px 0;
    color: rgba(255,255,255,0.3);
}

/* Interstitial Ads Between Results */
.results-interstitial-ad {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    margin: 24px 0;
}

.results-interstitial-inner {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.08);
    text-align: center;
    max-width: 100%;
    box-sizing: border-box;
}

.results-interstitial-inner .ad-label {
    display: block;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    margin-bottom: 4px;
}

/* Ensure Google ads never force horizontal overflow */
.ad-slot-container,
.full-width-ad {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

ins.adsbygoogle {
    max-width: 100% !important;
    box-sizing: border-box;
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    .results-container {
        padding: 24px 16px 60px;
    }
    
    /* On phone view we keep things simple and just use list view */
    .view-toggle {
        display: none;
    }
    
    .results-logo img {
        max-width: 300px;
    }
    
    .results-section {
        margin: 0;
        padding: 0;
        overflow-x: hidden;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        margin: 0;
        width: 100%;
    }
    
    .search-info {
        padding: 20px 24px;
    }
    
    .search-term {
        font-size: 18px;
    }
    
    .search-meta {
        font-size: 13px;
    }
    
    .speed-nav {
        padding: 24px 20px;
    }
    
    .speed-nav-title {
        font-size: 18px;
    }
    
    .speed-nav-description {
        font-size: 12px;
    }
    
    .speed-buttons {
        gap: 8px;
    }
    
    .speed-btn {
        padding: 8px 16px;
        font-size: 12px;
        min-width: 90px;
    }
    
    .speed-btn-name {
        font-size: 12px;
    }
    
    .speed-btn-count {
        font-size: 9px;
    }
    
    .new-search-btn,
    .premium-search-btn {
        padding: 10px 20px;
        font-size: 13px;
        margin-bottom: 12px;
    }
    
    .results-item {
        padding: 16px;
        margin: 0;
    }
    
    .list-view .results-item-header {
        display: block;
        margin-bottom: 10px;
    }
    
    .list-view .results-item-content {
        display: block;
        width: 100%;
    }
    
    .list-view .results-button-wrapper {
        position: static;
        transform: none;
        display: block;
        margin-top: 10px;
        width: 100%;
        justify-content: flex-start;
    }
}

@media screen and (max-width: 480px) {
    .results-logo img {
        max-width: 250px;
    }
    
    .search-info {
        padding: 16px 20px;
    }
    
    .search-term {
        font-size: 16px;
    }
    
    .search-meta {
        font-size: 12px;
    }
    
    .search-meta p {
        margin: 6px 0;
    }
    
    .speed-nav {
        padding: 20px 16px;
    }
    
    .speed-nav-title {
        font-size: 16px;
    }
    
    .speed-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .speed-btn {
        width: 100%;
        text-align: center;
    }
    
    .action-buttons {
        flex-direction: column !important;
        gap: 10px !important;
        width: 100%;
    }
    
    .new-search-btn,
    .premium-search-btn {
        width: 100%;
        text-align: center;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .results-button {
        font-size: 12px !important;
        padding: 7px 16px !important;
    }
}

/* Mobile Performance Optimizations - Better INP */
@media screen and (max-width: 768px) {
    /* Reduce transition durations for faster INP */
    .speed-btn,
    .view-btn,
    .new-search-btn,
    .premium-search-btn,
    .results-item,
    .results-button {
        transition-duration: 0.15s !important;
    }
    
    /* Disable result fade-in animation on mobile */
    .results-item {
        animation: none !important;
    }
    
    /* Disable pulse animation on counter */
    #results-counter {
        animation: none !important;
    }
}

/* Content visibility for off-screen elements */
.modern-footer {
    content-visibility: auto;
    contain-intrinsic-size: 0 180px;
}

/* Reduced Motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}