/* ============================================================
   LAYOUT — Sidebar fija oscura + shell de contenido principal.
   Estructural únicamente; el look de los componentes vive en
   theme.css.
   ============================================================ */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------------------------------------------------------- */
/* Sidebar                                                     */
/* ---------------------------------------------------------- */
.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
    transition: width .18s ease;
}
.app-sidebar.colapsado { width: var(--sidebar-width-mini); }

.sidebar-marca {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-5);
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 32px;
}
.sidebar-marca .logo-punto {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}
.sidebar-marca .texto-marca {
    font-weight: 700;
    color: #fff;
    font-size: 14.5px;
    white-space: nowrap;
    overflow: hidden;
}
.app-sidebar.colapsado .texto-marca,
.app-sidebar.colapsado .sidebar-seccion-titulo,
.app-sidebar.colapsado .nav-lateral a span {
    display: none;
}

.sidebar-nav { flex: 1; padding: var(--space-4) var(--space-3); overflow-y: auto; }
.sidebar-seccion-titulo {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #5B6B8C;
    padding: var(--space-4) var(--space-3) var(--space-2);
    font-weight: 700;
}

.nav-lateral { list-style: none; margin: 0; padding: 0; }
.nav-lateral li { margin-bottom: 2px; }
.nav-lateral a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    position: relative;
    transition: background .15s ease, color .15s ease;
}
.nav-lateral a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-lateral a:hover { background: var(--sidebar-bg-elevated); color: #fff; }

.nav-lateral a.activo {
    background: var(--sidebar-bg-elevated);
    color: var(--sidebar-text-active);
}
.nav-lateral a.activo::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: var(--radius-full);
    background: var(--sidebar-accent);
}
.app-sidebar.colapsado .nav-lateral a { justify-content: center; }
.app-sidebar.colapsado .nav-lateral a.activo::before { left: 0; }
.app-sidebar.colapsado .badge-nav { display: none; }

.badge-nav {
    margin-left: auto;
    background: var(--accent-orange);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    font-family: var(--font-mono);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-pie {
    padding: var(--space-4) var(--space-3);
    border-top: 1px solid var(--sidebar-border);
}
.btn-colapsar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    background: var(--sidebar-bg-elevated);
    border: none;
    color: var(--sidebar-text);
    padding: 9px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}
.btn-colapsar:hover { color: #fff; }
.btn-colapsar svg { width: 16px; height: 16px; transition: transform .18s ease; }
.app-sidebar.colapsado .btn-colapsar svg { transform: rotate(180deg); }
.app-sidebar.colapsado .btn-colapsar span { display: none; }

/* ---------------------------------------------------------- */
/* Contenido principal                                         */
/* ---------------------------------------------------------- */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    transition: margin-left .18s ease;
}
.app-sidebar.colapsado ~ .app-main { margin-left: var(--sidebar-width-mini); }

/* ---------------------------------------------------------- */
/* Topbar ejecutiva global (fija, 56px, igual en todo el sistema) */
/* ---------------------------------------------------------- */
.topbar-ejecutiva-global {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 30;
}

.buscador-global {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    width: 280px;
    color: var(--color-text-subtle);
    cursor: pointer;
    transition: border-color 150ms ease;
}
.buscador-global:hover, .buscador-global:focus-within { border-color: var(--color-accent); }
.buscador-global svg { width: 15px; height: 15px; flex-shrink: 0; }
.buscador-global input {
    border: none;
    background: none;
    font-family: var(--font-sans);
    font-size: 12.5px;
    flex: 1;
    color: var(--color-text);
    min-width: 0;
}
.buscador-global input:focus { outline: none; }
.buscador-global input::placeholder { color: var(--color-text-subtle); }
.atajo-teclado {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--color-text-subtle);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    padding: 1px 6px;
    flex-shrink: 0;
}

.topbar-spacer { flex: 1; }

.widget-tc {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--color-success-soft);
    border: 1px solid var(--color-success-border);
    border-radius: var(--radius-full);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-success-text);
    font-family: var(--font-mono);
    white-space: nowrap;
}
.widget-tc .punto-vivo {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, .6);
    animation: pulso-suave 2s infinite;
    flex-shrink: 0;
}

.reloj-topbar {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-text-muted);
    text-align: right;
    line-height: 1.25;
    white-space: nowrap;
}
.reloj-topbar .hora-reloj { font-weight: 700; color: var(--color-text); display: block; }
.reloj-topbar .fecha-reloj { font-size: 10.5px; text-transform: capitalize; }

.btn-notificaciones {
    position: relative;
    border: none;
    background: none;
    color: var(--color-text-muted);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-notificaciones:hover { background: var(--color-surface-alt); color: var(--color-text); }
.btn-notificaciones svg { width: 18px; height: 18px; }
.punto-pulso-notif {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-danger);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, .7);
    animation: pulso-notif 1.8s infinite;
}
@keyframes pulso-suave {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); }
    70%  { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
@keyframes pulso-notif {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, .55); }
    70%  { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.perfil-topbar {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-left: var(--space-4);
    border-left: 1px solid var(--color-border-soft);
    flex-shrink: 0;
}
.perfil-topbar .avatar-perfil {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #4338CA);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.perfil-topbar .status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--color-success);
    border: 2px solid var(--color-surface);
}
.perfil-topbar .texto-perfil { line-height: 1.25; }
.perfil-topbar .nombre-perfil { font-size: 12px; font-weight: 700; color: var(--color-text); }
.perfil-topbar .rol-perfil { font-size: 10.5px; color: var(--color-text-subtle); }

@media (max-width: 1100px) {
    .buscador-global { width: 200px; }
    .widget-tc, .reloj-topbar { display: none; }
}
@media (max-width: 800px) {
    .buscador-global { display: none; }
}

/* ---------------------------------------------------------- */
/* Topbar de página (título + subtítulo + acciones contextuales) */
/* ---------------------------------------------------------- */
.app-topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-5) var(--space-7);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    position: sticky;
    top: var(--topbar-height);
    z-index: 20;
}
.app-topbar h1 { font-size: 19px; }
.app-topbar .subtitulo-pagina { font-size: 12.5px; color: var(--color-text-muted); margin-top: 2px; font-weight: 500; }
.app-topbar .acciones-topbar { display: flex; align-items: center; gap: var(--space-3); }

.app-contenido {
    padding: var(--space-7);
    max-width: 1320px;
}

@media (max-width: 960px) {
    .app-sidebar { width: var(--sidebar-width-mini); }
    .app-sidebar .texto-marca,
    .app-sidebar .sidebar-seccion-titulo,
    .app-sidebar .nav-lateral a span,
    .app-sidebar .btn-colapsar span { display: none; }
    .app-sidebar .nav-lateral a { justify-content: center; }
    .app-main { margin-left: var(--sidebar-width-mini); }
    .app-topbar { padding: var(--space-4); }
    .app-contenido { padding: var(--space-4); }
}
