/* Estilos Globales y Animaciones */

/* ========================================
   FONDO ANIMADO CON GRADIENTE  
   ======================================== */

/* Fondo principal con gradiente animado */
body {
    background: linear-gradient(-45deg, #e3f2fd, #f3e5f5, #e8f5e9, #fff3e0);
    background-size: 400% 400%;
    animation: gradientFlow 15s ease infinite;
    min-height: 100vh;
}

/* Animación suave del gradiente */
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Overlay decorativo con círculos flotantes */
.bg-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.1));
    filter: blur(40px);
    animation: floatCircle 20s ease-in-out infinite;
}

.bg-circle:nth-child(1) {
    width: 300px;
    height: 300px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.bg-circle:nth-child(2) {
    width: 400px;
    height: 400px;
    top: 50%;
    right: 10%;
    animation-delay: 5s;
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.12), rgba(147, 51, 234, 0.08));
}

.bg-circle:nth-child(3) {
    width: 250px;
    height: 250px;
    bottom: 15%;
    left: 30%;
    animation-delay: 10s;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(16, 185, 129, 0.1));
}

@keyframes floatCircle {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(20px, -30px) scale(1.05);
    }

    50% {
        transform: translate(-15px, 25px) scale(0.95);
    }

    75% {
        transform: translate(30px, 15px) scale(1.02);
    }
}

/* ========================================
   FIN FONDO ANIMADO
   ======================================== */

