/* ============================================
   OnshoreHSE Animations
   Micro-animations, Transitions, Effects
   ============================================ */

/* --- Entrance Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

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

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

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

/* --- Staggered Card Animation --- */
.animate-stagger > * {
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.animate-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.animate-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.animate-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.animate-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.animate-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.animate-stagger > *:nth-child(6) { animation-delay: 0.3s; }
.animate-stagger > *:nth-child(7) { animation-delay: 0.35s; }
.animate-stagger > *:nth-child(8) { animation-delay: 0.4s; }

/* --- Counter Animation --- */
.animate-counter {
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Pulse --- */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* --- Bounce --- */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

/* --- Spin --- */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* --- Shimmer Loading --- */
@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--gray-200) 25%,
        var(--gray-100) 50%,
        var(--gray-200) 75%
    );
    background-size: 200px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 4px;
}

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

.skeleton-circle {
    border-radius: 50%;
}

/* --- Notification Animations --- */
@keyframes slideInNotification {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

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

/* --- Toast Container --- */
.toast-container {
    position: fixed;
    top: var(--space-5);
    right: var(--space-5);
    z-index: var(--z-notification);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    min-width: 320px;
    max-width: 420px;
    animation: slideInNotification 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

.toast.removing {
    animation: slideOutNotification 0.3s ease forwards;
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.toast.success::before { background: var(--color-success); }
.toast.warning::before { background: var(--color-warning); }
.toast.error::before { background: var(--color-danger); }
.toast.info::before { background: var(--color-info); }

.toast .toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--color-success); }
.toast.warning .toast-icon { color: var(--color-warning); }
.toast.error .toast-icon { color: var(--color-danger); }
.toast.info .toast-icon { color: var(--color-info); }

.toast .toast-content {
    flex: 1;
}

.toast .toast-title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.toast .toast-message {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: 2px;
}

.toast .toast-close {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: flex;
}

.toast .toast-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.toast .toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.2;
    transition: width linear;
}

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

.count-animate {
    animation: countUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* --- Ripple effect on click --- */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    width: 100px;
    height: 100px;
    margin-top: -50px;
    margin-left: -50px;
    top: 50%;
    left: 50%;
    transform: scale(0);
    opacity: 1;
    transition: transform 0.5s, opacity 0.5s;
}

.ripple:active::after {
    transform: scale(4);
    opacity: 0;
    transition: 0s;
}

/* --- Glow effect --- */
.glow-emerald {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
    transition: box-shadow var(--transition-base);
}

.glow-emerald:hover {
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.25);
}

/* --- Floating label --- */
.float-label {
    position: relative;
}

.float-label input:focus ~ label,
.float-label input:not(:placeholder-shown) ~ label {
    transform: translateY(-24px) scale(0.85);
    color: var(--emerald-600);
}

.float-label label {
    position: absolute;
    top: 10px;
    left: 12px;
    font-size: var(--text-sm);
    color: var(--gray-400);
    transition: all var(--transition-base);
    pointer-events: none;
    transform-origin: left top;
}
