/* ============================================
   Agilmente.net - Estilos Globales
   ============================================
   Estos estilos complementan a Tailwind CSS (CDN).
   Contienen animaciones, utilidades personalizadas
   y estilos para componentes que no se cubren fácilmente
   con clases utilitarias.
*/

/* --- Reset y Base --- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
}

/* --- Scrollbar personalizado --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* --- Animaciones de entrada --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- Clases de animación --- */
.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide-left {
    animation: slideInLeft 0.5s ease-out forwards;
}

.animate-slide-right {
    animation: slideInRight 0.5s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.4s ease-out forwards;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-gradient {
    background-size: 200% auto;
    animation: gradient-shift 3s ease infinite;
}

/* --- Retrasos de animación (para stagger) --- */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }

/* --- Elementos que esperan ser animados por IntersectionObserver --- */
.scroll-animate {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-animate.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger para hijos dentro de contenedores observados */
.scroll-animate.visible .stagger-child:nth-child(1) { transition-delay: 0ms; }
.scroll-animate.visible .stagger-child:nth-child(2) { transition-delay: 80ms; }
.scroll-animate.visible .stagger-child:nth-child(3) { transition-delay: 160ms; }
.scroll-animate.visible .stagger-child:nth-child(4) { transition-delay: 240ms; }
.scroll-animate.visible .stagger-child:nth-child(5) { transition-delay: 320ms; }

.stagger-child {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.scroll-animate.visible .stagger-child {
    opacity: 1;
    transform: translateY(0);
}

/* --- Contenedores de AdSense --- */
.adsense-container {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    min-height: 90px;
    transition: opacity 0.3s ease;
}

.adsense-container:hover {
    opacity: 0.8;
}

/* El contenido del placeholder desaparece cuando AdSense carga */
.adsense-container ins {
    display: block;
}

/* --- Texto con gradiente --- */
.text-gradient {
    background: linear-gradient(135deg, #0F6E56, #534AB7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-gradient-animated {
    background: linear-gradient(135deg, #0F6E56, #534AB7, #0F6E56);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 4s ease infinite;
}

/* --- Borde con gradiente --- */
.border-gradient {
    position: relative;
    border: none;
}

.border-gradient::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, #0F6E56, #534AB7);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.border-gradient:hover::before {
    opacity: 1;
}

/* --- Efecto glassmorphism --- */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* --- Patrón de fondo sutil --- */
.bg-grid-pattern {
    background-image:
        linear-gradient(rgba(15, 110, 86, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 110, 86, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
}

/* --- Focus accesible --- */
*:focus-visible {
    outline: 2px solid #0F6E56;
    outline-offset: 2px;
    border-radius: 4px;
}

/* --- Estilos para herramientas --- */
.tool-input {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tool-input:focus {
    border-color: #0F6E56;
    box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.15);
}

/* --- Botón con shimmer --- */
.btn-shimmer {
    position: relative;
    overflow: hidden;
}

.btn-shimmer::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0.15) 50%,
        transparent 100%
    );
    transform: rotate(45deg);
    transition: transform 0.6s ease;
}

.btn-shimmer:hover::after {
    transform: rotate(45deg) translateX(100%);
}

/* --- QR Output --- */
#qr-output canvas,
#qr-output img {
    border-radius: 12px;
    max-width: 100%;
    height: auto;
}

/* --- Responsividad adicional (Mobile-First) --- */

/* Scrollbar más delgado en móvil */
@media (max-width: 640px) {
    ::-webkit-scrollbar {
        width: 4px;
    }

    .adsense-container {
        min-height: 50px;
        border-radius: 8px;
    }

    /* Categorías en 2 columnas: ajustar padding */
    .stagger-child {
        padding: 1rem;
    }

    /* Reducir decorativos en móvil para rendimiento */
    .blur-3xl {
        display: none;
    }
}

/* Tablet intermedio */
@media (min-width: 641px) and (max-width: 1023px) {
    .adsense-container {
        min-height: 70px;
    }
}

/* --- Touch Optimizations --- */
@media (pointer: coarse) {
    /* Touch targets mínimo 44x44px en dispositivos táctiles */
    a, button, [role="button"], input[type="search"], select {
        min-height: 44px;
    }

    /* Eliminar highlight en tap */
    a, button {
        -webkit-tap-highlight-color: transparent;
    }

    /* Scrolling suave con inercia */
    .overflow-y-auto, .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }

    /* Desactivar hover effects en touch */
    .hover\:-translate-y-0\.5:hover,
    .hover\:-translate-y-1:hover {
        transform: none !important;
    }
}

/* --- Orientación landscape en móviles --- */
@media (max-height: 500px) and (orientation: landscape) {
    .pt-8 {
        padding-top: 1rem;
    }
    .pb-12 {
        padding-bottom: 2rem;
    }
}

/* --- Efecto Spotlight para el Hero --- */
section.bg-slate-900::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        800px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(15, 110, 86, 0.06),
        transparent 40%
    );
    z-index: 1;
}

/* Reducción de movimiento para accesibilidad */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }

    .scroll-animate {
        opacity: 1;
        transform: none;
    }

    .stagger-child {
        opacity: 1;
        transform: none;
    }

    .text-gradient-animated {
        animation: none;
    }
}

/* --- Safe area para notch iPhones --- */
@supports (padding: env(safe-area-inset-top)) {
    header {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    footer {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
}

/* --- Modo impresión --- */
@media print {
    .adsense-container,
    .no-print {
        display: none !important;
    }
}
