/* =====================================================================
   RESPONSIVE FIXES & LAYOUT CORRECTIONS
   Corrige desalinhamentos de header/footer, responsividade mobile/desktop
   e libera animações de forma fluida e sem limitações.
   ===================================================================== */

:root {
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ===== ANIMAÇÕES FLUIDAS E SEM LIMITAÇÕES ===== */

@keyframes pulseGlow {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.4))
                drop-shadow(0 0 16px rgba(236, 72, 153, 0.2));
    }
    50% {
        transform: scale(1.04);
        filter: drop-shadow(0 0 16px rgba(124, 58, 237, 0.8))
                drop-shadow(0 0 28px rgba(236, 72, 153, 0.5));
    }
}

@keyframes shimmerFlow {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

@keyframes floatUp {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

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

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

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== TOPBAR - CORRIGIDO E RESPONSIVO ===== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    width: 100%;
    padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
    background: rgba(13, 11, 20, 0.88);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    animation: slideInDown 0.5s ease-out;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

.logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.3px;
    background: linear-gradient(90deg, #8b5cf6 0%, #ec4899 25%, #fbbf24 50%, #06b6d4 75%, #8b5cf6 100%);
    background-size: 300% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: pulseGlow 3s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.4));
    will-change: filter, transform;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--text);
    opacity: 0.85;
    transition: all 0.25s var(--spring);
    cursor: pointer;
    background: transparent;
    border: none;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    opacity: 1;
    transform: scale(1.08);
}

.icon-btn:active {
    transform: scale(0.92);
}

.avatar-btn img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-2);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(236, 72, 153, 0.3);
    transition: all 0.3s var(--spring);
}

.avatar-btn:hover img {
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 6px 16px rgba(236, 72, 153, 0.5);
    transform: scale(1.05);
}

/* ===== BOTTOM NAV - MOBILE FIRST ===== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(17, 14, 26, 0.95);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--border);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    gap: 2px;
    animation: slideInUp 0.5s ease-out;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
    padding: 6px 8px;
    border-radius: 12px;
    transition: all 0.25s var(--spring);
    flex: 1;
    min-width: 0;
    position: relative;
    cursor: pointer;
    border: none;
    background: transparent;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 24px;
    height: 3px;
    border-radius: 2px;
    background: var(--primary-2);
    transform: translateX(-50%) scaleX(0);
    transform-origin: center;
    transition: transform 0.3s var(--spring);
    box-shadow: 0 0 8px rgba(236, 72, 153, 0.6);
}

.nav-item.active {
    color: #fff;
}

.nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

.nav-item:active {
    transform: scale(0.88);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    transition: all 0.25s var(--spring);
}

.nav-item.active svg {
    filter: drop-shadow(0 0 6px rgba(236, 72, 153, 0.6));
}

.nav-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--primary-2);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 6px;
    min-width: 18px;
    text-align: center;
    animation: pulseGlow 2s ease-in-out infinite;
}

.nav-item-create {
    margin-top: -18px;
}

.create-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.5);
    transition: all 0.3s var(--spring);
    position: relative;
    overflow: hidden;
}

.create-circle::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--primary), var(--primary-2), var(--primary));
    opacity: 0;
    animation: spinRing 4s linear infinite;
}

.create-circle svg {
    position: relative;
    z-index: 1;
}

.nav-item-create:active .create-circle {
    transform: scale(0.85) rotate(90deg);
}

@keyframes spinRing {
    to {
        transform: rotate(360deg);
    }
}

/* ===== APP LAYOUT - MOBILE ===== */

.app-shell {
    min-height: 100vh;
    min-height: var(--vh100);
    display: flex;
    flex-direction: column;
    position: relative;
}

.app-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.app-main {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 12px 12px 100px;
    flex: 1;
}

.app-main.with-nav {
    padding-bottom: 100px;
}

/* ===== DESKTOP LAYOUT (1080px+) ===== */

@media (min-width: 1080px) {
    .topbar {
        position: sticky;
        top: 0;
        padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
    }

    .topbar-inner {
        max-width: 1000px;
        margin: 0 auto;
        padding: 0 20px;
    }

    .app-shell {
        padding-left: 90px;
    }

    .bottom-nav {
        position: fixed;
        top: 0;
        bottom: 0;
        right: auto;
        left: 0;
        width: 90px;
        height: 100vh;
        height: var(--vh100);
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        gap: 8px;
        padding: 20px 8px;
        border-top: none;
        border-right: 1px solid var(--border);
        background: var(--bg-elevated);
        animation: none;
    }

    .nav-item {
        flex: 0 0 auto;
        width: 100%;
        padding: 12px 6px;
        font-size: 11px;
    }

    .nav-item::before {
        top: 50%;
        left: 2px;
        width: 3px;
        height: 22px;
        transform: translateY(-50%) scaleY(0);
        border-radius: 2px;
    }

    .nav-item.active::before {
        transform: translateY(-50%) scaleY(1);
    }

    .nav-item:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    .nav-item-create {
        margin-top: 0;
        order: -1;
    }

    .create-circle {
        width: 52px;
        height: 52px;
    }

    .app-layout {
        max-width: 1000px;
        margin: 0 auto;
        width: 100%;
    }

    .app-main {
        max-width: 640px;
        padding: 20px 20px 40px;
    }

    .app-main.with-nav {
        padding-bottom: 40px;
    }
}

/* ===== TABLET (768px - 1079px) ===== */

@media (min-width: 768px) and (max-width: 1079px) {
    .topbar {
        padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
    }

    .topbar-inner {
        max-width: 100%;
    }

    .app-main {
        max-width: 100%;
        padding: 14px 16px 100px;
    }

    .app-main.with-nav {
        padding-bottom: 100px;
    }
}

/* ===== MOBILE PEQUENO (até 480px) ===== */

@media (max-width: 480px) {
    .topbar {
        padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
    }

    .logo {
        font-size: 18px;
    }

    .topbar-actions {
        gap: 8px;
    }

    .icon-btn {
        width: 32px;
        height: 32px;
    }

    .avatar-btn img {
        width: 28px;
        height: 28px;
    }

    .app-main {
        padding: 10px 10px 100px;
    }

    .nav-item {
        font-size: 9px;
    }

    .nav-item-create {
        margin-top: -16px;
    }

    .create-circle {
        width: 44px;
        height: 44px;
    }
}

/* ===== REMOVE CONFLITOS DE ANIMAÇÃO ===== */

/* Remover o arquivo 00-disable-anim.css que estava bloqueando tudo */
.logo,
.auth-logo,
.topbar .logo {
    animation: pulseGlow 3s ease-in-out infinite !important;
    transform-origin: center;
    will-change: filter, transform;
}

/* Garante que animações não sejam bloqueadas */
.logo *,
.auth-logo *,
.topbar .logo * {
    animation: inherit !important;
}

/* ===== SAFE AREA HANDLING ===== */

@supports (padding: max(0px)) {
    body {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }

    .topbar {
        padding-top: max(12px, calc(12px + env(safe-area-inset-top)));
    }

    .bottom-nav {
        padding-bottom: max(8px, calc(8px + env(safe-area-inset-bottom)));
    }
}

/* ===== REDUZ MOTION PREFERENCE ===== */

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