/* app.css — Layout, Sidebar, Topbar, Responsive */
@import url('theme.css');
@import url('components.css');
@import url('tables.css');
@import url('forms.css');
@import url('dashboard.css');
@import url('operaciones.css');

/* ─── Layout Wrapper ──────────────────── */
#wrapper {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Sidebar ──────────────────────────── */
#sidebar-wrapper {
    width: var(--sidebar-width);
    height: 100vh;
    max-height: 100vh;
    background: var(--erp-surface);
    border-right: 1px solid var(--erp-border);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.sidebar-heading,
.sidebar-header {
    flex: 0 0 auto;
}

.sidebar-menu,
#sidebar-wrapper .list-group {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0.75rem 2rem;
    -webkit-overflow-scrolling: touch;
}

.sidebar-footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--erp-border);
    padding: 1rem;
}

.sidebar-menu::-webkit-scrollbar,
#sidebar-wrapper .list-group::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-thumb,
#sidebar-wrapper .list-group::-webkit-scrollbar-thumb {
    background: rgba(123, 132, 151, 0.35);
    border-radius: 999px;
}

/* Sidebar Brand */
.sidebar-heading {
    padding: 1.5rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border-bottom: 1px solid var(--erp-border);
    margin-bottom: 0.5rem;
}
.sidebar-heading .brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--erp-primary) 0%, #8b7dfa 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.sidebar-heading .brand-text {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--erp-text);
}

/* Sidebar Section Labels */
.sidebar-section {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--erp-muted);
    padding: 1.25rem 1.5rem 0.5rem;
}

/* Sidebar Nav Items */
.list-group-flush {
    padding: 0 0.75rem;
}
.list-group-item {
    border: none;
    padding: 0.6rem 1rem;
    color: var(--erp-text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--erp-transition);
    margin: 2px 0;
    border-radius: var(--erp-radius-xs);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: transparent;
}
.list-group-item i, .list-group-item .bi {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    opacity: 0.7;
    flex-shrink: 0;
}
.list-group-item:hover, .list-group-item:focus {
    background: var(--erp-primary-soft);
    color: var(--erp-primary);
    text-decoration: none;
}
.list-group-item:hover i, .list-group-item:hover .bi,
.list-group-item:focus i, .list-group-item:focus .bi {
    opacity: 1;
}
.list-group-item.active {
    background: var(--erp-primary-soft);
    color: var(--erp-primary);
    font-weight: 600;
}
.list-group-item.active i, .list-group-item.active .bi {
    opacity: 1;
    color: var(--erp-primary);
}

/* ─── Page Content ─────────────────────── */
#page-content-wrapper {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    background: var(--erp-bg);
    display: flex;
    flex-direction: column;
}

/* ─── Topbar ───────────────────────────── */
.topbar {
    background: var(--erp-surface);
    border-bottom: 1px solid var(--erp-border);
    box-shadow: 0 1px 4px rgba(47,55,90,0.03);
    height: 64px;
    padding: 0 1.75rem;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 500;
}
.topbar h5 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
}
.topbar .user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--erp-primary) 0%, #8b7dfa 100%);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ─── Content Area ─────────────────────── */
.container-fluid {
    flex: 1;
}

/* ─── Mobile Toggle ────────────────────── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--erp-text);
    cursor: pointer;
    padding: 0.25rem;
}

/* ─── Responsive ───────────────────────── */
@media (max-width: 991.98px) {
    #sidebar-wrapper {
        transform: translateX(-100%);
        width: min(86vw, 320px);
        box-shadow: var(--erp-shadow-lg);
    }
    #sidebar-wrapper.show {
        transform: translateX(0);
    }
    #page-content-wrapper {
        margin-left: 0;
        width: 100%;
    }
    .sidebar-toggle {
        display: inline-flex;
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(37, 43, 58, 0.35);
        backdrop-filter: blur(2px);
        z-index: 900;
        opacity: 0;
        visibility: hidden;
        transition: all 0.25s ease;
    }
    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }
    body.sidebar-open {
        overflow: hidden;
    }
}

.table-responsive {
    border-radius: var(--erp-radius-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 576px) {
    .topbar { padding: 0 1rem; height: 60px; }
    .topbar h5 { font-size: 0.95rem; }
    .topbar-title small,
    .user-avatar + span { display: none !important; }
    .container-fluid { padding-left: 1rem !important; padding-right: 1rem !important; }
    .card-body { padding: 1rem; }
    .hero-card { padding: 1.5rem; }
    .stat-card { padding: 1.25rem; margin-bottom: 1rem; }
    .form-actions,
    .page-actions { display: grid; gap: 0.75rem; }
    .form-actions .btn,
    .page-actions .btn { width: 100%; }
    .quick-actions-grid { grid-template-columns: 1fr; }
    .chart-container { height: 260px !important; }
}
