/**
 * Sistema de Feedback Visual
 * Estilos para notificaciones, animaciones y estados de carga
 */

/* ===========================================
   VARIABLES CSS
   =========================================== */
:root {
    --toast-success: #10b981;
    --toast-error: #ef4444;
    --toast-warning: #f59e0b;
    --toast-info: #3b82f6;
    --transition-fast: 150ms;
    --transition-normal: 300ms;
    --transition-slow: 500ms;
}

/* ===========================================
   TOAST NOTIFICATIONS
   =========================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    background: white;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 450px;
    pointer-events: auto;
    animation: toastSlideIn var(--transition-normal) ease-out;
    border-left: 4px solid;
}

.toast.toast-success {
    border-left-color: var(--toast-success);
}

.toast.toast-error {
    border-left-color: var(--toast-error);
}

.toast.toast-warning {
    border-left-color: var(--toast-warning);
}

.toast.toast-info {
    border-left-color: var(--toast-info);
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
    color: #1f2937;
}

.toast-message {
    font-size: 14px;
    color: #6b7280;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: #374151;
}

.toast.toast-hiding {
    animation: toastSlideOut var(--transition-normal) ease-in forwards;
}

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

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

/* ===========================================
   LOADING SPINNER
   =========================================== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.spinner-dark {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: #374151;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

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

/* ===========================================
   BUTTON LOADING STATES
   =========================================== */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.btn-loading.btn-outline-primary::after,
.btn-loading.btn-outline-secondary::after,
.btn-loading.btn-light::after {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: #374151;
}

/* ===========================================
   SKELETON LOADERS
   =========================================== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ===========================================
   FADE ANIMATIONS
   =========================================== */
.fade-in {
    animation: fadeIn var(--transition-normal) ease-out;
}

.fade-out {
    animation: fadeOut var(--transition-normal) ease-in forwards;
}

.fade-in-up {
    animation: fadeInUp var(--transition-normal) ease-out;
}

.fade-in-down {
    animation: fadeInDown var(--transition-normal) ease-out;
}

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

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

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

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

/* ===========================================
   SCALE ANIMATIONS
   =========================================== */
.scale-in {
    animation: scaleIn var(--transition-normal) ease-out;
}

.pulse {
    animation: pulse 2s infinite;
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ===========================================
   HOVER EFFECTS
   =========================================== */
.hover-lift {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hover-scale {
    transition: transform var(--transition-fast);
}

.hover-scale:hover {
    transform: scale(1.02);
}

.hover-glow {
    transition: box-shadow var(--transition-fast);
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(13, 110, 253, 0.4);
}

/* ===========================================
   STATUS BADGES WITH ANIMATION
   =========================================== */
.badge-animated {
    transition: all var(--transition-fast);
}

.badge-animated:hover {
    transform: scale(1.05);
}

.badge-pulse {
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(13, 110, 253, 0);
    }
}

/* ===========================================
   FORM FIELD VALIDATION
   =========================================== */
.form-control.is-validating {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3e%3ccircle cx='12' cy='12' r='10'%3e%3c/circle%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    animation: fieldSpin 1s linear infinite;
}

@keyframes fieldSpin {
    to {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' style='transform:rotate(360deg)'%3e%3ccircle cx='12' cy='12' r='10'%3e%3c/circle%3e%3c/svg%3e");
    }
}

.form-control.is-valid {
    animation: validPop var(--transition-fast) ease-out;
}

.form-control.is-invalid {
    animation: shake var(--transition-normal) ease-out;
}

@keyframes validPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* ===========================================
   TABLE ROW ANIMATIONS
   =========================================== */
.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.table-row-new {
    animation: highlightNew 2s ease-out;
}

.table-row-updated {
    animation: highlightUpdate 1s ease-out;
}

.table-row-deleted {
    animation: fadeOutRow 0.5s ease-out forwards;
}

@keyframes highlightNew {
    0% {
        background-color: rgba(16, 185, 129, 0.3);
    }
    100% {
        background-color: transparent;
    }
}

@keyframes highlightUpdate {
    0% {
        background-color: rgba(59, 130, 246, 0.3);
    }
    100% {
        background-color: transparent;
    }
}

@keyframes fadeOutRow {
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* ===========================================
   PROGRESS BAR
   =========================================== */
.progress-animated .progress-bar {
    animation: progressGrow 1s ease-out;
}

@keyframes progressGrow {
    from {
        width: 0;
    }
}

/* ===========================================
   CARD ANIMATIONS
   =========================================== */
.card {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* ===========================================
   MODAL ANIMATIONS
   =========================================== */
.modal.fade .modal-dialog {
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.modal.fade:not(.show) .modal-dialog {
    transform: scale(0.95) translateY(-20px);
    opacity: 0;
}

/* ===========================================
   RIPPLE EFFECT
   =========================================== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
    width: 200%;
    height: 200%;
}

/* ===========================================
   FLOATING LABELS ANIMATION
   =========================================== */
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    transition: all var(--transition-fast) ease-out;
}

/* ===========================================
   SUCCESS/ERROR ICONS ANIMATION
   =========================================== */
.icon-success {
    color: var(--toast-success);
    animation: iconPop 0.5s ease-out;
}

.icon-error {
    color: var(--toast-error);
    animation: iconShake 0.5s ease-out;
}

@keyframes iconPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes iconShake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* ===========================================
   COUNTER ANIMATION
   =========================================== */
.counter-animated {
    animation: counterPop 0.3s ease-out;
}

@keyframes counterPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
