/* ============================================================
   ComercioCRM - Tema moderno (estilo app)
   ============================================================ */

:root {
    /* Marca */
    --brand: #0071dc;
    --brand-dark: #0058a8;
    --brand-soft: #e7f1fd;

    /* Neutros */
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --line: #e6eaf1;
    --line-2: #eef1f6;
    --bg: #f5f7fb;
    --surface: #ffffff;

    /* Formas */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px rgba(15, 23, 42, .05);
    --shadow-md: 0 8px 28px rgba(15, 23, 42, .10);

    /* Sidebar */
    --sidebar-width: 252px;
    --sidebar-bg: #0b1220;
    --sidebar-bg-2: #101a2c;

    /* Bootstrap */
    --bs-primary: #0071dc;
    --bs-primary-rgb: 0, 113, 220;
    --bs-link-color: #0071dc;
    --bs-link-hover-color: #0058a8;
    --bs-body-bg: #f5f7fb;
    --bs-body-color: #0f172a;
    --bs-border-color: #e6eaf1;
    --bs-border-radius: .65rem;
    --bs-border-radius-sm: .5rem;
    --bs-border-radius-lg: .9rem;
    --bs-body-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: var(--bs-body-font-family);
    background-color: var(--bg);
    color: var(--ink);
    font-size: .925rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -.02em;
    color: var(--ink);
}

h2 { font-weight: 750; font-size: 1.55rem; }
h4 { font-weight: 700; }
h5 { font-weight: 700; font-size: 1.05rem; }

h2 > .bi:first-child,
h4 > .bi:first-child {
    color: var(--brand);
}

small { color: var(--muted); }

a { text-decoration: none; }

/* ---------- Estructura ---------- */
.wrapper {
    display: flex;
    min-height: 100vh;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1030;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .3s ease;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, .06);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-header {
    padding: 1.1rem 1.1rem 1rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, .07) !important;
    background: rgba(255, 255, 255, .02);
}
.sidebar-header h5 {
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: #fff;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.sidebar-header small {
    color: var(--muted-2) !important;
    font-size: .72rem;
    display: block;
    margin-top: .15rem;
    padding-left: 1.85rem;
}

.sidebar-body { padding: .85rem .7rem 1.5rem !important; }

.sidebar .nav-link {
    color: rgba(226, 232, 240, .78) !important;
    padding: .52rem .7rem !important;
    border-radius: 10px !important;
    margin-bottom: 2px;
    font-size: .855rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: background .15s, color .15s, transform .1s;
}
.sidebar .nav-link i { font-size: 1rem; opacity: .85; }

.sidebar .nav-link:hover {
    color: #fff !important;
    background-color: rgba(255, 255, 255, .07) !important;
}

.sidebar .nav-link.active {
    color: #fff !important;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%) !important;
    box-shadow: 0 6px 16px rgba(0, 113, 220, .35);
    font-weight: 600;
}
.sidebar .nav-link.active i { opacity: 1; }

/* Separadores de sección del menú */
.sidebar .nav-link.text-white-50 {
    color: var(--muted-2) !important;
    font-size: .66rem !important;
    letter-spacing: .1em;
    font-weight: 700 !important;
    padding: .85rem .7rem .35rem !important;
    pointer-events: none;
}

