/*
 * Motion, colour and interaction layer on top of admin-theme.css.
 * Rules that move things only use transform inside animations that do not persist
 * (fill-mode: backwards) — a lasting transform on a container would trap Filament's
 * fixed-position dropdowns and modals inside it.
 */

:root {
    --egy-c1: #7c3aed; /* violet  */
    --egy-c2: #0ea5e9; /* sky     */
    --egy-c3: #10b981; /* emerald */
    --egy-c4: #f59e0b; /* amber   */
    --egy-c5: #f43f5e; /* rose    */
    --egy-c6: #6366f1; /* indigo  */
    --egy-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --egy-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Keyframes ---------- */

@keyframes egy-rise {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to { opacity: 1; transform: none; }
}

@keyframes egy-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes egy-slide-in {
    from { opacity: 0; transform: translateX(var(--egy-slide-from, 18px)); }
    to { opacity: 1; transform: none; }
}

@keyframes egy-pop {
    0% { opacity: 0; transform: translateY(10px) scale(0.96); }
    100% { opacity: 1; transform: none; }
}

@keyframes egy-blob {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    33% { transform: translate3d(6vw, 4vh, 0) scale(1.12); }
    66% { transform: translate3d(-4vw, 8vh, 0) scale(0.94); }
}

@keyframes egy-shine {
    from { transform: translateX(-120%) skewX(-18deg); }
    to { transform: translateX(220%) skewX(-18deg); }
}

@keyframes egy-gradient-pan {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes egy-pulse-ring {
    0% { box-shadow: 0 0 0 0 rgb(124 58 237 / 0.45); }
    100% { box-shadow: 0 0 0 10px rgb(124 58 237 / 0); }
}

@keyframes egy-ripple {
    to { transform: scale(4); opacity: 0; }
}

@keyframes egy-progress {
    0% { transform: translateX(100%) scaleX(0.3); }
    50% { transform: translateX(0) scaleX(0.6); }
    100% { transform: translateX(-100%) scaleX(0.3); }
}

@keyframes egy-icon-wiggle {
    0%, 100% { transform: rotate(0) scale(1); }
    30% { transform: rotate(-12deg) scale(1.15); }
    60% { transform: rotate(8deg) scale(1.1); }
}

/* ---------- Living background ---------- */

.fi-body::before,
.fi-body::after {
    content: '';
    position: fixed;
    /* Behind everything: no z-index on the layout, so modals (z 40) still cover the sticky top bar (z 30). */
    z-index: -1;
    width: 42vw;
    height: 42vw;
    border-radius: 999px;
    filter: blur(70px);
    opacity: 0.38;
    pointer-events: none;
    animation: egy-blob 26s ease-in-out infinite;
}

.fi-body::before {
    top: -14vw;
    inset-inline-start: -10vw;
    background: radial-gradient(circle, #c4b5fd 0%, transparent 65%);
}

.fi-body::after {
    bottom: -18vw;
    inset-inline-end: -8vw;
    background: radial-gradient(circle, #a5f3fc 0%, transparent 65%);
    animation-delay: -12s;
    animation-duration: 32s;
}

.dark .fi-body::before,
.dark .fi-body::after {
    opacity: 0.16;
}


/* ---------- Page entrance ---------- */

.fi-page-header-main-ctn,
.fi-header {
    animation: egy-slide-in 0.55s var(--egy-ease) backwards;
}

.fi-header-heading {
    background: linear-gradient(90deg, var(--egy-text) 0%, var(--egy-text) 55%, var(--egy-accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    position: relative;
}

.fi-header-heading::after {
    content: '';
    display: block;
    width: 56px;
    height: 4px;
    margin-top: 0.5rem;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--egy-c1), var(--egy-c2), var(--egy-c3));
    background-size: 200% 100%;
    animation: egy-gradient-pan 6s ease infinite;
}

/* Cards rise one after another. */
.fi-page .fi-grid-col,
.fi-page .fi-section,
.fi-page .fi-ta-ctn,
.fi-page .fi-wi {
    animation: egy-rise 0.6s var(--egy-ease) backwards;
}

.fi-page .fi-grid-col:nth-child(1) { animation-delay: 0.03s; }
.fi-page .fi-grid-col:nth-child(2) { animation-delay: 0.09s; }
.fi-page .fi-grid-col:nth-child(3) { animation-delay: 0.15s; }
.fi-page .fi-grid-col:nth-child(4) { animation-delay: 0.21s; }
.fi-page .fi-grid-col:nth-child(5) { animation-delay: 0.27s; }
.fi-page .fi-grid-col:nth-child(6) { animation-delay: 0.33s; }
.fi-page .fi-grid-col:nth-child(n + 7) { animation-delay: 0.38s; }

/* Table rows cascade in. */
.fi-ta-row {
    animation: egy-fade 0.45s var(--egy-ease) backwards;
}

.fi-ta-row:nth-child(1) { animation-delay: 0.02s; }
.fi-ta-row:nth-child(2) { animation-delay: 0.05s; }
.fi-ta-row:nth-child(3) { animation-delay: 0.08s; }
.fi-ta-row:nth-child(4) { animation-delay: 0.11s; }
.fi-ta-row:nth-child(5) { animation-delay: 0.14s; }
.fi-ta-row:nth-child(6) { animation-delay: 0.17s; }
.fi-ta-row:nth-child(7) { animation-delay: 0.2s; }
.fi-ta-row:nth-child(8) { animation-delay: 0.23s; }
.fi-ta-row:nth-child(n + 9) { animation-delay: 0.26s; }

/* ---------- Colourful stat tiles ---------- */

.fi-wi-stats-overview .fi-grid-col:nth-child(6n + 1) { --egy-tone: var(--egy-c1); }
.fi-wi-stats-overview .fi-grid-col:nth-child(6n + 2) { --egy-tone: var(--egy-c2); }
.fi-wi-stats-overview .fi-grid-col:nth-child(6n + 3) { --egy-tone: var(--egy-c3); }
.fi-wi-stats-overview .fi-grid-col:nth-child(6n + 4) { --egy-tone: var(--egy-c4); }
.fi-wi-stats-overview .fi-grid-col:nth-child(6n + 5) { --egy-tone: var(--egy-c5); }
.fi-wi-stats-overview .fi-grid-col:nth-child(6n + 6) { --egy-tone: var(--egy-c6); }

.fi-wi-stats-overview-stat {
    --egy-tone: var(--egy-c1);
    border-top: 0;
    isolation: isolate;
    transition: transform 0.35s var(--egy-spring), box-shadow 0.35s var(--egy-ease);
}

.fi-wi-stats-overview .fi-grid-col > .fi-sc-component > .fi-wi-stats-overview-stat {
    --egy-tone: inherit;
}

/* Coloured accent strip along the top. */
.fi-wi-stats-overview-stat::before {
    content: '';
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--egy-tone), color-mix(in oklab, var(--egy-tone) 40%, white));
    z-index: 1;
}

/* Soft glow of the tile colour in the corner (replaces the violet one). */
.fi-wi-stats-overview-stat::after {
    background: radial-gradient(circle, color-mix(in oklab, var(--egy-tone) 22%, transparent) 0%, transparent 70%);
    transition: transform 0.6s var(--egy-ease);
}

.fi-wi-stats-overview-stat:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px -18px color-mix(in oklab, var(--egy-tone) 55%, transparent);
}

.fi-wi-stats-overview-stat:hover::after {
    transform: scale(1.6);
}

/* Icon inside a tinted chip. */
.fi-wi-stats-overview-stat-label-ctn > .fi-icon {
    box-sizing: content-box;
    padding: 0.4rem;
    border-radius: 10px;
    color: var(--egy-tone);
    background-color: color-mix(in oklab, var(--egy-tone) 14%, transparent);
    transition: transform 0.4s var(--egy-spring);
}

.fi-wi-stats-overview-stat:hover .fi-wi-stats-overview-stat-label-ctn > .fi-icon {
    animation: egy-icon-wiggle 0.6s var(--egy-ease);
}

.fi-wi-stats-overview .fi-grid-col:first-child > .fi-sc-component > .fi-wi-stats-overview-stat::before {
    background: linear-gradient(90deg, rgb(255 255 255 / 0.65), rgb(255 255 255 / 0.15));
}

.fi-wi-stats-overview .fi-grid-col:first-child > .fi-sc-component > .fi-wi-stats-overview-stat .fi-wi-stats-overview-stat-label-ctn > .fi-icon {
    background-color: rgb(255 255 255 / 0.2);
    color: #fff;
}

/* The filled tile slowly shifts its gradient. */
.fi-wi-stats-overview .fi-grid-col:first-child > .fi-sc-component > .fi-wi-stats-overview-stat {
    background: linear-gradient(135deg, #a78bfa, #7c3aed, #6d28d9, #4f46e5);
    background-size: 220% 220%;
    animation: egy-gradient-pan 9s ease infinite;
}

/* ---------- Sections: coloured edge and header tint ---------- */

.fi-section:not(.fi-section-not-contained) {
    transition: box-shadow 0.3s var(--egy-ease), border-color 0.3s var(--egy-ease);
}

.fi-section:not(.fi-section-not-contained):hover {
    box-shadow: var(--egy-shadow-hover);
    border-color: var(--egy-border-strong);
}

.fi-section:not(.fi-section-not-contained) > .fi-section-header {
    position: relative;
    background: linear-gradient(90deg, var(--egy-accent-softer), transparent 70%);
}

.fi-section:not(.fi-section-not-contained) > .fi-section-header::before {
    content: '';
    position: absolute;
    inset-block: 0.9rem;
    inset-inline-start: 0;
    width: 4px;
    border-radius: 0 6px 6px 0;
    background: linear-gradient(180deg, var(--egy-c1), var(--egy-c2));
}

[dir='rtl'] .fi-section:not(.fi-section-not-contained) > .fi-section-header {
    background: linear-gradient(270deg, var(--egy-accent-softer), transparent 70%);
}

[dir='rtl'] .fi-section:not(.fi-section-not-contained) > .fi-section-header::before {
    border-radius: 6px 0 0 6px;
}

.fi-section-header > .fi-icon {
    color: var(--egy-accent);
}

/* ---------- Tables ---------- */

.fi-ta-ctn {
    transition: box-shadow 0.3s var(--egy-ease);
}

.fi-ta-ctn:hover {
    box-shadow: var(--egy-shadow-hover);
}

.fi-ta-header-cell {
    position: relative;
}

.fi-ta-table > thead {
    background: linear-gradient(90deg, var(--egy-accent-softer), var(--egy-surface-soft));
}

.fi-ta-row {
    position: relative;
}

/* Accent bar slides in on the hovered row. */
.fi-ta-row > td:first-child {
    position: relative;
}

.fi-ta-row > td:first-child::before {
    content: '';
    position: absolute;
    inset-block: 6px;
    inset-inline-start: 0;
    width: 3px;
    border-radius: 3px;
    background: var(--egy-gradient);
    transform: scaleY(0);
    transition: transform 0.25s var(--egy-ease);
}

.fi-ta-row:hover > td:first-child::before {
    transform: scaleY(1);
}

.fi-ta-row.fi-selected,
.fi-ta-row:has(.fi-ta-record-checkbox:checked) {
    background-color: var(--egy-accent-soft);
}

.fi-ta-text-item {
    transition: color 0.2s ease;
}

.fi-ta-row:hover a .fi-ta-text-item,
.fi-ta-row:hover a.fi-ta-text-item {
    color: var(--egy-accent);
}

/* ---------- Badges: soft, colourful, with a status dot ---------- */

.fi-badge {
    gap: 0.35rem;
    transition: transform 0.2s var(--egy-spring);
}

.fi-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.85;
    flex-shrink: 0;
}

.fi-badge:has(> .fi-icon)::before,
.fi-sidebar-item-btn .fi-badge::before,
.fi-tabs-item .fi-badge::before,
.fi-icon-btn-badge-ctn .fi-badge::before {
    display: none;
}

.fi-ta-row:hover .fi-badge {
    transform: scale(1.05);
}

/* ---------- Sidebar ---------- */

.fi-sidebar-group-label {
    background: linear-gradient(90deg, var(--egy-c1), var(--egy-c2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.fi-sidebar-group-btn > .fi-icon {
    color: var(--egy-accent);
}

.fi-sidebar-item {
    animation: egy-slide-in 0.4s var(--egy-ease) backwards;
}

[dir='rtl'] .fi-sidebar-item {
    --egy-slide-from: -14px;
}

.fi-sidebar-item-btn > .fi-icon {
    transition: transform 0.35s var(--egy-spring), color 0.2s ease;
}

.fi-sidebar-item-btn:hover > .fi-icon {
    transform: scale(1.18) rotate(-6deg);
}

.fi-sidebar-item-btn > .fi-sidebar-item-label {
    transition: transform 0.25s var(--egy-ease), color 0.2s ease;
}

.fi-sidebar-item-btn:hover > .fi-sidebar-item-label {
    transform: translateX(-3px);
}

[dir='ltr'] .fi-sidebar-item-btn:hover > .fi-sidebar-item-label {
    transform: translateX(3px);
}

.fi-sidebar-item.fi-active > .fi-sidebar-item-btn {
    background: linear-gradient(135deg, #a78bfa, #7c3aed, #6d28d9, #4f46e5);
    background-size: 220% 220%;
    animation: egy-gradient-pan 8s ease infinite;
    overflow: hidden;
}

/* Light sweeping across the active item. */
.fi-sidebar-item.fi-active > .fi-sidebar-item-btn::after {
    content: '';
    position: absolute;
    inset-block: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.35), transparent);
    animation: egy-shine 3.8s ease-in-out infinite;
    pointer-events: none;
}

/* ---------- Top bar ---------- */

.fi-topbar {
    position: relative;
}

.fi-topbar::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--egy-c1), var(--egy-c2), var(--egy-c3), var(--egy-c4), var(--egy-c5), var(--egy-c1));
    background-size: 300% 100%;
    animation: egy-gradient-pan 14s linear infinite;
    opacity: 0.85;
}

