/* FactuTraz — tema Bootstrap 5 */

:root {
    --primary: #198754;
    --primary-dark: #146c43;
    --primary-light: #d1e7dd;
    --sidebar-bg: #1a1d21;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 4rem;
    --sidebar-text: #8b949e;
    --sidebar-text-hover: #ffffff;
    --header-height: 3.25rem;
    --content-bg: #f4f6f9;
    --card-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 0.5rem 1.25rem rgba(25, 135, 84, 0.12);
}

/* ——— Layout principal ——— */
.app-body {
    min-height: 100vh;
    background-color: var(--content-bg);
    margin: 0;
    font-size: 1rem;
    transition: padding 0.25s ease;
}

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

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.5rem;
    transition: width 0.28s ease, transform 0.28s ease;
    box-shadow: 0.125rem 0 1rem rgba(0, 0, 0, 0.15);
}

.app-sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    padding: 0.25rem 0;
    margin: 0;
}

.app-sidebar-nav::-webkit-scrollbar { width: 0.35rem; }
.app-sidebar-nav::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); border-radius: 0.25rem; }
.app-sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 0.25rem; }
.app-sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.28s ease;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    min-height: var(--header-height);
    box-shadow: 0 0.0625rem 0.25rem rgba(0, 0, 0, 0.04);
}

.app-header-inner {
    padding: 0.65rem 1.25rem;
}

.app-content {
    flex: 1;
    padding: 0;
}

.text-muted-sidebar {
    color: var(--sidebar-text) !important;
}

/* Marca sidebar */
.app-sidebar-brand {
    padding: 0 0.35rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 0.25rem;
}

.app-sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-sidebar-logo-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 0.4rem;
    background: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.app-sidebar-logo-text span.fw-bold { font-size: 0.85rem; }
.app-sidebar-logo-text small { font-size: 0.62rem; letter-spacing: 0.02em; }

/* Enlaces menú */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.32rem 0.6rem;
    border-radius: 0.35rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.8rem;
    line-height: 1.3;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.sidebar-link:hover { color: var(--sidebar-text-hover); background-color: rgba(255,255,255,0.06); }
