/**
 * SISMADLMPA - Animaciones y Efectos Visuales
 * Módulo: Consumir Lotes de Madeira
 */

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

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

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(-10px);
    }
}

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

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

/* Apply animations */
.stat-card {
    animation: fadeIn 0.6s ease-out;
}

.stat-card:nth-child(1) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.3s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.4s;
}

.form-card {
    animation: fadeIn 0.8s ease-out;
}

.table-modern tbody tr {
    animation: fadeIn 0.4s ease-out;
}

/* Button hover effects */
.btn-modern {
    position: relative;
    overflow: hidden;
}

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

.btn-modern:active::before {
    width: 300px;
    height: 300px;
}

/* Loading skeleton */
.skeleton {
    background: #f6f7f8;
    background-image: linear-gradient(
        to right,
        #f6f7f8 0%,
        #edeef1 20%,
        #f6f7f8 40%,
        #f6f7f8 100%
    );
    background-repeat: no-repeat;
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
}

.skeleton-text {
    height: 16px;
    margin: 8px 0;
    border-radius: 4px;
}

.skeleton-title {
    height: 24px;
    margin: 12px 0;
    border-radius: 4px;
    width: 60%;
}

.skeleton-card {
    height: 100px;
    border-radius: 12px;
    margin-bottom: 20px;
}

/* Progress bar animation */
.progress-custom .progress-bar {
    position: relative;
    overflow: hidden;
}

.progress-custom .progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
    );
    background-size: 20px 20px;
    animation: moveStripes 1s linear infinite;
}

@keyframes moveStripes {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 20px 20px;
    }
}

/* Toast animations */
.toast-modern {
    animation: slideInRight 0.4s ease-out;
}

.toast-modern.hide {
    animation: slideInRight 0.4s ease-out reverse;
}

/* Table row hover effect */
.table-modern tbody tr {
    transition: all 0.3s ease;
    position: relative;
}

.table-modern tbody tr::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-color);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.table-modern tbody tr:hover::before {
    transform: scaleY(1);
}

/* Input focus effects */
.form-control:focus,
.form-select:focus {
    animation: pulse 0.3s ease;
}

/* Card hover effect */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 70%
    );
    transform: scale(0);
    transition: transform 0.6s ease;
}

.stat-card:hover::after {
    transform: scale(1);
}

/* Number counter animation */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-value {
    animation: countUp 0.5s ease-out;
}

/* Badge pulse animation */
.badge-status {
    animation: scaleIn 0.3s ease-out;
}

.badge-status:hover {
    animation: pulse 0.5s ease;
}

/* Checkbox custom style */
.form-check-input:checked {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    animation: scaleIn 0.2s ease;
}

/* Navbar brand animation */
.navbar-brand:hover {
    animation: bounce 0.5s ease;
}

/* Icon animations */
.stat-icon:hover {
    animation: rotate 0.5s ease;
}

.btn-modern i {
    transition: transform 0.3s ease;
}

.btn-modern:hover i {
    transform: scale(1.2);
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar for tables */
.table-responsive {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) #f1f1f1;
}

.table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

/* Loading overlay blur effect */
.loading-overlay {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .no-print,
    .btn,
    .navbar,
    .toast-container {
        display: none !important;
    }

    .stat-card,
    .form-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .table-modern {
        font-size: 10pt;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #34495e;
        --secondary-color: #2c3e50;
        --light-bg: #1a1a1a;
    }

    body {
        background: linear-gradient(135deg, #1a1a1a 0%, #2c3e50 100%);
        color: #ecf0f1;
    }

    .form-card,
    .stat-card {
        background: #2c3e50;
        color: #ecf0f1;
    }

    .form-control,
    .form-select {
        background: #34495e;
        border-color: #4a5f7f;
        color: #ecf0f1;
    }
}

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

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    .stat-card {
        animation: fadeIn 0.4s ease-out;
    }

    .table-modern {
        font-size: 0.85rem;
    }

    .btn-modern {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .stat-icon,
    .btn-modern i {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}
