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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    overflow-x: hidden;
    padding: 20px;
}

.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.3) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -50px) rotate(10deg); }
    66% { transform: translate(-20px, 20px) rotate(-5deg); }
}

.container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 40px;
}

/* Tarjeta de Búsqueda */
.search-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    padding: 48px 40px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    max-width: 600px;
    margin: 0 auto;
}

.search-card:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    color: white;
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    font-weight: 300;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.input-wrapper {
    position: relative;
}

#searchInput {
    width: 100%;
    padding: 18px 20px 18px 52px;
    font-size: 1rem;
    border: none;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#searchInput::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#searchInput:focus {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.7);
}

.engine-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.engine-selector label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 500;
}

#engineSelect {
    padding: 14px 16px;
    font-size: 1rem;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.8)' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

#engineSelect option {
    background: #764ba2;
    color: white;
}

#engineSelect:focus {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.search-btn:active {
    transform: translateY(0);
}

.search-btn svg {
    width: 20px;
    height: 20px;
}

.footer {
    text-align: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

.footer a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

.footer a:hover {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

.footer a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: -2px;
    left: 0;
    background-color: rgba(255, 255, 255, 0.8);
    transition: width 0.3s ease;
}

.footer a:hover::after {
    width: 100%;
}

/* ============================================
   SECCIÓN DE RESULTADOS (FIX FINAL)
   ============================================ */

/* Contenedor Principal: Forzar visibilidad y espacio */
.results-section {
    width: 100% !important;
    margin-top: 30px;
    display: none !important; /* Se activará con JS */
    animation: fadeIn 0.5s ease forwards;
    min-height: 200px; /* Altura mínima para evitar colapso */
    overflow: visible !important;
}

/* Clase auxiliar para forzar display block desde JS si falla */
.results-section.active {
    display: block !important;
}

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

/* Header de Resultados */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-bottom: 20px;
    color: white;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
    position: relative;
}

.view-more-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    text-decoration: none;
    z-index: 10;
}

.view-more-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* GRID: 4 Columnas con espacio explícito */
.results-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 20px;
    width: 100%;
    min-height: 100px;
    position: relative;
    z-index: 5;
}

/* TARJETAS: Forzar altura y visibilidad */
.result-card {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-height: 160px !important; /* Altura mínima crítica */
    display: flex !important;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
    z-index: 5;
    visibility: visible !important;
    opacity: 1 !important; /* Forzar opacidad 1 */
}

.result-card:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.4) !important;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    opacity: 0;
    transition: opacity 0.3s;
}

.result-card:hover::before {
    opacity: 1;
}

/* Contenido interno */
.result-title {
    color: #fff !important;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-snippet {
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 12px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.result-engine {
    color: rgba(255, 255, 255, 0.5) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.result-domain {
    color: rgba(255, 255, 255, 0.6) !important;
    text-decoration: none;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* FallBack */
.fallback-container {
    width: 100%;
    margin-top: 20px;
}

.fallback-message {
    text-align: center;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

.fallback-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.fallback-message h3 {
    color: white;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.fallback-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.fallback-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: white;
    transition: transform 0.2s;
}

.fallback-btn.duckduckgo { background: #de5833; }
.fallback-btn.google { background: #4285f4; }
.fallback-btn.bing { background: #00897b; }

.fallback-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Responsive */
@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr !important;
    }
    
    .search-card {
        padding: 24px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
}

/* Notificación */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    color: #667eea;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes slideUp {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}