/* ═══════════════════════════════════════════════════════════════════════════════
   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); }
}

/* ═══════════════════════════════════════════════════════════
   BRANDED ZHORVIN LOADER
   The Zhorvin mark: the Z badge + ring hold still while the brand DOT orbits the ring (+ a gentle
   badge breathe). .zhorvin-spinner-wrap/.zhorvin-mark = inline indicator; .zhorvin-loading-overlay
   = full-area wait (no text). GPU-friendly (transform only); aspect ratio preserved.
   ═══════════════════════════════════════════════════════════ */

/* The Z badge + ring stay STILL; only the brand DOT orbits the ring, with a gentle breathing
   pulse on the badge. GPU-friendly (transform only), transform-origin at the 456x456 centre. */
@keyframes zhorvinOrbit {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes zhorvinBreathe {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.94); opacity: 0.92; }
}

.zhorvin-spinner-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: -0.2em;
    line-height: 0;
}

.zhorvin-mark {
    display: inline-block;
    overflow: visible;        /* the orbiting dot rides the ring edge */
}

/* Orbit the dot about the mark's centre (228,228 on the 456 canvas = 50% 50%). */
.zhorvin-mark .zv-orbit {
    transform-box: view-box;
    transform-origin: 228px 228px;
    will-change: transform;
    animation: zhorvinOrbit 1.15s linear infinite;
}

/* Subtle badge breathe so the mark feels alive without a crude whole-logo spin. */
.zhorvin-mark .zv-badge {
    transform-box: view-box;
    transform-origin: 228px 228px;
    will-change: transform, opacity;
    animation: zhorvinBreathe 1.8s ease-in-out infinite;
}

/* Full-area / global page-load overlay (no text — the mark alone is the indicator). */
.zhorvin-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(2px);
    opacity: 1;
    transition: opacity 400ms var(--ease-out, ease-out);
}

.zhorvin-loading-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.zhorvin-loading-overlay .zhorvin-mark {
    width: 72px;
    height: 72px;
}

/* 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;
    }

    /* Branded loader: hold the mark still (dot + badge) — show the static logo, no motion. */
    .zhorvin-mark .zv-orbit,
    .zhorvin-mark .zv-badge {
        animation: none !important;
        transform: none !important;
    }

    .zhorvin-loading-overlay {
        transition: none !important;
    }

    .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;
    }
}
