/* ==========================================================================
   STAMPASS DESIGN SYSTEM - CORE DESKTOP-FIRST & RESPONSIVO
   ========================================================================== */

:root {
    --stampass-primaria: #2B8158;
    --stampass-secundaria: #FF5522;
    --stampass-fundo: #F8FAFC;
    --stampass-texto: #111111;
    --sidebar-largura: 260px;
    --header-altura: 70px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body.sp-pwa-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--stampass-fundo);
    color: var(--stampass-texto);
    min-height: 100vh;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Container Estrutural Padrão */
.sp-app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Header Fixo / Top Bar */
.sp-header {
    height: var(--header-altura);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid #E5E7EB;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.sp-logo-container {
    display: flex;
    align-items: center;
}

.sp-logo-img {
    height: 38px;
    max-height: 40px;
    width: auto;
    object-fit: contain;
}

.sp-badge-icon {
    height: 42px;
    width: 42px;
    max-width: 42px;
    max-height: 42px;
    object-fit: contain;
}

.sp-sidebar {
    display: none;
}

/* Conteúdo Principal Ampliado (Desktop-First) */
.sp-main-content {
    flex: 1;
    padding: 32px 40px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* Grids Gerais */
.sp-circuit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    width: 100%;
}

.sp-categories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
    width: 100%;
}

.sp-bottom-nav {
    display: none;
}

.sp-footer-branding {
    text-align: center;
    padding: 20px 0 80px 0;
    font-size: 0.75rem;
    color: #9CA3AF;
    width: 100%;
}

.sp-footer-branding a {
    color: #6B7280;
    text-decoration: underline;
}

/* ==========================================================================
   LAYOUT DESKTOP COM SIDEBAR (@media min-width: 992px)
   ========================================================================== */
@media (min-width: 992px) {
    .sp-app-container.has-sidebar {
        display: grid;
        grid-template-columns: var(--sidebar-largura) 1fr;
        grid-template-rows: var(--header-altura) 1fr auto;
        grid-template-areas:
            "sidebar header"
            "sidebar main"
            "sidebar footer";
    }

    .sp-app-container.has-sidebar .sp-header {
        grid-area: header;
        padding: 0 32px;
    }

    .sp-app-container.has-sidebar .sp-sidebar {
        display: flex;
        flex-direction: column;
        grid-area: sidebar;
        background: #ffffff;
        border-right: 1px solid #E5E7EB;
        position: fixed;
        top: 0;
        bottom: 0;
        width: var(--sidebar-largura);
        padding: 24px 16px;
        z-index: 101;
    }

    .sp-sidebar-brand {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 32px;
    }

    .sp-sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .sp-sidebar-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        border-radius: 10px;
        color: #4B5563;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.2s ease;
    }

    .sp-sidebar-link:hover, 
    .sp-sidebar-link.active {
        background-color: #F1F5F9;
        color: var(--stampass-primaria);
    }

    .sp-app-container.has-sidebar .sp-main-content {
        grid-area: main;
    }

    .sp-app-container.has-sidebar .sp-footer-branding {
        grid-area: footer;
        padding: 20px 0;
    }
}

/* ==========================================================================
   ADAPTAÇÕES RESPONSIVAS MOBILE (QUEBRA DE MARGEM CORRIGIDA)
   ========================================================================== */
@media (max-width: 991px) {
    .sp-app-container.has-sidebar {
        display: flex;
        flex-direction: column;
    }

    .sp-sidebar {
        display: none !important;
    }

    .sp-header {
        padding: 0 16px;
    }

    .sp-main-content {
        padding: 16px 16px 80px 16px;
    }

    .sp-categories-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .sp-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 65px;
        background: #ffffff;
        display: flex;
        justify-content: space-around;
        align-items: center;
        border-top: 1px solid #E5E7EB;
        z-index: 99;
    }

    .sp-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: #6B7280;
        text-decoration: none;
        font-size: 0.75rem;
        font-weight: 600;
    }

    .sp-nav-item.active {
        color: var(--stampass-secundaria);
    }
}

@media (max-width: 480px) {
    .sp-categories-grid {
        grid-template-columns: 1fr;
    }
}