.fi-topbar .fi-icon-btn {
    transition: transform 0.3s var(--egy-spring), background-color 0.2s ease;
}

.fi-topbar .fi-icon-btn:hover {
    transform: translateY(-2px) scale(1.08);
    background-color: var(--egy-accent-soft);
}

.fi-topbar .fi-icon-btn-badge-ctn .fi-badge {
    animation: egy-pulse-ring 1.8s ease-out infinite;
}

.fi-user-menu .fi-avatar,
.fi-topbar .fi-avatar {
    transition: transform 0.35s var(--egy-spring);
}

.fi-user-menu .fi-avatar:hover,
.fi-topbar .fi-avatar:hover {
    transform: scale(1.1) rotate(-4deg);
}

/* ---------- Buttons ---------- */

.fi-btn {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.fi-btn.fi-color-primary:not(.fi-outlined) {
    background: linear-gradient(135deg, #a78bfa, #7c3aed, #6d28d9, #4f46e5);
    background-size: 220% 220%;
    background-position: 0% 50%;
    transition: background-position 0.6s var(--egy-ease), transform 0.25s var(--egy-spring), box-shadow 0.25s ease;
}

.fi-btn.fi-color-primary:not(.fi-outlined):hover {
    background-position: 100% 50%;
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -12px rgb(124 58 237 / 0.7);
}

.fi-btn:active {
    transform: translateY(0) scale(0.97);
}

.fi-btn.fi-color-primary:not(.fi-outlined)::after {
    content: '';
    position: absolute;
    inset-block: 0;
    width: 35%;
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.35), transparent);
    transform: translateX(-120%) skewX(-18deg);
    pointer-events: none;
    z-index: -1;
}

