/* ========================================
   Pivot AI - Estilos con Animaciones
   ======================================== */

/* Variables */
:root {
    --brand-50: #EFF6FF;
    --brand-100: #DBEAFE;
    --brand-200: #BFDBFE;
    --brand-600: #2563EB;
    --brand-700: #1D4ED8;
    --accent: #06B6D4;
    --slate-50: #F8FAFC;
    --slate-100: #F1F5F9;
    --slate-200: #E2E8F0;
    --slate-600: #475569;
    --slate-900: #0F172A;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--slate-900);
    line-height: 1.6;
}

/* ========================================
   Fondo Ambiental con Partículas - Toda la página
   ======================================== */
#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.8;
}

/* Gradientes ambientales animados - en toda la página */
.ambient-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.ambient-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.ambient-gradient {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    animation: floatGradient 25s ease-in-out infinite;
}

.gradient-1 {
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.4), rgba(37, 99, 235, 0.1));
    animation-delay: 0s;
}

.gradient-2 {
    top: 40%;
    right: -15%;
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.35), rgba(6, 182, 212, 0.08));
    animation-delay: -12s;
}

.gradient-3 {
    bottom: -10%;
    left: 20%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.25), rgba(6, 182, 212, 0.1));
    animation-delay: -6s;
}

@keyframes floatGradient {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(30px, -30px) scale(1.1);
    }
    50% {
        transform: translate(-20px, 20px) scale(0.9);
    }
    75% {
        transform: translate(-30px, -20px) scale(1.05);
    }
}

/* ========================================
   Navegación
   ======================================== */
nav {
    transition: all 0.3s ease;
}

nav:hover {
    background: white;
}

/* ========================================
   Hero con Animación Tipográfica
   ======================================== */
#hero {
    position: relative;
    overflow: hidden;
}

#hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -20%;
    width: 60%;
    height: 100%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

#hero::after {
    content: '';
    position: absolute;
    bottom: -30%;
    right: -10%;
    width: 40%;
    height: 60%;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

/* Texto typing动画 */
.typing-text {
    display: inline-block;
    border-right: 3px solid var(--brand-600);
    padding-right: 5px;
    animation: blink 0.8s step-end infinite;
    white-space: nowrap;
    overflow: hidden;
}

@keyframes blink {
    0%, 100% { border-color: var(--brand-600); }
    50% { border-color: transparent; }
}

/* Elementos flotantes */
.animate-float {
    animation: float 6s ease-in-out infinite;
}

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

/* ========================================
   Animaciones Scroll Reveal
   ======================================== */
.scroll-reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Stagger animation for children */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-children.visible > * {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.6s ease;
}

/* ========================================
   Procesos - Barras de Progreso
   ======================================== */
.process-item {
    transition: all 0.4s ease;
}

.process-item:hover {
    transform: translateX(10px);
}

/* ========================================
   Botones CTA con Microinteracción
   ======================================== */
.cta-button {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.cta-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.cta-button:hover::before {
    left: 100%;
}

/* ========================================
   Hover Effects para Tarjetas
   ======================================== */
.service-card {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.service-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(37, 99, 235, 0.15);
}

/* ========================================
   Juego CRM
   ======================================== */
#crm-game-container {
    transition: all 0.3s ease;
}

.game-btn {
    cursor: pointer;
    transition: all 0.2s ease;
}

.game-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.game-btn:active {
    transform: scale(0.98);
}

/* ========================================
   Línea de Tiempo Animada
   ======================================== */
.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--brand-600), var(--accent));
    transform: translateX(-50%);
}

.timeline-item {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

.timeline-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Section spacing
   ======================================== */
section {
    scroll-margin-top: 80px;
    position: relative;
    z-index: 1;
}

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

::-webkit-scrollbar-track {
    background: var(--slate-50);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--brand-400), var(--accent));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(var(--brand-600), var(--accent));
}

/* ========================================
   Animaciones de Entrada
   ======================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.animate-fade-in {
    animation: fadeInUp 0.6s ease forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease forwards;
}

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

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    section {
        padding-top: 4rem;
        padding-bottom: 4rem;
    }
    
    .gradient-1, .gradient-2 {
        width: 200px;
        height: 200px;
    }
}

/* ========================================
   Optimizaciones de Rendimiento
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   Demo CRM - Chat Interactivo
   ======================================== */
#crm-demo-container {
    transition: all 0.3s ease;
}

/* Lista de Leads */
.lead-item {
    transition: all 0.2s ease;
}

.lead-item:hover {
    background: rgba(255, 255, 255, 0.5);
}

.lead-item.active {
    background: white;
    border-left: 3px solid var(--brand-600);
}

/* Chat Messages */
#chat-messages {
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1d5db' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

#chat-messages .flex {
    animation: messageSlideIn 0.3s ease;
}

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

/* Input */
#message-input:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Botón enviar */
button svg {
    transition: transform 0.2s ease;
}

button:hover svg {
    transform: translateX(2px);
}

/* ========================================
   Responsive CRM Demo
   ======================================== */
@media (max-width: 1024px) {
    #crm-demo-container .flex-col {
        height: auto;
    }
    
    #crm-demo-container .lg\:w-80 {
        width: 100%;
        max-height: 300px;
    }
}

@media (max-width: 768px) {
    #crm-demo-container {
        margin: 0 -1rem;
        border-radius: 0;
    }
}

/* ========================================
   Utilidades
   ======================================== */
.gradient-text {
    background: linear-gradient(135deg, var(--brand-600), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-effect {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}