/* ---------- Barra superior ---------- */
.navbar {
    background: rgba(255, 255, 255, .85) !important;
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line) !important;
    min-height: 58px;
    padding: .45rem 1.25rem !important;
    box-shadow: none;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.navbar .btn-sm {
    border-radius: 9px;
    font-weight: 600;
    color: var(--ink-2);
    border-color: var(--line);
    background: #fff;
}
.navbar .btn-sm:hover { border-color: #cbd5e1; background: #f8fafc; }

/* ---------- Contenido ---------- */
.container-fluid { max-width: 100%; }

/* ---------- Tarjetas ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line-2);
    border-top-left-radius: var(--radius-lg) !important;
    border-top-right-radius: var(--radius-lg) !important;
    padding: .85rem 1.1rem;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
}
.card-body { padding: 1.1rem; }
.card-footer {
    background: transparent;
    border-top: 1px solid var(--line-2);
    padding: .8rem 1.1rem;
}

/* ---------- Botones ---------- */
.btn {
    border-radius: 10px;
    font-weight: 600;
    font-size: .875rem;
    padding: .5rem .95rem;
    letter-spacing: .005em;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { border-radius: 8px; padding: .32rem .7rem; font-size: .8rem; }
.btn-lg { border-radius: 12px; padding: .72rem 1.4rem; font-size: 1rem; }

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: #004f97;
    --bs-btn-active-border-color: #004f97;
    --bs-btn-focus-shadow-rgb: 0, 113, 220;
    box-shadow: 0 4px 12px rgba(0, 113, 220, .22);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: #bcd7f5;
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    background: #fff;
}
.btn-outline-secondary {
    --bs-btn-color: var(--ink-2);
    --bs-btn-border-color: #d7dee7;
    background: #fff;
}
.btn-success {
    --bs-btn-bg: #0f9d58;
    --bs-btn-border-color: #0f9d58;
    --bs-btn-hover-bg: #0b8049;
    --bs-btn-hover-border-color: #0b8049;
}
.btn-group .btn, .input-group .btn { border-radius: 9px; }

/* ---------- Formularios ---------- */
.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: .3rem;
}
.form-control, .form-select {
    border-radius: 10px;
    border: 1px solid #dfe5ec;
    padding: .5rem .75rem;
    font-size: .885rem;
    color: var(--ink);
    background-color: #fff;
}
.form-control::placeholder { color: #a8b2c1; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(0, 113, 220, .14);
}
.input-group-text {
    border-radius: 10px;
    border-color: #dfe5ec;
    background: #f8fafc;
    color: var(--muted);
    font-size: .85rem;
}
.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}
.form-check-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(0, 113, 220, .14);
}

/* ---------- Tablas ---------- */
.table {
    --bs-table-hover-bg: #f8fafc;
    margin-bottom: 0;
    color: var(--ink-2);
}
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table thead th {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    background: #fbfcfe;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table tbody td {
    font-size: .86rem;
    border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}
