/* MotoClub OS - Design System Mobile Nativo & UX Posicional (PWA) */
:root {
    --mc-bg: #0d0f12;
    --mc-card: #151820;
    --mc-card-hover: #1c212b;
    --mc-border: rgba(255, 255, 255, 0.08);
    --mc-gold: #e5a93b;
    --mc-gold-rgb: 229, 169, 59;
    --mc-orange: #ff5722;
    --mc-text-main: #f1f3f5;
    --mc-text-muted: #9aa0a6;
    
    /* UX Posicional & Zonas do Polegar */
    --mc-touch-min: 44px;
    --mc-touch-comfortable: 48px;
    --bottom-nav-height: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* ==========================================================================
   1. Base & Comportamento App Nativo (Touch, Overscroll, Viewport)
   ========================================================================== */
html, body {
    background-color: var(--mc-bg);
    color: var(--mc-text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    overflow-x: hidden;
}

body {
    user-select: none;
    overscroll-behavior-y: contain;
}

/* Seleção de texto apenas onde necessário */
input, textarea, p, span, td, th, h1, h2, h3, h4, h5, h6, .selectable-text {
    user-select: text;
}

/* Prevenção de Zoom automático incômodo no Safari iOS em inputs */
@media (max-width: 767.98px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
        min-height: var(--mc-touch-comfortable);
        border-radius: 10px;
    }
}

/* Botões com Feedback Tátil (Micro-interação de Toque) */
.btn, .nav-link, .touch-clickable {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease, filter 0.15s ease, background-color 0.15s ease;
}

.btn:active, .touch-clickable:active {
    transform: scale(0.96);
    filter: brightness(0.92);
}

/* ==========================================================================
   2. Sidebar Desktop vs Drawer Mobile (Painéis Administrativos)
   ========================================================================== */
.sidebar-club, .sidebar-admin {
    width: 275px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    background-color: #11141b;
    border-right: 1px solid var(--mc-border);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-club::-webkit-scrollbar, .sidebar-admin::-webkit-scrollbar {
    width: 4px;
}

.sidebar-club::-webkit-scrollbar-thumb, .sidebar-admin::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}

.sidebar-nav-section {
    padding: 10px 10px 4px 10px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    display: flex;
    align-items: center;
}
.sidebar-nav-section::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin-left: 8px;
}

.sidebar-club .nav-item {
    margin-bottom: 2px;
}

.sidebar-club .nav-link {
    display: flex;
    align-items: center;
    color: #94a3b8 !important;
    font-size: 0.86rem;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.sidebar-club .nav-link:hover {
    color: #f8fafc !important;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-club .nav-link.active {
    color: #ffffff !important;
    background: rgba(229, 169, 59, 0.12);
    border-left-color: var(--mc-gold);
    font-weight: 600;
}

.sidebar-club .nav-link.active .nav-icon-wrapper {
    color: var(--mc-gold);
}

.nav-icon-wrapper {
    width: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-right: 10px;
    color: #64748b;
    transition: color 0.15s ease;
    flex-shrink: 0;
}

.sidebar-club .nav-link:hover .nav-icon-wrapper {
    color: #cbd5e1;
}

.nav-badge-pill {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 12px;
    letter-spacing: 0.02em;
}

.nav-badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.nav-badge-addon {
    background: rgba(229, 169, 59, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(229, 169, 59, 0.3);
}

.nav-badge-muted {
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 991.98px) {
    .sidebar-club, .sidebar-admin {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.7);
    }
    
    .sidebar-club.show, .sidebar-admin.show {
        transform: translateX(0);
    }

    .main-panel-content {
        padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 24px) !important;
        padding-left: 14px !important;
        padding-right: 14px !important;
        padding-top: 14px !important;
    }

    .metric-big, .metric-val {
        font-size: 1.45rem !important;
    }
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1040;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}
.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* ==========================================================================
   3. Barras de Navegação Inferior App Nativo (Zona do Polegar)
   ========================================================================== */
.mobile-bottom-nav,
.club-mobile-bottom-nav,
.portal-mobile-bottom-nav {
    display: none;
}

@media (max-width: 991.98px) {
    .mobile-bottom-nav,
    .club-mobile-bottom-nav,
    .portal-mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(var(--bottom-nav-height) + var(--safe-bottom));
        background: rgba(14, 17, 23, 0.94);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--mc-border);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
        z-index: 1030;
        padding-bottom: var(--safe-bottom);
        align-items: center;
        justify-content: space-around;
        padding-left: env(safe-area-inset-left, 6px);
        padding-right: env(safe-area-inset-right, 6px);
    }

    .mobile-bottom-nav a,
    .club-mobile-bottom-nav a,
    .portal-mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--mc-text-muted);
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 600;
        padding: 6px 4px;
        min-height: var(--mc-touch-min);
        border-radius: 12px;
        transition: color 0.15s ease, transform 0.15s ease;
        flex: 1;
        position: relative;
    }

    .mobile-bottom-nav a i,
    .club-mobile-bottom-nav a i,
    .portal-mobile-bottom-nav a i {
        font-size: 1.3rem;
        margin-bottom: 2px;
        transition: transform 0.15s ease;
    }

    .mobile-bottom-nav a.active,
    .club-mobile-bottom-nav a.active,
    .portal-mobile-bottom-nav a.active {
        color: var(--mc-gold);
    }

    .mobile-bottom-nav a.active::after,
    .club-mobile-bottom-nav a.active::after,
    .portal-mobile-bottom-nav a.active::after {
        content: '';
        position: absolute;
        bottom: 3px;
        width: 14px;
        height: 3px;
        background: var(--mc-gold);
        border-radius: 3px;
        box-shadow: 0 0 8px rgba(229, 169, 59, 0.7);
    }

    .mobile-bottom-nav a:active,
    .club-mobile-bottom-nav a:active,
    .portal-mobile-bottom-nav a:active {
        transform: scale(0.9);
    }
}

