/* ================================
   SAT Buscador - Diseño Productivo
   ================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f0f4f8;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f4f8;
    min-height: 100vh;
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 640px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--background);
}

/* ================================
   HEADER
   ================================ */
header {
    text-align: center;
    padding: 32px 24px 24px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface) 80%, transparent 100%);
    position: relative;
}

.header-logo {
    width: 100%;
    max-width: 260px;
    height: auto;
    margin-bottom: 12px;
}

.header-slogan {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: -0.01em;
}

/* ================================
   MAIN CONTENT
   ================================ */
main {
    flex: 1;
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 50px;
}

/* ================================
   AD BANNERS
   ================================ */
.ad-placeholder {
    display: block;
    text-decoration: none;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.ad-placeholder:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.ad-container {
    background: var(--surface);
    overflow: hidden;
    position: relative;
}

.ad-container img {
    display: block;
    width: 100%;
    height: auto;
}

.ad-label {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 1;
}

/* Anuncio inline dentro de resultados */
.resultado-ad {
    background: var(--surface);
    padding: 0;
    overflow: hidden;
}

.resultado-ad:hover {
    border-color: var(--border);
    box-shadow: none;
}

.ad-link {
    display: block;
    position: relative;
}

.ad-label-inline {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 1;
}

.ad-link img {
    display: block;
    width: 100%;
    height: auto;
}

/* ================================
   SEARCH FORM
   ================================ */
.search-form {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-lg);
}

.form-group {
    margin-bottom: 20px;
}

.form-group:last-of-type {
    margin-bottom: 24px;
}

label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text);
}

label .icon {
    font-size: 1.1rem;
}

label .optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.85rem;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--background);
}

input[type="text"]:hover,
textarea:hover {
    border-color: var(--text-muted);
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
    background: var(--surface);
}

textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}

/* Submit Button */
.btn-buscar {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.btn-buscar:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

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

.btn-buscar:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-buscar .btn-icon {
    font-size: 1.2rem;
}

/* Loading state */
.btn-buscar.loading {
    pointer-events: none;
}

.btn-buscar.loading .btn-text {
    display: none;
}

.btn-buscar .btn-loading {
    display: none;
}

.btn-buscar.loading .btn-loading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* ================================
   RESULTS SECTION
   ================================ */
.resultados {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.4s ease-out;
}

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

.resultados-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.resultados h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.resultados-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--background);
    padding: 6px 12px;
    border-radius: 20px;
}

/* Result Cards */
.resultado-card {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 12px;
    border: 1px solid transparent;
    transition: var(--transition);
    position: relative;
}

.resultado-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.resultado-card:last-child {
    margin-bottom: 0;
}

.resultado-card.top-result {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.03) 100%);
    border-color: rgba(16, 185, 129, 0.2);
}

.resultado-card.top-result::before {
    content: '⭐ Mejor coincidencia';
    position: absolute;
    top: -10px;
    left: 16px;
    background: var(--success);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.resultado-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.resultado-num {
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.resultado-card.top-result .resultado-num {
    background: var(--success);
}

.resultado-codigo {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    letter-spacing: 1px;
}

.resultado-card.top-result .resultado-codigo {
    color: var(--success-dark);
}

/* Tipo tag */
.tipo-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: auto;
}

.tipo-producto {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary-dark);
}

.tipo-servicio {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success-dark);
}

.resultado-descripcion {
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 14px;
}

/* Copy Button */
.copy-btn {
    margin-top: 14px;
    padding: 10px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.copy-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

.copy-btn.copied {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

/* ================================
   ERROR STATE
   ================================ */
.error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 20px;
    color: #dc2626;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: shake 0.5s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.error .icon {
    font-size: 1.5rem;
}

/* Error especial para servicio no disponible */
.error-servicio {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border-color: #fed7aa;
    color: #c2410c;
}

.error-servicio .icon {
    font-size: 1.8rem;
}

/* ================================
   FOOTER
   ================================ */
footer {
    text-align: center;
    padding: 32px 20px;
    background: var(--surface);
    margin-top: auto;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.footer-brand {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.footer-copy {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-links {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ================================
   TOAST NOTIFICATION
   ================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.mostrar {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast .icon {
    font-size: 1.2rem;
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 480px) {
    main {
        padding: 0 16px 16px;
        gap: 16px;
    }
    
    .search-form {
        padding: 20px;
    }
    
    .resultados {
        padding: 20px;
    }
    
    .resultado-card {
        padding: 16px;
    }
    
    header {
        padding: 24px 16px 20px;
    }
    
    .header-logo {
        max-width: 220px;
    }
    
    .btn-buscar {
        padding: 14px 20px;
    }
}

/* ================================
   UTILITIES
   ================================ */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}