.sidebar-link.active { background-color: var(--primary); color: #fff; }
.sidebar-link.active .sidebar-icon { color: inherit; }

.sidebar-icon {
    width: 1.1rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--sidebar-text);
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.sidebar-link:hover .sidebar-icon { color: var(--sidebar-text-hover); }

.sidebar-item { margin-bottom: 0.05rem; }

.sidebar-sublink {
    display: block;
    padding: 0.22rem 0.6rem 0.22rem 1.85rem;
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0.3rem;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.sidebar-sublink:hover { color: var(--sidebar-text-hover); background-color: rgba(255,255,255,0.05); }
.sidebar-sublink.active { color: #fff; background-color: rgba(25, 135, 84, 0.35); }

/* Acordeón sidebar */
.sidebar-accordion { margin-bottom: 0.05rem; }
.sidebar-accordion .accordion-item { background: transparent; }

.sidebar-accordion .accordion-button.sidebar-accordion-btn {
    background-color: transparent;
    color: var(--sidebar-text);
    box-shadow: none;
    padding: 0.32rem 0.6rem;
    font-size: 0.8rem;
    line-height: 1.3;
    border-radius: 0.35rem !important;
    gap: 0.5rem;
    align-items: center;
}

.sidebar-accordion .accordion-button.sidebar-accordion-btn:not(.collapsed) {
    color: var(--sidebar-text-hover);
    background-color: rgba(255, 255, 255, 0.06);
}

.sidebar-accordion .accordion-button.sidebar-accordion-btn::after {
    filter: invert(0.65);
    margin-left: auto;
    width: 0.55rem;
    height: 0.55rem;
    background-size: 0.55rem;
}

.sidebar-accordion .accordion-button.sidebar-accordion-btn:focus { box-shadow: none; border-color: transparent; }

.sidebar-accordion .accordion-body {
    background: transparent;
    border: none;
    padding-top: 0.1rem !important;
    padding-bottom: 0.15rem !important;
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
}

/* Footer sidebar */
.app-sidebar-footer {
    padding: 0.4rem 0.35rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-sidebar-toggle {
    color: var(--sidebar-text);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.72rem;
    padding: 0.3rem 0.4rem;
    border-radius: 0.35rem;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn-sidebar-toggle:hover {
    color: var(--sidebar-text-hover);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-collapse-icon { transition: transform 0.28s ease; }
body.sidebar-collapsed .sidebar-collapse-icon { transform: rotate(180deg); }

.avatar-sm {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.7rem;
}

/* Sidebar colapsada */
body.sidebar-collapsed { --sidebar-width: var(--sidebar-collapsed-width); }

body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

body.sidebar-collapsed .app-sidebar-logo-text,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-user-text,
body.sidebar-collapsed .btn-sidebar-toggle .sidebar-label { display: none !important; }

body.sidebar-collapsed .app-sidebar-logo { justify-content: center; }
body.sidebar-collapsed .app-sidebar-brand { padding-left: 0; padding-right: 0; }

body.sidebar-collapsed .sidebar-link,
body.sidebar-collapsed .sidebar-accordion .accordion-button.sidebar-accordion-btn {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

body.sidebar-collapsed .sidebar-icon { margin: 0; }
body.sidebar-collapsed .sidebar-accordion .accordion-button.sidebar-accordion-btn::after { display: none; }
body.sidebar-collapsed .accordion-collapse { display: none !important; }
body.sidebar-collapsed .app-sidebar-user { justify-content: center; }
body.sidebar-collapsed .btn-sidebar-toggle { padding: 0.5rem; }
body.sidebar-collapsed .btn-sidebar-toggle .sidebar-collapse-icon { margin: 0 !important; }

/* Móvil */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-backdrop.is-visible { opacity: 1; visibility: visible; }

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 100vw - 2rem);
    }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-main { margin-left: 0 !important; }
    body.sidebar-collapsed .app-sidebar { width: min(var(--sidebar-width), 100vw - 2rem); }
}

/* Tarjetas dashboard */
.stat-card {
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    border-radius: 0.65rem;
}

.stat-card:hover { transform: translateY(-0.2rem); box-shadow: var(--card-shadow-hover) !important; }

.stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.welcome-card { border-radius: 0.65rem; transition: box-shadow 0.22s ease; }
.welcome-card:hover { box-shadow: 0 0.35rem 1rem rgba(0,0,0,0.08) !important; }

.quick-card { border-radius: 0.65rem; transition: transform 0.22s ease, box-shadow 0.22s ease; }
.quick-card:hover { transform: translateY(-0.25rem); box-shadow: var(--card-shadow-hover) !important; }

.quick-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.5rem;
    background: rgba(25, 135, 84, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.card.shadow-sm { box-shadow: var(--card-shadow) !important; }

/* Invitado / login */
.guest-body { min-height: 100vh; margin: 0; background: #f0f2f5; }
.guest-layout { background: none; }

.guest-side {
    width: 42%;
    max-width: 520px;
    background: linear-gradient(160deg, #0a3d20 0%, #146c43 40%, #198754 70%, #20c997 100%);
    position: relative;
    overflow: hidden;
}

.guest-side::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255,255,255,0.06) 0%, transparent 50%);
    pointer-events: none;
}

.guest-side-content { position: relative; z-index: 1; }

.guest-side-icon {
    width: 5rem;
    height: 5rem;
    margin: 0 auto;
    border-radius: 1.25rem;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    border: 1px solid rgba(255,255,255,0.2);
}

.guest-form-panel { background: #f8f9fb; }

.guest-logo-mobile {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.85rem;
    background: linear-gradient(145deg, #146c43, #20c997);
    display: flex;
    align-items: center;
    justify-content: center;
}

.guest-card {
    border-radius: 1rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
    background: #fff;
}

.guest-footer { max-width: 26rem; }

.btn-login {
    background: linear-gradient(135deg, #146c43 0%, #20c997 100%);
    color: #fff;
    border: none;
    border-radius: 0.6rem;
    padding: 0.7rem 1.5rem;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(20, 108, 67, 0.3);
}

.btn-login:hover {
    background: linear-gradient(135deg, #0a3d20 0%, #198754 100%);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(20, 108, 67, 0.4);
}

.btn-login:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(20, 108, 67, 0.3); }

.guest-card .form-control-lg {
    border-radius: 0.5rem;
    border: 1.5px solid #dee2e8;
    padding: 0.65rem 0.9rem;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.guest-card .form-control-lg:focus {
    border-color: #198754;
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.12);
}

.guest-card .input-group .btn-outline-secondary {
    border: 1.5px solid #dee2e8;
    border-left: 0;
    border-radius: 0 0.5rem 0.5rem 0;
    color: #6c757d;
}

.guest-card .input-group .form-control-lg { border-radius: 0.5rem 0 0 0.5rem; }
.guest-card .form-check-input:checked { background-color: #198754; border-color: #198754; }
.guest-card a { color: #198754; }
.guest-card a:hover { color: #0a3d20; }

.app-header-toggle { border-radius: 0.45rem; }
.app-breadcrumb .breadcrumb { background: transparent; padding: 0; margin: 0; }

/* ================================================================
   ESTILOS GLOBALES — Tablas, formularios, contenido compacto
   ================================================================ */
.app-content { font-size: 0.84rem; }
.app-content h1, .app-content .h4 { font-size: 1.05rem !important; }
.app-content h5 { font-size: 0.92rem; }

.app-content .table { font-size: 0.8rem; margin-bottom: 0; }
.app-content .table th {
    padding: 0.4rem 0.55rem;
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #5a6a85;
    white-space: nowrap;
    border-bottom-width: 1px;
}
.app-content .table td { padding: 0.3rem 0.55rem; vertical-align: middle; border-bottom: 1px solid #f0f2f5; }
.app-content .table thead.table-light th { background-color: #f8f9fb; border-bottom: 2px solid #e9ecf1; }
.app-content .table-hover > tbody > tr:hover > td { background-color: #f0fff8; }

.badge { font-size: 0.68rem; font-weight: 500; padding: 0.25em 0.55em; border-radius: 0.3rem; letter-spacing: 0.01em; }
.badge.bg-success { background-color: #d1e7dd !important; color: #0f5132 !important; }
.badge.bg-danger { background-color: #ffeef0 !important; color: #c62828 !important; }
.badge.bg-warning { background-color: #fff8e1 !important; color: #e65100 !important; }
.badge.bg-info { background-color: #cff4fc !important; color: #055160 !important; }
.badge.bg-primary { background-color: #d1e7dd !important; color: #0a3d20 !important; }
.badge.bg-secondary { background-color: #f0f2f5 !important; color: #546e7a !important; }

.app-content .btn-group-sm > .btn, .app-content .btn-sm {
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
    border-radius: 0.3rem;
}
.app-content .btn-group-sm > .btn i, .app-content .btn-sm i { font-size: 0.72rem; }

.app-content .btn-outline-primary,
.app-content .btn-outline-info,
.app-content .btn-outline-warning,
.app-content .btn-outline-success,
.app-content .btn-outline-danger { border-color: #d5dbe3; color: #5a6a85; }

.app-content .btn-outline-success:hover { background-color: #d1e7dd; border-color: #a3cfbb; color: #0f5132; }
.app-content .btn-outline-primary:hover { background-color: #d1e7dd; border-color: #a3cfbb; color: #0a3d20; }
.app-content .btn-outline-warning:hover { background-color: #fff8e1; border-color: #ffe082; color: #e65100; }
.app-content .btn-outline-danger:hover { background-color: #ffeef0; border-color: #ef9a9a; color: #c62828; }

.app-content .nav-tabs .nav-link {
    font-size: 0.78rem;
    padding: 0.4rem 0.85rem;
    color: #5a6a85;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
}
.app-content .nav-tabs .nav-link.active { color: #198754; font-weight: 600; border-bottom-color: #198754; background: transparent; }
.app-content .nav-tabs .nav-link:hover:not(.active) { color: #333; border-bottom-color: #d5dbe3; }
.app-content .nav-tabs { border-bottom: 1px solid #e9ecf1; }

.app-content .card { border-radius: 0.55rem; }
.app-content .card-body { padding: 1rem; }

.app-content .btn-primary {
    font-size: 0.78rem;
    padding: 0.35rem 0.85rem;
    border-radius: 0.4rem;
    background: #198754;
    border-color: #198754;
}
.app-content .btn-primary:hover { background: #146c43; border-color: #146c43; }
.app-content .btn-secondary { font-size: 0.78rem; padding: 0.35rem 0.85rem; }

.modal-title { font-size: 0.95rem; }
.modal-body { font-size: 0.84rem; padding: 1rem 1.25rem; }
.modal-body .form-label { font-size: 0.78rem; margin-bottom: 0.25rem; }
.modal-body .form-control { font-size: 0.82rem; padding: 0.35rem 0.65rem; }
.modal-body .mb-3 { margin-bottom: 0.65rem !important; }
.modal-header { padding: 0.75rem 1.25rem; }
.modal-footer { padding: 0.6rem 1.25rem; }
.modal-footer .btn { font-size: 0.78rem; padding: 0.3rem 0.8rem; }

.app-content .form-label { font-size: 0.8rem; font-weight: 500; margin-bottom: 0.2rem; color: #475569; }
.app-content .form-control, .app-content .form-select { font-size: 0.82rem; padding: 0.35rem 0.65rem; border-radius: 0.35rem; }

.app-content .dataTables_wrapper .dataTables_length select { font-size: 0.78rem; padding: 0.25rem 1.75rem 0.25rem 0.5rem; appearance: auto; min-width: 4.5rem; }
.app-content .dataTables_wrapper .dataTables_filter input { font-size: 0.78rem; padding: 0.25rem 0.5rem; }
.app-content .dataTables_wrapper .dataTables_info,
.app-content .dataTables_wrapper .dataTables_length label,
.app-content .dataTables_wrapper .dataTables_filter label { font-size: 0.76rem; color: #5a6a85; }
.app-content .dataTables_wrapper .dataTables_paginate .paginate_button { font-size: 0.76rem !important; padding: 0.2rem 0.5rem !important; }

.app-content .alert { font-size: 0.82rem; padding: 0.5rem 0.85rem; border-radius: 0.4rem; }
.app-content .breadcrumb { font-size: 0.75rem; }
.app-content .container-fluid.py-3 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }

/* POS / Facturación */
.pos-product-card {
    cursor: pointer;
    border-radius: 0.55rem;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    border: 1.5px solid #e9ecf1;
}
.pos-product-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(25,135,84,0.15); border-color: #a3cfbb; }
.pos-product-card.selected { border-color: var(--primary); background-color: #f0fff8; }

.factura-total-box { background: #f0fff8; border-radius: 0.55rem; border: 1.5px solid #a3cfbb; }
