/**
 * SGS DESIGN SYSTEM - CORE COMPONENTS (MODULAR)
 * Contiene componentes compartidos y animaciones base.
 */

/* =============================================================================
   ANIMACIONES Y KEYFRAMES
   ============================================================================= */

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

.sgs-fade-in {
    animation: sgsFadeIn 0.4s ease-out forwards;
}

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

@keyframes highlight {
    0% { background: var(--sgs-success); }
    100% { background: none; }
}

@keyframes red_highlight {
    0% { background: var(--sgs-error); }
    100% { background: none; }
}

@keyframes bounceIn {
    0% { transform: scale(0.7); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.animate { animation: animatezoom 0.6s; }
.highlight { animation: highlight 2s; }
.red_highlight { animation: red_highlight 3s; }

/* Animación Shimmer para Skeletons */
@keyframes shimmer {
    0% { background-position: -468px 0; }
    100% { background-position: 468px 0; }
}

.sgs-skeleton {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 104px;
    display: inline-block;
    position: relative;
    animation: shimmer 1.2s linear infinite forwards;
    border-radius: 4px;
}

.sgs-skeleton-text { height: 15px; width: 100%; margin-bottom: 10px; }
.sgs-skeleton-title { height: 30px; width: 60%; margin-bottom: 20px; }
.sgs-skeleton-rect { height: 200px; width: 100%; }

/* Notificaciones Toast */
.sgs-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--sgs-text-main);
    color: white;
    padding: 12px 24px;
    border-radius: var(--sgs-radius-sm);
    box-shadow: var(--sgs-shadow-md);
    z-index: 10000000;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease-out;
}

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

/* =============================================================================
   COMPONENTES DE UI: MODALES
   ============================================================================= */

.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto !important;
    background-color: rgba(0,0,0,0.4);
    padding-top: 20px;
}

.modal-content {
    background-color: whitesmoke !important;
    margin: 5% auto 15% auto;
    border: 1px solid #888;
    width: fit-content;
    border-radius: 30px !important;
}

.sgs-modal-close, .close {
    position: absolute;
    right: 15px;
    top: 10px;
    color: #000;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    border: none;
    background: transparent;
    padding: 0;
    outline: none;
}

.sgs-modal-close:hover, .close:hover,
.sgs-modal-close:focus, .close:focus { 
    color: var(--sgs-error); 
    text-decoration: none;
    outline: none;
    border: none;
    background: transparent;
}

/* Modal Premium (Inactividad) */
.modal_premium {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: var(--z-premium);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal_premium_content {
    background: white;
    padding: 35px;
    border-radius: var(--sgs-radius-md);
    text-align: center;
    box-shadow: var(--sgs-shadow-md);
    max-width: 400px;
    width: 90%;
    border-top: 5px solid #d9534f;
    animation: bounceIn 0.4s ease-out;
}

/* =============================================================================
   COMPONENTES DE UI: SWITCHES Y OTROS
   ============================================================================= */

.switch {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 17px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 13px; width: 13px;
    left: 2px; bottom: 2px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider { background-color: #2196F3; }
input:checked + .slider:before { transform: translateX(13px); }

.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

.spin {
    width: 100px;
    position: fixed;
    top: 50%; left: 50%;
    margin-top: -50px; margin-left: -50px;
}

/* =============================================================================
   LAYOUT GLOBAL: CONTENEDOR DINÁMICO
   ============================================================================= */

#dinamico {
    margin: 0 auto;
    padding: 20px;
    transition: max-width 0.3s ease;
}

/* Desktop: Limitar ancho para legibilidad */
@media (min-width: 992px) {
    #dinamico {
        max-width: 95%;
    }
}

/* Mobile: Ocupar todo el espacio y mejorar usabilidad */
@media (max-width: 768px) {
    #dinamico {
        max-width: 100%;
        padding: 10px 5px;
    }

    /* Evitar zoom automático en iOS al enfocar inputs */
    .form-control, input, select, textarea {
        font-size: 16px !important;
    }

    /* Botones más fáciles de tocar */
    .btn {
        min-height: 40px;
    }

    /* Centrar encabezados en móvil */
    h1, .h3, h4 {
        text-align: center;
        width: 100%;
    }
}