.table-hover > tbody > tr:hover > * { background-color: #f7f9fc; }
.table-light, .table > thead.table-light th { background: #fbfcfe; }
.table-danger { --bs-table-bg: #fff1f2; --bs-table-color: #7f1d1d; }
.table-warning { --bs-table-bg: #fffbeb; --bs-table-color: #78350f; }
.table-responsive { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- Insignias ---------- */
.badge {
    border-radius: 999px;
    font-weight: 600;
    font-size: .68rem;
    padding: .38em .7em;
    letter-spacing: .01em;
}
.badge.bg-light { border: 1px solid var(--line); color: var(--ink-2); }

/* ---------- Alertas ---------- */
.alert {
    border: none;
    border-radius: var(--radius);
    font-size: .87rem;
    padding: .8rem 1rem;
    box-shadow: var(--shadow-xs);
}

/* ---------- Modales ---------- */
.modal-content {
    border: none;
    border-radius: 18px;
    box-shadow: var(--shadow-md);
}
.modal-header { border-bottom: 1px solid var(--line-2); padding: 1rem 1.25rem; }
.modal-title { font-weight: 700; font-size: 1.05rem; }
.modal-body { padding: 1.25rem; }
.modal-footer { border-top: 1px solid var(--line-2); padding: .85rem 1.25rem; }
.modal-backdrop.show { opacity: .45; }

/* ---------- Desplegables ---------- */
.dropdown-menu {
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: .35rem;
    font-size: .87rem;
}
.dropdown-item {
    border-radius: 8px;
    padding: .45rem .65rem;
    font-weight: 500;
    color: var(--ink-2);
}
.dropdown-item:hover { background: #f4f7fb; color: var(--ink); }
.dropdown-divider { border-color: var(--line-2); }

/* ---------- Navegación por pestañas ---------- */
.nav-tabs { border-bottom: 1px solid var(--line); }
.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: .87rem;
}
.nav-tabs .nav-link.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    background: transparent;
}

/* ---------- Paginación ---------- */
.pagination { gap: .25rem; }
.page-link {
    border: 1px solid var(--line);
    border-radius: 8px !important;
    color: var(--ink-2);
    font-size: .82rem;
    font-weight: 600;
    padding: .35rem .65rem;
}
.page-item.active .page-link {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.page-link:hover { background: #f4f7fb; color: var(--brand); }

/* ---------- Barras de progreso ---------- */
.progress { border-radius: 999px; height: .5rem; background: #eef2f7; }
.progress-bar { border-radius: 999px; }

/* ---------- Pestañas heredadas / POS ---------- */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1rem;
    height: calc(100vh - 120px);
}
.pos-products { overflow-y: auto; }
.pos-cart {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.pos-cart-body { flex: 1; overflow-y: auto; padding: 1rem; }
.pos-cart-footer { border-top: 1px solid var(--line); padding: 1rem; background: #fbfcfe; }

.product-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .75rem;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .15s;
    background: #fff;
}
.product-card:hover {
    border-color: var(--brand);
    box-shadow: 0 8px 20px rgba(0, 113, 220, .14);
    transform: translateY(-2px);
}
.product-card img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; }

/* ---------- Carga de imágenes ---------- */
.image-preview {
    width: 150px;
    height: 150px;
    border: 2px dashed #d7dee7;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background: #fafbfd;
}
.image-preview img { max-width: 100%; max-height: 100%; object-fit: cover; }
.image-preview:hover { border-color: var(--brand); }

/* ---------- Impresión ---------- */
@media print {
    .sidebar, .navbar, .no-print, .btn { display: none !important; }
    .main-content { margin-left: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: none; }
}
.print-58 { width: 58mm; font-family: monospace; font-size: 10px; padding: 2mm; }
.print-80 { width: 80mm; font-family: monospace; font-size: 12px; padding: 3mm; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.4); }
    .main-content { margin-left: 0; }
    .pos-container { grid-template-columns: 1fr; height: auto; }
}

/* ---------- Varios ---------- */
.badge-counter {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: .65rem;
    padding: .2em .5em;
}

.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, .7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.active { background-color: #0f9d58; }
.status-dot.inactive { background-color: #dc3545; }
.status-dot.warning { background-color: #f59e0b; }

/* Scrollbars finos */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }

/* Accesos rápidos del dashboard */.qa-chip {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink-2);
    border-radius: 999px;
    font-weight: 600;
    font-size: .8rem;
    padding: .38rem .85rem;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.qa-chip i { color: var(--muted); font-size: .95rem; }
.qa-chip:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: #f7fbff;
}
.qa-chip:hover i { color: var(--brand); }

/* Tarjetas de indicadores del dashboard */
.card.border-primary,
.card.border-success,
.card.border-warning,
.card.border-danger,
.card.border-info {
    border-width: 1px !important;
}
.card.bg-success, .card.bg-info, .card.bg-primary, .card.bg-warning {
    border: none;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .10);
}
.card.bg-success { background: linear-gradient(135deg, #0f9d58, #0b8049) !important; }
.card.bg-info { background: linear-gradient(135deg, #0ea5c6, #0284a3) !important; }
.card.bg-primary { background: linear-gradient(135deg, #0071dc, #0058a8) !important; }

/* ---------- Pantalla de acceso ---------- */
body.bg-light {
    background:
        radial-gradient(1000px 520px at 8% -10%, #e2efff 0%, rgba(226, 239, 255, 0) 62%),
        radial-gradient(900px 520px at 108% 8%, #e6f7ee 0%, rgba(230, 247, 238, 0) 58%),
        #f5f7fb !important;
}
body.bg-light .card { border-radius: 20px; }
body.bg-light .card.shadow { box-shadow: 0 18px 50px rgba(15, 23, 42, .12) !important; }
body.bg-light .form-control { padding: .65rem .85rem; }
body.bg-light .btn-primary { padding: .65rem; }
