/* ================================
   LAYOUT GENERAL
   ================================ */

:root {
    /* Altura base del header (desktop) */
    --header-height: 64px;
}

/* Contenedor global */
.app-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden; /* evita scroll horizontal cuando el contenido se desplaza */
}

/* ================================
   HEADER SUPERIOR
   ================================ */

.app-header {
    min-height: var(--header-height);
    padding: 0.8rem 1rem 1rem; /* un poco de aire abajo pero sin exagerar */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 0.8rem; /* más separación entre “Sesión” y el botón */
}

/* Botón hamburguesa */
.menu-toggle {
    border: none;
    background: rgba(255,255,255,0.9);
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(0,0,0,0.08);
    cursor: pointer;
    font-size: 1.1rem;
}

/* ================================
   CONTENIDO PRINCIPAL
   ================================ */

.app-shell {
    display: flex;
    width: 100%;
    transform: translateX(0);
    transition: transform .3s ease;
}

/* Cuando el menú se abre, el contenido se mueve a la izquierda */
.app-shell.shift-left {
    transform: translateX(-240px);
}

.app-main {
    flex: 1;
    padding: 1rem 1.2rem 2rem;
}

/* Animación suave al cargar cada vista */
.app-content {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeSlideIn .35s ease forwards;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================
   SIDEBAR (OFFCANVAS DERECHA)
   ================================ */

.app-sidebar {
    width: 240px;
    background: rgba(255, 255, 255, 0.98);
    border-left: 1px solid var(--border-soft);
    padding: 0.75rem 0.5rem 1rem;
    position: fixed;
    top: var(--header-height); /* alineado con el header */
    right: 0;
    height: calc(100vh - var(--header-height));
    transform: translateX(100%);
    transition: transform .3s ease;
    z-index: 30;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

/* Sidebar visible */
.app-sidebar.open {
    transform: translateX(0);
}

/* Overlay oscuro suave detrás del sidebar */
.app-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.06);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
    z-index: 20;
}

.app-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Contenido interno del sidebar */
.app-sidebar-inner {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.sidebar-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 0.6rem 0.4rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.6rem;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.8rem;
    color: var(--text-main);
}

.sidebar-link span.icon {
    font-size: 1rem;
}

.sidebar-link.active {
    background: var(--peach-soft);
    color: var(--peach-accent);
    font-weight: 600;
}

/* ================================
   LOGIN
   ================================ */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: rgba(255,255,255,0.96);
    border-radius: 20px;
    padding: 1.4rem 1.3rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-soft);
}

.alert-error {
    background: #ffe0e0;
    color: #b03030;
    border-radius: 10px;
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
    margin-bottom: 0.6rem;
}

/* ================================
   RESPONSIVE
   ================================ */

/* Pantallas grandes: un poco más de aire */
@media (min-width: 768px) {
    .app-shell {
        min-height: calc(100vh - var(--header-height));
    }

    .app-main {
        padding: 1rem 1.5rem 2rem;
    }
}

/* Ajustes específicos para móvil (iPhone / Android) */
@media (max-width: 600px) {
    :root {
        --header-height: 72px; /* un poquito más alto en móvil */
    }

    .app-header {
        padding: 0.9rem 1rem 1rem;
    }

    .app-header-right {
        gap: 1rem; /* más separación entre texto y hamburguesa */
    }

    .menu-toggle {
        margin-left: 0.3rem; /* evita que se pegue al texto del usuario */
    }
}

/* ================================
   TABLAS GENERALES (para otras secciones)
   ================================ */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-minimal {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.table-minimal td,
.table-minimal th {
    padding: 0.55rem 0.4rem;
    vertical-align: top;
}

@media (max-width: 600px) {
    .table-minimal td,
    .table-minimal th {
        padding: 0.45rem 0.3rem;
        font-size: 0.75rem;
        line-height: 1.1rem;
        word-break: break-word;
    }
}

/* ================================
   TARJETAS DE VENTAS (todas las resoluciones)
   ================================ */

.venta-card {
    display: block;
    background: #ffffff;
    border-radius: 14px;
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    border: 1px solid var(--border-soft);
    font-size: 0.92rem;
    animation: fadeSlideIn .3s ease;
}

.venta-line {
    margin-bottom: 0.35rem;
    line-height: 1.28;
}

.venta-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.venta-actions {
    margin-top: 0.4rem;
    font-size: 0.80rem;
}

.venta-actions a {
    color: #2980b9;
    margin-right: 0.6rem;
    text-decoration: none;
}

.venta-actions a:last-child {
    color: #c0392b;
}

/* ================================
   UTILIDADES
   ================================ */

/* Números negativos en rojo automáticamente */
.card-value.negative,
.negative,
.negative-value {
    color: #e63946;
}
