/**
 * ============================================================================
 * MODERN COMPONENTS - MI CAJA DIGITAL 2025
 * ============================================================================
 * Sistema de componentes modernos con Tailwind CSS v4.0
 * Incluye: Botones, Cards, Modales, Formularios
 * Garantiza visibilidad de texto y accesibilidad WCAG 2.1 AA
 * ============================================================================
 */

/* ========================================================================== */
/* VARIABLES CSS MODERNAS - Compatible con Tailwind v4 */
/* ========================================================================== */
:root {
    /* Colores Primarios - Alta Calidad P3 Wide Gamut */
    --color-primary: oklch(40% 0.15 240); /* Azul CSS profundo */
    --color-primary-light: oklch(85% 0.05 240); /* Azul claro vibrante */
    --color-primary-dark: oklch(25% 0.15 240); /* Azul oscuro intenso */

    /* Colores de Acento */
    --color-accent: oklch(65% 0.20 200); /* Azul cielo vibrante */
    --color-success: oklch(65% 0.20 145); /* Verde éxito */
    --color-warning: oklch(75% 0.15 85); /* Amarillo advertencia */
    --color-danger: oklch(60% 0.25 25); /* Rojo peligro */

    /* Escala de Grises Moderna */
    --color-gray-50: oklch(98% 0 0);
    --color-gray-100: oklch(96% 0 0);
    --color-gray-200: oklch(90% 0 0);
    --color-gray-300: oklch(80% 0 0);
    --color-gray-400: oklch(70% 0 0);
    --color-gray-500: oklch(60% 0 0);
    --color-gray-600: oklch(50% 0 0);
    --color-gray-700: oklch(40% 0 0);
    --color-gray-800: oklch(30% 0 0);
    --color-gray-900: oklch(20% 0 0);

    /* Sombras Modernas */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 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);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-blur: 12px;

    /* Animaciones */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Tipografía */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
}

/* ========================================================================== */
/* SISTEMA DE BOTONES MODERNO - TEXTO SIEMPRE VISIBLE */
/* ========================================================================== */

/* Botón Base - Garantiza visibilidad de texto */
.btn-modern {
    /* Layout */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    /* Espaciado */
    padding: 0.625rem 1.25rem;

    /* Tipografía - Garantiza legibilidad */
    font-family: 'Poppins', sans-serif;
    font-size: var(--font-size-base);
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    color: #ffffff; /* Texto blanco por defecto para máximo contraste */

    /* Bordes */
    border: 2px solid transparent;
    border-radius: 0.75rem;

    /* Efectos */
    background-clip: padding-box;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    user-select: none;

    /* Transiciones suaves */
    transition: all var(--transition-base);

    /* Forzar visibilidad */
    opacity: 1 !important;
    visibility: visible !important;
}