.fi-btn.fi-color-primary:not(.fi-outlined):hover::after {
    animation: egy-shine 0.9s var(--egy-ease);
}

/* Coloured flat buttons for the other colours. */
.fi-btn.fi-color-success:not(.fi-outlined) { background: linear-gradient(135deg, #34d399, #059669); border: 0; }
.fi-btn.fi-color-danger:not(.fi-outlined) { background: linear-gradient(135deg, #fb7185, #e11d48); border: 0; }
.fi-btn.fi-color-warning:not(.fi-outlined) { background: linear-gradient(135deg, #fbbf24, #d97706); border: 0; }
.fi-btn.fi-color-info:not(.fi-outlined) { background: linear-gradient(135deg, #38bdf8, #0284c7); border: 0; }

.fi-btn.fi-color-success:not(.fi-outlined),
.fi-btn.fi-color-danger:not(.fi-outlined),
.fi-btn.fi-color-warning:not(.fi-outlined),
.fi-btn.fi-color-info:not(.fi-outlined) {
    transition: transform 0.25s var(--egy-spring), box-shadow 0.25s ease, filter 0.2s ease;
}

.fi-btn.fi-color-success:not(.fi-outlined):hover,
.fi-btn.fi-color-danger:not(.fi-outlined):hover,
.fi-btn.fi-color-warning:not(.fi-outlined):hover,
.fi-btn.fi-color-info:not(.fi-outlined):hover {
    transform: translateY(-2px);
    filter: saturate(1.15);
}

.fi-btn.fi-color-gray:not(.fi-outlined):hover {
    background-color: var(--egy-accent-softer);
    border-color: var(--egy-border-strong);
}

/* Ripple spawned by admin-interactions.js */
.egy-ripple {
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    background: rgb(255 255 255 / 0.45);
    transform: scale(0);
    animation: egy-ripple 0.6s ease-out forwards;
    z-index: 2;
}

.fi-btn.fi-color-gray .egy-ripple,
.fi-icon-btn .egy-ripple,
.fi-tabs-item:not(.fi-active) .egy-ripple {
    background: rgb(124 58 237 / 0.25);
}

/* ---------- Tabs ---------- */

.fi-tabs-item {
    position: relative;
    overflow: hidden;
    transition: color 0.2s ease, background-color 0.25s ease, transform 0.25s var(--egy-spring);
}

.fi-tabs-item:not(.fi-active):hover {
    background-color: var(--egy-accent-softer);
    transform: translateY(-1px);
}

.fi-tabs-item.fi-active {
    background: linear-gradient(135deg, #a78bfa, #7c3aed, #4f46e5);
    background-size: 200% 200%;
    animation: egy-gradient-pan 7s ease infinite;
}

/* ---------- Forms ---------- */

.fi-input-wrp {
    transition: box-shadow 0.25s var(--egy-ease), border-color 0.25s ease, transform 0.25s var(--egy-ease);
}

.fi-input-wrp:hover:not(.fi-disabled) {
    border-color: var(--egy-border-strong);
}

.fi-input-wrp:focus-within:not(.fi-disabled) {
    box-shadow: 0 0 0 4px var(--egy-accent-soft), 0 8px 22px -12px rgb(124 58 237 / 0.45);
}

.fi-fo-field-label-content {
    transition: color 0.2s ease;
}

.fi-fo-field:focus-within .fi-fo-field-label-content {
    color: var(--egy-accent);
}

.fi-toggle {
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.fi-toggle.fi-toggle-on {
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    box-shadow: 0 4px 12px -4px rgb(124 58 237 / 0.6);
}

.fi-checkbox-input {
    transition: transform 0.2s var(--egy-spring);
}

.fi-checkbox-input:checked {
    transform: scale(1.08);
}

/* ---------- Dropdowns, modals, notifications ---------- */

.fi-dropdown-panel {
    animation: egy-pop 0.22s var(--egy-ease) backwards;
}

.fi-dropdown-list-item {
    transition: background-color 0.15s ease, padding 0.2s var(--egy-ease);
}

.fi-dropdown-list-item:hover .fi-icon {
    color: var(--egy-accent);
}

.fi-modal-window {
    animation: egy-pop 0.32s var(--egy-spring) backwards;
}

.fi-modal-header {
    background: linear-gradient(180deg, var(--egy-accent-softer), transparent);
}

.fi-modal-icon-bg {
    animation: egy-pulse-ring 2s ease-out infinite;
}

.fi-no-notification {
    animation: egy-slide-in 0.4s var(--egy-spring) backwards;
    border-inline-start: 4px solid var(--egy-accent);
}

/* ---------- Pagination ---------- */

.fi-pagination-item-btn {
    transition: transform 0.2s var(--egy-spring), background-color 0.2s ease;
}

.fi-pagination-item-btn:hover {
    transform: translateY(-2px);
    background-color: var(--egy-accent-soft);
}

/* ---------- Empty states ---------- */

.fi-ta-empty-state-icon-bg {
    animation: egy-pulse-ring 2.2s ease-out infinite;
}

/* ---------- Login ---------- */

.fi-simple-main {
    animation: egy-pop 0.6s var(--egy-spring) backwards;
    position: relative;
    overflow: hidden;
}

.fi-simple-main::before {
    content: '';
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--egy-c1), var(--egy-c2), var(--egy-c3), var(--egy-c4), var(--egy-c5), var(--egy-c1));
    background-size: 300% 100%;
    animation: egy-gradient-pan 10s linear infinite;
}

/* ---------- Top progress bar for Livewire requests (admin-interactions.js toggles it) ---------- */

.egy-progress {
    position: fixed;
    inset-inline: 0;
    top: 0;
    height: 3px;
    z-index: 100;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.egy-progress.egy-busy {
    opacity: 1;
}

.egy-progress::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--egy-c2), var(--egy-c1), var(--egy-c5));
    animation: egy-progress 1.1s ease-in-out infinite;
}

/* ---------- Accessibility: no motion when the user asks for less ---------- */

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