/* Animación de entrada para listas */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.item-card {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Modal Slide Up */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-slide-up {
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.3s ease-out forwards;
}

/* Prevent zoom on double tap on mobile */
button {
    touch-action: manipulation;
}

/* No select text for app-like feel */
.no-select {
    user-select: none;
    -webkit-user-select: none;
}

/* Entradas */
.animate-fade-in {
    animation: fadeIn 0.2s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.2s ease-out forwards;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Salidas */
.animate-fade-out {
    animation: fadeOut 0.2s ease-in forwards;
}

.animate-scale-out {
    animation: scaleOut 0.2s ease-in forwards;
}

.animate-slide-down {
    animation: slideDown 0.2s ease-in forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes scaleOut {
    from {
        transform: scale(1);
        opacity: 1;
    }

    to {
        transform: scale(0.95);
        opacity: 0;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

/* Animación de Fondo (Blobs) */
@keyframes blob {
    0% {
        transform: translate(0px, 0px) scale(1);
    }

    33% {
        transform: translate(30px, -50px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }

    100% {
        transform: translate(0px, 0px) scale(1);
    }
}

.animate-blob {
    animation: blob 7s infinite;
}

.animation-delay-2000 {
    animation-delay: 2s;
}

.animation-delay-4000 {
    animation-delay: 4s;
}

/* Menu Icon Animation */
.menu-icon {
    width: 24px;
    height: 18px;
    position: relative;
    cursor: pointer;
    display: inline-block;
}

.menu-icon span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: #6b7280;
    border-radius: 9px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: .25s ease-in-out;
}

.menu-icon span:nth-child(1) {
    top: 0px;
}

.menu-icon span:nth-child(2) {
    top: 8px;
}

.menu-icon span:nth-child(3) {
    top: 16px;
}

.menu-icon.open span {
    background: #2563eb;
}

.menu-icon.open span:nth-child(1) {
    top: 8px;
    transform: rotate(135deg);
}

.menu-icon.open span:nth-child(2) {
    opacity: 0;
    left: -20px;
}

.menu-icon.open span:nth-child(3) {
    top: 8px;
    transform: rotate(-135deg);
}

/* Advanced Hamburger Animation (CodePen Port) */
.custom-menu-icon {
    width: 64px;
    height: 45px;
    position: relative;
    cursor: pointer;
    transform: scale(0.4);
    transform-origin: center;
    -webkit-tap-highlight-color: transparent;
}

.custom-menu-icon span {
    width: 100%;
    height: 5px;
    background-color: #6b7280;
    display: block;
    position: absolute;
    border-radius: 2px;
    transition: all .5s ease;
}

.custom-menu-icon span:nth-child(1) {
    top: 0px;
    left: 0px;
}

.custom-menu-icon span:nth-child(2) {
    top: 20px;
    right: 0px;
}

.custom-menu-icon span:nth-child(3) {
    top: 40px;
    left: 0px;
}

.custom-menu-icon.open span {
    background-color: #2563eb;
}

.custom-menu-icon.open span:nth-child(2) {
    animation: span2 1.5s forwards cubic-bezier(.8, .5, .2, 1.4);
}

@keyframes span2 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    20% {
        width: 5px;
        border-radius: 50%;
        transform: translate(0, 0) scale(1);
    }

    40% {
        width: 5px;
        border-radius: 50%;
        transform: translate(0, 0) scale(1);
    }

    50% {
        width: 5px;
        border-radius: 50%;
        transform: translate(0, 18px) scale(1);
    }

    80% {
        width: 5px;
        border-radius: 50%;
        transform: translate(0, -16px) scale(1);
    }

    100% {
        width: 5px;
        border-radius: 50%;
        transform: translate(0, 100px) scale(0);
    }
}

.custom-menu-icon.open span:nth-child(3) {
    animation: span3 .8s forwards cubic-bezier(.8, .5, .2, 1.4);
    animation-delay: .7s;
}

@keyframes span3 {
    0% {
        transform: translate(0, 0);
    }

    60% {
        transform: rotate(80deg) translate(-7px, -7px);
    }

    100% {
        transform: rotate(45deg) translate(-7px, -7px);
    }
}

.custom-menu-icon.open span:nth-child(1) {
    animation: span1 .8s forwards cubic-bezier(.8, .5, .2, 1.4);
    animation-delay: 1.1s;
}

@keyframes span1 {
    0% {
        transform: translate(0, 0);
    }

    60% {
        transform: rotate(-110deg) translate(-7px, -7px);
    }

    100% {
        transform: rotate(-45deg) translate(-20px, 20px);
    }
}

.custom-menu-icon span:nth-child(1) {
    animation: span1_close .8s forwards cubic-bezier(.8, .5, .2, 1.4);
}

@keyframes span1_close {
    0% {
        transform: rotate(-45deg) translate(-20px, 20px);
    }

    100% {
        transform: rotate(0deg) translate(0, 0);
    }
}

.custom-menu-icon span:nth-child(2) {
    animation: span2_close .8s forwards cubic-bezier(.8, .5, .2, 1.4);
}

@keyframes span2_close {
    0% {
        transform: translate(0, 40px) scale(0);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

.custom-menu-icon span:nth-child(3) {
    animation: span3_close .8s forwards cubic-bezier(.8, .5, .2, 1.4);
}

@keyframes span3_close {
    0% {
        transform: rotate(45deg) translate(-7px, -7px);
    }

    100% {
        transform: rotate(0deg) translate(0, 0);
    }
}

/* Shimmer Animation for Cards */
@keyframes shimmer {
    100% {
        transform: translateX(200%);
    }
}

.animate-shimmer {
    animation: shimmer 1s infinite alternate;
    /* O infinite? mejor solo hover once triggers transition usually */
    animation: shimmer 1.5s infinite;
}

/* Professional Animated Border */
/* Professional Animated Border */
.border-glow-card {
    position: relative;
    border: 1px solid rgba(226, 232, 240, 0.8);
    /* Slate-200 equivalent fallback */
    background: rgba(255, 255, 255, 0.95);
    z-index: 0;
    overflow: hidden;
    /* Contain the beams */
}

/* The Rotating Beam */
.border-glow-card::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg,
            transparent 0deg,
            transparent 80deg,
            #2563eb 180deg,
            /* Primary Blue */
            transparent 180deg,
            transparent 260deg,
            #f59e0b 360deg
            /* Accent Gold */
        );
    animation: rotateBorder 4s linear infinite;
    z-index: -2;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.3s ease;
}

/* Show ONLY on hover */
.border-glow-card:hover::before {
    opacity: 1;
}

/* Inner Background to mask the center (keep content readable) */
.border-glow-card::after {
    content: "";
    position: absolute;
    inset: 1px;
    /* The border width */
    background: rgba(255, 255, 255, 0.98);
    /* High opacity white */
    border-radius: inherit;
    z-index: -1;
}

@keyframes rotateBorder {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   MODERN TAB NAVIGATION STYLES
   ======================================== */

/* Container principal de tabs */
.tabs-container {
    position: relative;
    display: flex;
    padding: 4px;
    gap: 4px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: inset 0 2px 4px rgba(148, 163, 184, 0.1);
    overflow: hidden;
}

/* Indicador deslizante animado */
.tabs-container::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 6px);
    height: calc(100% - 8px);
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 12px;
    box-shadow:
        0 4px 12px rgba(15, 23, 42, 0.08),
        0 2px 4px rgba(15, 23, 42, 0.04),
        inset 0 -1px 2px rgba(148, 163, 184, 0.1);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
    pointer-events: none;
}

/* Animar el indicador según el tab activo */
.tabs-container[data-active="historial"]::before {
    transform: translateX(calc(100% + 4px));
}

/* Botones de tab base */
.tab-button {
    flex: 1;
    position: relative;
    z-index: 2;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-align: center;
    color: #64748b;
    background: transparent;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Estado hover (solo para tabs inactivos) */
.tab-button:not(.active):hover {
    color: #475569;
    transform: translateY(-1px);
}

/* Estado activo */
.tab-button.active {
    color: #1e293b;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

/* Animación de entrada del texto */
.tab-button span {
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-button.active span {
    transform: scale(1.02);
}

/* Efecto de presión */
.tab-button:active {
    transform: scale(0.98);
}

/* Responsive - Mobile */
@media (max-width: 640px) {
    .tabs-container {
        padding: 3px;
        gap: 3px;
        border-radius: 14px;
    }

    .tabs-container::before {
        top: 3px;
        left: 3px;
        width: calc(50% - 4.5px);
        height: calc(100% - 6px);
        border-radius: 11px;
    }

    .tabs-container[data-active="historial"]::before {
        transform: translateX(calc(100% + 3px));
    }

    .tab-button {
        padding: 10px 16px;
        font-size: 12px;
        border-radius: 11px;
    }
}

/* Responsive - Desktop Large */
@media (min-width: 1024px) {
    .tabs-container {
        max-width: 500px;
        margin: 0 auto;
    }

    .tab-button {
        padding: 14px 24px;
        font-size: 14px;
    }

    .tab-button:hover {
        background: rgba(255, 255, 255, 0.5);
    }
}

/* Animación de carga inicial */
@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tabs-container {
    animation: tabFadeIn 0.5s ease-out;
}

/* Accesibilidad - Focus visible para teclado */
.tab-button:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Variante con icono (opcional para futuro) */
.tab-button-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tab-button-icon svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.tab-button.active .tab-button-icon svg {
    transform: rotate(5deg) scale(1.1);
}

/* ========================================
   LOADING SCREEN STYLES
   ======================================== */

/* Contenedor principal de la pantalla de carga */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    backdrop-filter: blur(10px);
    animation: loadingFadeIn 0.4s ease-out;
}

/* Animación de entrada de la pantalla de carga */
@keyframes loadingFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Animación de salida de la pantalla de carga */
@keyframes loadingFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.loading-screen.fade-out {
    animation: loadingFadeOut 0.5s ease-out forwards;
}

/* Contenedor del contenido de carga */
.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: contentSlideUp 0.6s ease-out 0.2s backwards;
}

@keyframes contentSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Logo/Icono animado */
.loading-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 10px 40px rgba(15, 23, 42, 0.1),
        0 4px 12px rgba(15, 23, 42, 0.05),
        inset 0 -2px 4px rgba(148, 163, 184, 0.1);
    animation: logoPulse 2s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

/* Animación de pulso del logo */
@keyframes logoPulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow:
            0 10px 40px rgba(15, 23, 42, 0.1),
            0 4px 12px rgba(15, 23, 42, 0.05);
    }

    50% {
        transform: scale(1.05);
        box-shadow:
            0 15px 50px rgba(15, 23, 42, 0.15),
            0 6px 16px rgba(15, 23, 42, 0.08);
    }
}

/* Brillo animado dentro del logo */
.loading-logo::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
            transparent 30%,
            rgba(255, 255, 255, 0.3) 50%,
            transparent 70%);
    animation: logoShine 3s ease-in-out infinite;
}

