/**
 * Visible motion — teen football club UI
 */

/* Page load */
body:not(.is-loaded) .wrapper {
    opacity: 0;
}

body.is-loaded .wrapper {
    animation: pageIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes pageIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* Scroll / enter reveal */
.reveal {
    opacity: 0;
    transform: translateY(28px) scale(0.97);
    transition:
        opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.reveal-delay-1 { transition-delay: 0.08s; }
.reveal-delay-2 { transition-delay: 0.16s; }
.reveal-delay-3 { transition-delay: 0.24s; }
.reveal-delay-4 { transition-delay: 0.32s; }

/* Stat icons bounce */
.stat-icon {
    display: inline-block;
    animation: iconPop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.stat-card:nth-child(1) .stat-icon { animation-delay: 0.2s; }
.stat-card:nth-child(2) .stat-icon { animation-delay: 0.35s; }
.stat-card:nth-child(3) .stat-icon { animation-delay: 0.5s; }
.stat-card:nth-child(4) .stat-icon { animation-delay: 0.65s; }

@keyframes iconPop {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    70% { transform: scale(1.2) rotate(8deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Logo */
.logo-ball {
    animation: ballBounce 2s ease-in-out infinite !important;
}

@keyframes ballBounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-6px) rotate(90deg); }
    50% { transform: translateY(0) rotate(180deg); }
    75% { transform: translateY(-4px) rotate(270deg); }
}

/* Bar charts grow */
.bar-fill {
    width: 0 !important;
    transition: width 1.1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bar-fill.is-animated {
    width: var(--bar-target, 0%) !important;
}

/* Quick action chips */
.quick-action-btn {
    animation: slideInChip 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.quick-actions .quick-action-btn:nth-child(1) { animation-delay: 0.15s; }
.quick-actions .quick-action-btn:nth-child(2) { animation-delay: 0.22s; }
.quick-actions .quick-action-btn:nth-child(3) { animation-delay: 0.29s; }
.quick-actions .quick-action-btn:nth-child(4) { animation-delay: 0.36s; }

@keyframes slideInChip {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: translateX(0); }
}

html[dir="rtl"] .quick-action-btn {
    animation-name: slideInChipRtl;
}

@keyframes slideInChipRtl {
    from { opacity: 0; transform: translateX(-24px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Table rows stagger */
tbody tr.reveal-row {
    opacity: 0;
    transform: translateX(16px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

tbody tr.reveal-row.is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Button press */
.btn:active {
    transform: scale(0.96) !important;
}

/* Success celebration */
.celebrate {
    animation: celebrate 0.65s ease;
}

@keyframes celebrate {
    0%, 100% { transform: scale(1); }
    30% { transform: scale(1.08); }
    60% { transform: scale(0.95); }
}

/* Floating emojis (dashboard) */
.float-emoji {
    position: fixed;
    font-size: 1.5rem;
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
    animation: floatEmoji 6s ease-in-out infinite;
}

.float-emoji:nth-child(1) { top: 15%; left: 8%; animation-delay: 0s; }
.float-emoji:nth-child(2) { top: 60%; right: 5%; animation-delay: 1.5s; }
.float-emoji:nth-child(3) { bottom: 20%; left: 12%; animation-delay: 3s; }

@keyframes floatEmoji {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(15deg); }
}

/* Nav backdrop */
.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.nav-backdrop.is-active {
    opacity: 1;
    visibility: visible;
}

/* Bottom nav (mobile) */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(11, 11, 13, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 2px solid var(--grass);
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
        justify-content: space-around;
        gap: 4px;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 8px 4px;
        min-height: 52px;
        border-radius: 12px;
        color: var(--text-muted);
        font-size: 0.65rem;
        font-weight: 700;
        font-family: inherit;
        text-decoration: none;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: transform 0.2s, background 0.2s, color 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .bottom-nav-item .nav-emoji {
        font-size: 1.35rem;
        line-height: 1;
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .bottom-nav-item.active {
        color: var(--grass-bright);
        background: rgba(227, 6, 19, 0.10);
    }

    .bottom-nav-item.active .nav-emoji {
        transform: scale(1.25) translateY(-2px);
        animation: tabPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    @keyframes tabPop {
        0% { transform: scale(0.8); }
        60% { transform: scale(1.3) translateY(-4px); }
        100% { transform: scale(1.25) translateY(-2px); }
    }

    .bottom-nav-item:active {
        transform: scale(0.92);
    }

    body.has-bottom-nav {
        padding-bottom: 72px;
    }

    body.has-bottom-nav .container {
        padding-bottom: 88px;
    }

    body.has-bottom-nav .footer {
        margin-bottom: 64px;
    }

    /* Hide desktop nav links on mobile */
    .navbar-nav.desktop-only {
        display: none !important;
    }

    .navbar {
        padding: 10px 16px;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .navbar-brand h1 {
        font-size: 1rem;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-menu {
        order: unset;
        width: auto;
        border: none;
        padding: 0;
        gap: 8px;
        flex-shrink: 0;
    }

    .user-badge {
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    .btn-logout {
        padding: 10px 12px;
        font-size: 0.8rem;
        min-height: 44px;
    }

    .nav-toggle {
        min-width: 44px;
        min-height: 44px;
    }

    /* Mobile overflow menu */
    .mobile-menu {
        position: fixed;
        bottom: 72px;
        left: 12px;
        right: 12px;
        background: var(--pitch-mid);
        border: 2px solid var(--grass);
        border-radius: var(--radius);
        padding: 12px;
        z-index: 999;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        transform: translateY(120%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s, visibility 0.3s;
        box-shadow: var(--shadow);
    }

    .mobile-menu.is-open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .mobile-menu a {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 14px 12px;
        background: rgba(0, 0, 0, 0.25);
        border-radius: var(--radius-sm);
        color: var(--text);
        font-weight: 600;
        font-size: 0.9rem;
        min-height: 48px;
    }

    .mobile-menu a:active {
        background: rgba(227, 6, 19, 0.12);
    }

    /* Tables → cards */
    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody tr {
        display: block;
        background: rgba(0, 0, 0, 0.25);
        border: 1px solid var(--card-border);
        border-radius: var(--radius-sm);
        margin-bottom: 12px;
        padding: 12px;
    }

    .table-mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 8px 4px;
        border: none;
        text-align: left;
    }

    .table-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--grass-bright);
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .table-mobile-cards tbody td:last-child {
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 8px;
        padding-top: 12px;
        border-top: 1px solid var(--card-border);
        margin-top: 4px;
    }

    .table-mobile-cards tbody td:last-child::before {
        display: none;
    }

    html[dir="rtl"] .table-mobile-cards tbody td {
        text-align: right;
    }

    .quick-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding-bottom: 8px;
        gap: 10px;
    }

    .quick-action-btn {
        flex-shrink: 0;
        scroll-snap-align: start;
        white-space: nowrap;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .section-header .btn,
    .section-header form {
        width: 100%;
    }

    .search-form {
        width: 100%;
    }

    .search-form input {
        flex: 1;
        min-width: 0;
    }

    .page-header h2 {
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .charts-section {
        grid-template-columns: 1fr;
    }

    .bar-row {
        grid-template-columns: 70px 1fr 32px;
        gap: 8px;
    }

    .btn {
        min-height: 44px;
        padding: 12px 16px;
    }

    .btn-sm {
        min-height: 40px;
        padding: 10px 14px;
    }
}

.bar-fill-revenue {
    background: linear-gradient(90deg, #F59E0B, #FF1E2D) !important;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

/* Auth page animations */
body.auth-layout .auth-box {
    animation: authPop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes authPop {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

body.auth-layout.is-loaded .auth-box {
    animation: authPop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@media (prefers-reduced-motion: reduce) {
    .reveal,
    .bar-fill,
    .stat-icon,
    .logo-ball,
    .quick-action-btn,
    body.is-loaded .wrapper {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .bar-fill.is-animated {
        width: var(--bar-target, 0%) !important;
    }
}
