/* ============================================================
   flib · App CSS
   ============================================================ */

/* ── Variables ─────────────────────────────────────────── */
:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1a1f2e;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: rgba(255,255,255,0.14);
    --brand-primary: #0d6efd;
}

/* ── Layout principal ──────────────────────────────────── */
#wrapper {
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    transition: width 0.25s ease;
    overflow-x: hidden;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1000;
}

.sidebar.collapsed {
    width: 64px;
    min-width: 64px;
}

.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-footer .overflow-hidden,
.sidebar.collapsed .sidebar-footer .btn span {
    display: none;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.70);
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
    padding: 0.55rem 1rem;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
    border-left: 3px solid var(--brand-primary);
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

/* ── Sidebar footer ────────────────────────────────────── */
.sidebar-footer {
    margin-top: auto;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Page content ──────────────────────────────────────── */
#page-content-wrapper {
    overflow-x: hidden;
}

/* ── Login page ────────────────────────────────────────── */
.login-body {
    background: linear-gradient(135deg, #1a1f2e 0%, #2d3561 100%);
}

.login-card {
    border-radius: 16px;
    background: #fff;
}

.login-logo {
    filter: drop-shadow(0 4px 12px rgba(13,110,253,0.3));
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
    border-radius: 12px;
}

/* ── Tables ────────────────────────────────────────────── */
.table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* ── Catalog items ─────────────────────────────────────── */
.catalog-item {
    cursor: pointer;
    transition: background 0.12s;
}

.catalog-item:hover {
    background-color: #e8f0fe !important;
}

/* ── Footer ────────────────────────────────────────────── */
.footer-app {
    font-size: 0.78rem;
}

/* ── Utility ───────────────────────────────────────────── */
.xsmall {
    font-size: 0.7rem;
}

/* ── Módulo ventas ─────────────────────────────────────── */
.catalog-scroll {
    max-height: 520px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.catalog-item {
    cursor: default;
}

.catalog-item .lh-sm {
    line-height: 1.3;
    word-break: break-word;
}

.qty-badge {
    min-width: 28px;
    font-size: 0.8rem;
}

.cart-items-scroll {
    max-height: 320px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.cart-item {
    transition: background 0.1s;
}

.qty-group {
    width: 120px;
    flex-shrink: 0;
}

.qty-input {
    max-width: 48px;
    min-width: 0;
    padding-left: 4px;
    padding-right: 4px;
}

.desc-group {
    width: 90px;
    flex-shrink: 0;
}

/* Tabs de venta */
.sale-tabs .nav-link {
    border-radius: 8px;
    color: #495057;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
}
.sale-tabs .nav-link.active {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

/* Barra inferior fija móvil */
.sale-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 2px solid #dee2e6;
    padding: 10px 16px;
    z-index: 1040;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
}

/* ── Responsive: sidebar collapses on mobile ───────────── */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        left: -260px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.25s ease;
    }
    .sidebar.show {
        left: 0;
    }
    #page-content-wrapper {
        width: 100%;
    }

    /* Ventas móvil */
    main.flex-grow-1 {
        padding-bottom: 80px !important; /* espacio para barra inferior */
    }

    .catalog-scroll {
        max-height: calc(100dvh - 280px);
    }

    .cart-items-scroll {
        max-height: calc(100dvh - 320px);
    }

    /* Botones más grandes para toque */
    .btn-agregar,
    .btn-quitar-cat {
        min-width: 40px;
        min-height: 40px;
        font-size: 1rem;
    }

    .qty-group .btn,
    .desc-group .btn {
        min-width: 36px;
        min-height: 36px;
    }

    /* Evitar overflow horizontal del catálogo */
    #listaCatalogo {
        width: 100%;
        overflow-x: hidden;
    }
}