@keyframes logoShine {

    0%,
    100% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }

    50% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}

/* Icono dentro del logo */
.loading-logo-icon {
    width: 40px;
    height: 40px;
    color: #64748b;
    animation: iconRotate 2s linear infinite;
    position: relative;
    z-index: 1;
}

@keyframes iconRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Spinner moderno (anillos concéntricos) */
.loading-spinner {
    width: 120px;
    height: 120px;
    position: relative;
}

.spinner-ring {
    position: absolute;
    border: 3px solid transparent;
    border-radius: 50%;
    animation: spinRotate 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.spinner-ring:nth-child(1) {
    width: 120px;
    height: 120px;
    border-top-color: #64748b;
    border-right-color: #64748b;
    animation-delay: 0s;
}

.spinner-ring:nth-child(2) {
    width: 100px;
    height: 100px;
    top: 10px;
    left: 10px;
    border-top-color: #94a3b8;
    border-right-color: #94a3b8;
    animation-delay: -0.4s;
}

.spinner-ring:nth-child(3) {
    width: 80px;
    height: 80px;
    top: 20px;
    left: 20px;
    border-top-color: #cbd5e1;
    border-right-color: #cbd5e1;
    animation-delay: -0.8s;
}

@keyframes spinRotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Texto de carga */
.loading-text {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: 0.02em;
    animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Puntos animados */
.loading-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 4px;
}

.loading-dot {
    width: 6px;
    height: 6px;
    background: #64748b;
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) {
    animation-delay: 0s;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Subtexto descriptivo */
.loading-subtext {
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    letter-spacing: 0.01em;
    animation: subtextFadeIn 0.6s ease-out 0.4s backwards;
}

@keyframes subtextFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Barra de progreso (opcional) */
.loading-progress {
    width: 240px;
    height: 4px;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 2px;
    overflow: hidden;
    animation: progressFadeIn 0.6s ease-out 0.6s backwards;
}

@keyframes progressFadeIn {
    from {
        opacity: 0;
        width: 0;
    }

    to {
        opacity: 1;
        width: 240px;
    }
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #64748b 0%, #94a3b8 100%);
    border-radius: 2px;
    animation: progressSlide 1.5s ease-in-out infinite;
    transform-origin: left;
}

@keyframes progressSlide {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(400%);
    }
}

/* Responsive - Mobile */
@media (max-width: 640px) {
    .loading-logo {
        width: 64px;
        height: 64px;
        border-radius: 20px;
    }

    .loading-logo-icon {
        width: 32px;
        height: 32px;
    }

    .loading-spinner {
        width: 100px;
        height: 100px;
    }

    .spinner-ring:nth-child(1) {
        width: 100px;
        height: 100px;
    }

    .spinner-ring:nth-child(2) {
        width: 80px;
        height: 80px;
        top: 10px;
        left: 10px;
    }

    .spinner-ring:nth-child(3) {
        width: 60px;
        height: 60px;
        top: 20px;
        left: 20px;
    }

    .loading-text {
        font-size: 16px;
    }

    .loading-subtext {
        font-size: 13px;
    }

    .loading-progress {
        width: 200px;
    }
}