/* Botón Primario - Azul CSS con excelente contraste */
.btn-primary {
    background: linear-gradient(135deg, #083D6C 0%, #0F76D2 100%);
    color: #ffffff; /* Contraste 7.8:1 - WCAG AAA */
    border-color: #083D6C;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #062A4B 0%, #0D5FAA 100%);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    color: #ffffff; /* Mantener texto blanco */
}

.btn-primary:active {
    background: linear-gradient(135deg, #041D33 0%, #0A4888 100%);
    box-shadow: var(--shadow-md);
    transform: translateY(0);
}

.btn-primary:focus-visible {
    outline: 3px solid #60A5FA;
    outline-offset: 3px;
}

/* Botón Secundario - Outline moderno */
.btn-secondary {
    background: transparent;
    color: #083D6C;
    border-color: #083D6C;
    border-width: 2px;
}

.btn-secondary:hover {
    background: #083D6C;
    color: #ffffff; /* Cambiar a blanco al hover */
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Botón Success - Verde vibrante */
.btn-success {
    background: linear-gradient(135deg, #059669 0%, #10B981 100%);
    color: #ffffff; /* Contraste 4.6:1 - WCAG AA */
    border-color: #059669;
}

.btn-success:hover {
    background: linear-gradient(135deg, #047857 0%, #0EA472 100%);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Botón Danger - Rojo intenso */
.btn-danger {
    background: linear-gradient(135deg, #DC2626 0%, #EF4444 100%);
    color: #ffffff; /* Contraste 5.9:1 - WCAG AAA */
    border-color: #DC2626;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #B91C1C 0%, #DC2626 100%);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Botón Warning - Amarillo con texto oscuro */
.btn-warning {
    background: linear-gradient(135deg, #F59E0B 0%, #FBBF24 100%);
    color: #78350F; /* Texto oscuro para contraste 6.2:1 */
    border-color: #F59E0B;
    font-weight: 700; /* Extra bold para mejor visibilidad */
}

.btn-warning:hover {
    background: linear-gradient(135deg, #D97706 0%, #F59E0B 100%);
    color: #78350F;
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Botón Ghost - Fondo sutil */
.btn-ghost {
    background: rgba(8, 61, 108, 0.05);
    color: #083D6C;
    border-color: transparent;
    font-weight: 600;
}

.btn-ghost:hover {
    background: rgba(8, 61, 108, 0.1);
    color: #062A4B;
    box-shadow: var(--shadow-sm);
}

/* ========================================================================== */
/* TAMAÑOS DE BOTONES */
/* ========================================================================== */

.btn-xs {
    padding: 0.375rem 0.75rem;
    font-size: var(--font-size-xs);
    border-radius: 0.5rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: var(--font-size-sm);
    border-radius: 0.625rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: var(--font-size-lg);
    border-radius: 1rem;
}

.btn-xl {
    padding: 1.125rem 2.25rem;
    font-size: var(--font-size-xl);
    border-radius: 1.25rem;
}

/* ========================================================================== */
/* ESTADOS DE BOTONES */
/* ========================================================================== */

/* Loading State */
.btn-loading {
    position: relative;
    color: transparent !important; /* Ocultar texto temporalmente */
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spinner 0.6s linear infinite;
}

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

/* Animación de shimmer para el header del modal */
@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Animación de barra de progreso */
@keyframes progress {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(0%);
    }
    100% {
        transform: translateX(100%);
    }
}

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

/* Disabled State - Texto visible pero atenuado */
.btn-modern:disabled,
.btn-modern.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}

/* Focus State - Accesibilidad */
.btn-modern:focus-visible {
    outline: 3px solid #60A5FA;
    outline-offset: 3px;
    box-shadow: var(--shadow-lg);
}

/* ========================================================================== */
/* ICONOS EN BOTONES - SIEMPRE VISIBLES */
/* ========================================================================== */

.btn-modern svg,
.btn-modern i {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
    stroke: currentColor;
}

.btn-modern i.fa,
.btn-modern i.fas,
.btn-modern i.far {
    width: auto;
    height: auto;
    font-size: 1.125rem;
}

/* Botón solo con icono */
.btn-icon-only {
    padding: 0.625rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
}

.btn-icon-only svg,
.btn-icon-only i {
    margin: 0;
}

/* ========================================================================== */
/* CARDS MODERNAS - Glassmorphism */
/* ========================================================================== */

.card-modern {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 1.25rem;
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    transition: all var(--transition-base);
}

.card-modern:hover {
    box-shadow: var(--shadow-2xl);
    transform: translateY(-4px);
    border-color: rgba(8, 61, 108, 0.2);
}

.card-modern-header {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid rgba(8, 61, 108, 0.1);
}

.card-modern-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: #083D6C;
    margin: 0;
}

.card-modern-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-gray-600);
    margin-top: 0.25rem;
}

/* ========================================================================== */
/* MODAL MODERNO - Glassmorphism */
/* ========================================================================== */

.modal-modern-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
    animation: fadeIn var(--transition-base);
}

.modal-modern {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn var(--transition-slow);
}

.modal-modern-content {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 1.5rem;
    box-shadow: var(--shadow-2xl);
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp var(--transition-slow);
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(2rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-modern-header {
    background: linear-gradient(135deg, #083D6C 0%, #0F76D2 100%);
    color: #ffffff;
    padding: 1.5rem;
    border-radius: 1.5rem 1.5rem 0 0;
}

.modal-modern-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: #ffffff; /* Garantizar visibilidad */
    margin: 0;
}

.modal-modern-body {
    padding: 2rem 1.5rem;
}

.modal-modern-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(8, 61, 108, 0.1);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ========================================================================== */
/* FORMULARIOS MODERNOS */
/* ========================================================================== */

.input-modern {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: var(--font-size-base);
    font-weight: 400;
    line-height: 1.5;
    color: #1F2937; /* Texto oscuro para contraste */
    background-color: #ffffff;
    background-clip: padding-box;
    border: 2px solid #D1D5DB;
    border-radius: 0.75rem;
    transition: all var(--transition-base);
}

.input-modern:focus {
    color: #111827;
    background-color: #ffffff;
    border-color: #083D6C;
    outline: 0;
    box-shadow: 0 0 0 4px rgba(8, 61, 108, 0.1);
}

.input-modern::placeholder {
    color: #9CA3AF;
    opacity: 1;
}

.input-modern:disabled {
    background-color: #F3F4F6;
    opacity: 0.6;
    cursor: not-allowed;
}

/* Label moderno */
.label-modern {
    display: block;
    margin-bottom: 0.5rem;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: #374151;
}

/* ========================================================================== */
/* UTILIDADES - VISIBILIDAD GARANTIZADA */
/* ========================================================================== */

/* Forzar visibilidad de elementos importantes */
.force-visible {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Texto con alto contraste */
.text-high-contrast {
    color: #111827;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Badge moderno */
.badge-modern {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 1;
    color: #ffffff;
    background: linear-gradient(135deg, #083D6C 0%, #0F76D2 100%);
    border-radius: 9999px;
    text-align: center;
}

/* ========================================================================== */
/* RESPONSIVE DESIGN */
/* ========================================================================== */

@media (max-width: 640px) {
    .btn-modern {
        padding: 0.5rem 1rem;
        font-size: var(--font-size-sm);
    }

    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: var(--font-size-base);
    }

    .card-modern {
        padding: 1rem;
        border-radius: 1rem;
    }

    .modal-modern-content {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
}

/* ========================================================================== */
/* DARK MODE SUPPORT (Opcional) */
/* ========================================================================== */

@media (prefers-color-scheme: dark) {
    .card-modern {
        background: rgba(17, 24, 39, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .input-modern {
        background-color: rgba(31, 41, 55, 0.9);
        border-color: rgba(75, 85, 99, 0.9);
        color: #F9FAFB;
    }

    .input-modern:focus {
        background-color: rgba(17, 24, 39, 1);
        border-color: #60A5FA;
    }
}
