/* =====================================================
   Variables
   ===================================================== */
:root {
    --topbar-height:   56px;
    --sidebar-width:   230px;
    --sidebar-collapsed-width: 58px;
    --sidebar-bg:      #1a1d23;
    --sidebar-hover:   #2a2f3a;
    --sidebar-active:  #0d6efd;
    --topbar-bg:       #111318;
    --content-bg:
    --transition:      0.22s ease;
}

/* =====================================================
   Reset / Base
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-size: 15px;
}

body.app-body {
    background: var(--content-bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* =====================================================
   Topbar
   ===================================================== */
.app-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 .75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.app-topbar .navbar-brand {
    font-size: 1.15rem;
    letter-spacing: .02em;
    color: #fff !important;
    text-decoration: none;
}

.sidebar-toggle {
    padding: 4px 8px;
    color: #fff !important;
    text-decoration: none;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.1); border-radius: 6px; }

/* =====================================================
   App Wrapper (sidebar + content)
   ===================================================== */
.app-wrapper {
    display: flex;
    margin-top: var(--topbar-height);
    flex: 1 1 auto;
}

/* Layout sin sidebar para usuarios no autenticados */
.app-wrapper.no-sidebar {
    display: block;
    padding-bottom: 0;
}

.app-wrapper.no-sidebar .app-content {
    margin-left: 0;
    max-width: 100%;
    padding: 2rem;
    padding-bottom: 0;
}

/* =====================================================
   Sidebar
   ===================================================== */
.app-sidebar {
    width: var(--sidebar-width);
    min-height: 100%;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: width var(--transition);
    overflow: hidden;
    flex-shrink: 0;
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    z-index: 1020;
}

/* Collapsed sidebar */
.app-sidebar.sidebar-collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Section labels */
.sidebar-section-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6c757d;
    padding: .45rem 1rem .1rem;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition);
}
.app-sidebar.sidebar-collapsed .sidebar-section-label {
    opacity: 0;
}

/* Nav links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem 1rem;
    color: #adb5bd !important;
    white-space: nowrap;
    border-radius: 6px;
    margin: 2px 6px;
    transition: background var(--transition), color var(--transition);
}
.sidebar-link i {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}
.sidebar-link:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #4f46e5 !important;
}
.sidebar-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: #4f46e5 !important;
}

/* Hide text labels when collapsed */
.app-sidebar.sidebar-collapsed .sidebar-label {
    display: none;
}

/* Sidebar footer */
.sidebar-footer {
    margin-top: auto;
    padding: .75rem 1rem;
    border-top: 1px solid #2a2f3a;
    white-space: nowrap;
    overflow: hidden;
}
.app-sidebar.sidebar-collapsed .sidebar-footer span {
    display: none;
}

/* Sidebar nav scroll */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #3a3f4a; border-radius: 4px; }

/* =====================================================
   Main Content
   ===================================================== */
.app-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 1.75rem 2rem 2rem;
    transition: margin-left var(--transition);
    min-width: 0;
}

.app-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* =====================================================
   Footer
   ===================================================== */
.app-footer {
    background: var(--topbar-bg);
    color: #6c757d;
    font-size: .8rem;
    padding: 1.5rem 2rem;
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    width: 100%;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-copyright {
    text-align: center;
    font-weight: 500;
    color: #495057;
}

.footer-disclaimer {
    background: rgba(13, 110, 253, 0.05);
    border-left: 3px solid #0d6efd;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.6;
}

.footer-disclaimer p {
    color: #495057;
}

.footer-disclaimer a {
    color: #0d6efd;
    font-weight: 500;
    transition: color 0.2s;
}

.footer-disclaimer a:hover {
    color: #0a58ca;
    text-decoration: underline !important;
}

.footer-disclaimer i.bi {
    color: #0d6efd;
    opacity: 0.8;
}

@media (min-width: 768px) {
    .footer-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .footer-disclaimer {
        flex: 1;
        max-width: 800px;
    }
}

/* =====================================================
   Responsive: en móvil el sidebar se superpone
   ===================================================== */
@media (max-width: 768px) {
    .app-sidebar {
        width: var(--sidebar-collapsed-width);
    }
    .app-content {
        margin-left: var(--sidebar-collapsed-width);
        padding: 1rem;
    }
    .app-sidebar.sidebar-collapsed {
        width: 0;
    }
    .app-content.sidebar-collapsed {
        margin-left: 0;
    }
}

/* =====================================================
   Utilidades de página
   ===================================================== */
.page-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: #212529;
}

.stat-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,.08);
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,.13);
}
.stat-card .card-body {
    padding: 1.25rem 1rem;
}
.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}
.stat-card .stat-label {
    font-size: .82rem;
    color: #6c757d;
    margin-top: .25rem;
}

.section-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,.07);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}
.section-card h2,
.section-card h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #343a40;
}

/* Focus ring override */
.btn:focus, .btn:active:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}
}