/* Estructura Principal y Layout 5S MoliShop (Claro & Obscuro · 100% Responsivo Móvil, Tablet y PC) */
.app-header {
    height: 60px;
    width: 100%;
    max-width: 100vw;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-sizing: border-box;
    overflow: hidden;
}

.header-left-group,
.header-right-group,
.header-actions-cluster {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.header-user-meta {
    text-align: right;
    line-height: 1.25;
    white-space: nowrap;
}

.header-geo-pill {
    text-decoration: none;
    min-height: 34px;
    padding: 0 11px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap !important;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-geo-pill #headerGeoPillText {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-quick-btn {
    min-height: 36px;
    padding: 0 11px;
    white-space: nowrap !important;
    flex-shrink: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    min-width: 0;
}

.brand-logo-img {
    height: 30px;
    width: auto;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

/* Conmutación automática del logotipo oficial MoliShop según el tema */
[data-theme="light"] .brand-logo-dark {
    display: none !important;
}
:root:not([data-theme="light"]) .brand-logo-light,
[data-theme="dark"] .brand-logo-light {
    display: none !important;
}

.brand-erp-pill {
    background: var(--color-marca-bg);
    color: var(--brand-text);
    border: 1px solid var(--brand-border);
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.app-wrapper {
    display: flex;
    min-height: calc(100vh - 60px);
    width: 100%;
    max-width: 100%;
}

/* Sidebar Corporativo MoliShop */
.app-sidebar {
    width: 248px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-shrink: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease, left 0.25s ease;
}

.sidebar-category {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.85rem 0.75rem 0.3rem;
    font-weight: 700;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: all 0.16s ease;
}

.sidebar-link svg,
.sidebar-link i {
    color: var(--text-muted);
    transition: color 0.16s ease;
}

.sidebar-link:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.sidebar-link:hover svg,
.sidebar-link:hover i {
    color: var(--color-marca);
}

.sidebar-link.active {
    background: var(--color-marca-bg);
    color: var(--brand-text);
    border-left-color: var(--color-marca);
    font-weight: 600;
}

.sidebar-link.active svg,
.sidebar-link.active i {
    color: var(--color-marca) !important;
}

/* Contenido Principal */
.app-content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 1.75rem;
    background: var(--bg-primary);
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100%;
}

/* Encabezado Estándar de Módulo 5S */
.page-header,
.module-header-5s {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.module-title-group {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.module-icon-box {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--color-marca-bg);
    border: 1px solid var(--brand-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-marca);
    flex-shrink: 0;
}

.module-actions-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.45rem;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Grid de Métricas KPI */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.metric-card {
    padding: 1.15rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--color-marca);
}

.metric-card.profit::before { background: var(--success); }
.metric-card.cost::before { background: var(--warning); }
.metric-card.stock::before { background: var(--color-marca); }

.metric-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
}

.metric-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
}

.metric-detail {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Botón Conmutador de Tema Claro / Obscuro */
.theme-toggle-btn {
    min-height: 36px;
    padding: 0 11px;
    font-size: 12px;
    gap: 6px;
    white-space: nowrap !important;
    flex-shrink: 0;
}

/* Backdrop y Encabezado Móvil del Menú Lateral + Barra Inferior de Navegación Móvil */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(2px);
    z-index: 998;
}
.sidebar-backdrop.active {
    display: block;
}

.sidebar-mobile-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem 0.75rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-header);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    z-index: 995;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    padding: 0 4px;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.14);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10.5px;
    font-weight: 600;
    background: transparent;
    border: none;
    border-top: 2px solid transparent;
    cursor: pointer;
    font-family: inherit;
    padding: 4px 2px;
    min-width: 0;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.mobile-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mobile-nav-item.active,
.mobile-nav-item:hover {
    color: var(--brand-text);
    border-top-color: var(--color-marca);
    background: var(--color-marca-bg);
}

.mobile-nav-item.active svg,
.mobile-nav-item:hover svg {
    color: var(--color-marca);
}

@media (max-width: 1024px) {
    .header-user-meta {
        display: none;
    }
    .header-geo-pill {
        max-width: 155px;
    }
}

@media (max-width: 900px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -280px;
        width: 268px;
        max-width: 84vw;
        z-index: 1005;
        box-shadow: var(--shadow-lg);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2rem;
    }
    .app-sidebar.open {
        left: 0;
    }
    .sidebar-mobile-head {
        display: flex;
    }
    .mobile-bottom-nav {
        display: grid;
    }
    .app-content {
        padding: 0.95rem 0.85rem 5rem;
    }
}

@media (max-width: 768px) {
    .header-theme-label {
        display: none !important;
    }
    .theme-toggle-btn {
        width: 34px;
        min-width: 34px;
        min-height: 34px;
        padding: 0 !important;
        justify-content: center;
    }
}

@media (max-width: 680px) {
    .app-header {
        height: 54px;
        padding: 0 0.65rem;
        gap: 0.35rem;
    }
    .header-left-group,
    .header-right-group,
    .header-actions-cluster {
        gap: 0.35rem;
    }
    .brand-logo-img {
        height: 24px;
    }
    .brand-erp-pill {
        display: none;
    }
    .header-btn-label {
        display: none;
    }
    .header-quick-btn {
        padding: 0;
        width: 34px;
        min-width: 34px;
        min-height: 34px;
    }
    .header-geo-pill {
        min-height: 32px;
        padding: 0 8px;
        font-size: 10.5px;
        max-width: 112px;
    }
    .page-header,
    .module-header-5s {
        gap: 0.65rem;
        margin-bottom: 0.95rem;
    }
    .page-title {
        font-size: 1.15rem;
        word-break: break-word;
    }
    .page-subtitle {
        font-size: 11.5px;
    }
    .module-actions-bar {
        width: 100%;
        gap: 0.45rem;
    }
    .module-actions-bar > .btn {
        flex: 1 1 auto;
    }
}

@media (max-width: 400px) {
    .header-geo-pill {
        max-width: 86px;
    }
}