/* Compensação de Espaço Inferior no Site e Loja para não encobrir conteúdo */
@media (max-width: 991.98px) {
    .has-club-bottom-nav {
        padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 20px) !important;
    }
    footer.py-5 {
        padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 40px) !important;
    }
}

/* ==========================================================================
   4. Modais como "Bottom Sheets" Nativos no Mobile (UX Posicional)
   ========================================================================== */
@media (max-width: 767.98px) {
    .modal.fade .modal-dialog {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        transform: translate3d(0, 100%, 0) !important;
        transition: transform 0.28s cubic-bezier(0.1, 0.9, 0.2, 1) !important;
    }

    .modal.show .modal-dialog {
        transform: translate3d(0, 0, 0) !important;
    }

    .modal-content {
        border-radius: 24px 24px 0 0 !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        border-bottom: none !important;
        background-color: #141720 !important;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.8) !important;
        padding-bottom: calc(var(--safe-bottom) + 12px) !important;
    }

    /* Alça de Arraste Visual de App (Bottom Sheet Handle) */
    .modal-content::before {
        content: '';
        display: block;
        width: 44px;
        height: 5px;
        background: rgba(255, 255, 255, 0.28);
        border-radius: 4px;
        margin: 10px auto 4px auto;
        flex-shrink: 0;
    }

    .modal-header {
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        padding: 12px 18px !important;
    }

    .modal-body {
        padding: 18px !important;
    }

    .modal-footer {
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        padding: 14px 18px !important;
        flex-direction: column-reverse;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
        min-height: var(--mc-touch-comfortable);
        margin: 0 !important;
    }
}

/* ==========================================================================
   5. Loja Virtual & Carrinho Mobile (Sticky Bottom Bar & App Flow)
   ========================================================================== */
/* Barra Flutuante de Carrinho na Loja (Sticky Bottom Cart Pill) */
.floating-cart-pill {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 12px);
    left: 14px;
    right: 14px;
    z-index: 1025;
    background: linear-gradient(135deg, #1b202a 0%, #11141b 100%);
    border: 1.5px solid var(--mc-gold);
    border-radius: 16px;
    padding: 12px 18px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.65), 0 0 12px rgba(229, 169, 59, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideUpPill 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

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

/* Barra Fixa de Finalização de Compra no Carrinho (Zona do Polegar) */
.cart-sticky-checkout-bar {
    display: none;
}

@media (max-width: 991.98px) {
    .cart-sticky-checkout-bar {
        display: flex;
        position: fixed;
        bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
        left: 0;
        right: 0;
        background: rgba(18, 22, 30, 0.96);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid rgba(229, 169, 59, 0.4);
        padding: 12px 16px;
        z-index: 1028;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.5);
    }
}

/* Cartões Mobile de Itens do Carrinho */
.cart-mobile-item-card {
    background: var(--mc-card);
    border: 1px solid var(--mc-border);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
}

/* Stepper de Quantidade com Toque Ergonômico */
.touch-stepper {
    display: inline-flex;
    align-items: center;
    background: #090a0d;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    overflow: hidden;
}

.touch-stepper-btn {
    width: 38px;
    height: 38px;
    background: transparent;
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    touch-action: manipulation;
}

.touch-stepper-btn:active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--mc-gold);
}

.touch-stepper-input {
    width: 38px;
    text-align: center;
    background: transparent;
    border: none;
    color: #fff;
    font-weight: bold;
    font-size: 0.95rem;
}

/* ==========================================================================
   6. Cards Responsivos e Tabelas Adaptativas (Mobile-Card Views)
   ========================================================================== */
.card-panel, .card-admin, .card-custom, .club-card {
    background-color: var(--mc-card);
    border: 1px solid var(--mc-border);
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

/* Cartões de Membros da Equipe no Mobile */
.mobile-user-card {
    background: #141720;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
}

/* Grid de Métricas 2x2 no Mobile */
@media (max-width: 767.98px) {
    .row-metrics-app > [class*="col-"] {
        flex: 0 0 auto !important;
        width: 50% !important;
    }
    .row-metrics-app .card {
        padding: 12px !important;
    }
    .row-metrics-app .metric-big {
        font-size: 1.45rem !important;
        margin: 2px 0 !important;
    }
    .row-metrics-app small {
        font-size: 0.72rem !important;
    }
}

/* ==========================================================================
   7. Offcanvas Mobile Drawer Nativo
   ========================================================================== */
.offcanvas.offcanvas-app-drawer {
    background: #10131a !important;
    color: #f1f3f5 !important;
    border-left: 1px solid var(--mc-border) !important;
    padding-bottom: var(--safe-bottom);
}

.offcanvas-app-drawer .nav-link {
    color: #cbd5e1 !important;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 12px 16px;
    border-radius: 10px;
    min-height: var(--mc-touch-comfortable);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.offcanvas-app-drawer .nav-link:hover,
.offcanvas-app-drawer .nav-link:active {
    background: rgba(255, 255, 255, 0.06);
    color: var(--mc-gold) !important;
}

.offcanvas-app-drawer .nav-link i {
    font-size: 1.25rem;
    width: 26px;
    text-align: center;
}

/* Logotipos Inteligentes e Preservação de Aspect Ratio */
.club-logo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, rgba(0,0,0,0.5) 100%);
    border: 1.5px solid var(--mc-gold);
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.club-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    padding: 2px;
}
