/* ═══════════════════════════════════════════════════════════════════════════════
   OmniTransport — Animations & Transitions
   Purposeful, fast (200-400ms), consistent, and motion-respectful.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── Base Timing Variables ─── */
:root {
    --anim-micro: 100ms;
    --anim-fast: 200ms;
    --anim-base: 250ms;
    --anim-smooth: 300ms;
    --anim-modal: 250ms;
    --anim-page: 350ms;
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in: cubic-bezier(0, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-spring: cubic-bezier(0.22, 1.2, 0.36, 1);
}

/* ═══════════════════════════════════════════════════════════
   TAB / PAGE TRANSITIONS
   ═══════════════════════════════════════════════════════════ */

.tab-content.active {
    animation: fadeIn var(--anim-fast) var(--ease-out) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sidebar active indicator slide */
.nav-item {
    position: relative;
    transition: background var(--anim-fast) var(--ease-out),
                color var(--anim-fast) var(--ease-out);
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
    transition: transform var(--anim-base) var(--ease-spring);
}

.nav-item.active::before {
    transform: translateY(-50%) scaleY(1);
}

/* ═══════════════════════════════════════════════════════════
   MODALS & DIALOGS
   ═══════════════════════════════════════════════════════════ */

.modal-backdrop,
.dialog-backdrop {
    animation: backdropFadeIn 150ms var(--ease-out) forwards;
}

.modal-backdrop.closing,
.dialog-backdrop.closing {
    animation: backdropFadeOut var(--anim-fast) var(--ease-in) forwards;
}

@keyframes backdropFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes backdropFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.modal-content,
.dialog-card {
    animation: modalEnter var(--anim-modal) var(--ease-spring) forwards;
}

.modal-content.closing,
.dialog-card.closing {
    animation: modalExit var(--anim-fast) var(--ease-in) forwards;
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modalExit {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
}

/* Confirmation dialog: subtle bounce */
.dialog-card.confirm {
    animation: confirmBounce var(--anim-smooth) var(--ease-bounce) forwards;
}

@keyframes confirmBounce {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    50% {
        transform: scale(1.02);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ═══════════════════════════════════════════════════════════
   CARDS & LIST ITEMS
   ═══════════════════════════════════════════════════════════ */

/* New card slide in from top */
.animate-enter,
.card-enter {
    animation: cardSlideIn var(--anim-smooth) var(--ease-out) forwards;
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Card removal: fade out + slide down */
.animate-exit,
.card-exit {
    animation: cardSlideOut var(--anim-smooth) var(--ease-in) forwards;
}

@keyframes cardSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(15px);
    }
}

/* Fleet/vehicle card hover lift */
.fleet-card,
.vehicle-card,
.dispatch-card,
navio-dispatch-card {
    transition: transform var(--anim-fast) var(--ease-out),
                box-shadow var(--anim-fast) var(--ease-out);
}

.fleet-card:hover,
.vehicle-card:hover,
.dispatch-card:hover,
navio-dispatch-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS & INTERACTIONS
   ═══════════════════════════════════════════════════════════ */

/* Button tactile click feedback */
.btn,
button[class*="btn"] {
    transition: transform var(--anim-micro) ease,
                background var(--anim-fast) var(--ease-out),
                box-shadow var(--anim-fast) var(--ease-out),
                opacity var(--anim-fast) var(--ease-out);
}

.btn:active,
button[class*="btn"]:active {
    transform: scale(0.97);
}

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* ═══════════════════════════════════════════════════════════
   MAP — VEHICLE MARKERS
   ═══════════════════════════════════════════════════════════ */

.vehicle-marker-appear {
    animation: markerPop var(--anim-smooth) var(--ease-bounce) forwards;
}

@keyframes markerPop {
    from {
        opacity: 0;
        transform: scale(0);
    }
    70% {
        transform: scale(1.1);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ═══════════════════════════════════════════════════════════
   LOADING & STATE TRANSITIONS
   ═══════════════════════════════════════════════════════════ */

/* Smooth spinner */
.fa-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Config save success flash (AdminWeb) */
.config-saved-flash {
    animation: successPulse 500ms var(--ease-out) forwards;
}

@keyframes successPulse {
    0% { background-color: inherit; }
    30% { background-color: rgba(16, 185, 129, 0.15); }
    100% { background-color: inherit; }
}

/* Tenant status change row transition */
.tenant-row {
    transition: background-color var(--anim-smooth) var(--ease-out);
}

/* ═══════════════════════════════════════════════════════════
   STAGGERED LIST ANIMATION
   For lists of cards that appear one after another
   ═══════════════════════════════════════════════════════════ */

.stagger-list > *:nth-child(1) { animation-delay: 0ms; }
.stagger-list > *:nth-child(2) { animation-delay: 50ms; }
.stagger-list > *:nth-child(3) { animation-delay: 100ms; }
.stagger-list > *:nth-child(4) { animation-delay: 150ms; }
.stagger-list > *:nth-child(5) { animation-delay: 200ms; }
.stagger-list > *:nth-child(6) { animation-delay: 250ms; }

/* ═══════════════════════════════════════════════════════════
   REDUCED MOTION — Respect user accessibility preferences
   Disables all decorative animations, keeps functional state changes
   ═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .tab-content.active {
        animation: none;
        opacity: 1;
    }

    .modal-content,
    .dialog-card {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .fleet-card:hover,
    .vehicle-card:hover,
    .dispatch-card:hover,
    navio-dispatch-card:hover {
        transform: none;
    }
}
