/* =========================================
   FACTURACELI 2.0 - HOJA DE ESTILOS MODERNA
   ========================================= */

/* 1. VARIABLES Y CONFIGURACIÓN BASE */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Paleta de Marca (Azul Profesional / Tech) */
    --primary-color: #2563eb;       /* Azul intenso */
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;     /* Gris azulado */
    --success-color: #10b981;       /* Verde esmeralda */
    --danger-color: #ef4444;        /* Rojo suave */
    --warning-color: #f59e0b;       /* Ambar */
    
    /* Fondos y Superficies */
    --bg-body: #f3f4f6;             /* Gris muy claro para fondo */
    --bg-card: #ffffff;             /* Blanco puro para tarjetas */
    --bg-sidebar: #1e293b;          /* Azul noche para sidebar */
    
    /* Sombras (Elevation) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Bordes */
    --radius-md: 0.75rem;           /* 12px */
    --radius-lg: 1rem;              /* 16px */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: #334155; /* Gris oscuro suave, no negro total */
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: #0f172a;
    letter-spacing: -0.025em; /* Tracking ajustado estilo moderno */
}

/* 2. TARJETAS (CARDS) REINVENTADAS */
.card {
    background-color: var(--bg-card);
    border: none; /* Sin borde visible */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 1.5rem;
    overflow: hidden; /* Para que la cabecera no se salga del borde redondeado */
}

.card:hover {
    /* Efecto sutil de elevación al pasar el mouse */
    transform: translateY(-2px); 
    box-shadow: var(--shadow-lg);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid #f1f5f9;
    padding: 1.25rem 1.5rem;
    font-weight: 700;
    color: #334155;
    font-size: 1.1rem;
}

.card-body {
    padding: 1.5rem;
}

/* 3. BOTONES MODERNOS */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); /* Resplandor azul */
}

/* 4. TABLAS ESTILIZADAS */
.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: #f8fafc;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e2e8f0;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
    font-size: 0.95rem;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

/* 5. INPUTS Y FORMULARIOS */
.form-control, .form-select {
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 6. SIDEBAR MEJORADO */
.sidebar {
    background-color: var(--bg-sidebar);
    box-shadow: var(--shadow-lg);
}

.sidebar .nav-link {
    color: #94a3b8;
    font-weight: 500;
    margin: 0.25rem 1rem;
    border-radius: 0.5rem;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.sidebar-header {
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1rem;
}

/* 7. BADGES (ETIQUETAS) */
.badge {
    padding: 0.5em 0.8em;
    border-radius: 2rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Indicadores de espera para consultas y navegacion prolongadas */
#app-loading-bar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 2000;
    height: 3px;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

#app-loading-bar.is-visible {
    opacity: 1;
}

#app-loading-bar::after {
    content: "";
    display: block;
    width: 35%;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #60a5fa, #2563eb);
    animation: app-loading-progress 1.1s ease-in-out infinite;
}

#app-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1999;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.24);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

#app-loading-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.app-loading-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    color: #1e293b;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 1rem;
    box-shadow: 0 16px 45px rgba(15, 23, 42, 0.18);
    font-weight: 600;
}

.app-loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: app-loading-spin 0.75s linear infinite;
}

@keyframes app-loading-progress {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(310%); }
}

@keyframes app-loading-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    #app-loading-bar::after,
    .app-loading-spinner {
        animation-duration: 2.5s;
    }

    #app-loading-bar,
    #app-loading-overlay {
        transition-duration: 0.01ms;
    }
}

@media print {
    #app-loading-bar,
    #app-loading-overlay {
        display: none !important;
    }
}

/* Facturaceli 2026: sistema visual, superficies y microinteracciones */
:root {
    color-scheme: light;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #059669;
    --danger-color: #e5484d;
    --warning-color: #d97706;
    --info-color: #0284c7;
    --bg-body: #f5f7fc;
    --bg-card: #ffffff;
    --bg-sidebar: #111827;
    --text-main: #111827;
    --text-muted: #64748b;
    --border-subtle: #e8edf5;
    --shadow-sm: 0 2px 8px rgba(20, 31, 56, 0.045);
    --shadow-md: 0 12px 30px rgba(20, 31, 56, 0.075);
    --shadow-lg: 0 24px 60px rgba(20, 31, 56, 0.13);
    --radius-md: 14px;
    --radius-lg: 20px;
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
    scroll-behavior: smooth;
    scrollbar-color: #c7cfe0 transparent;
    scrollbar-width: thin;
}

body {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 82% 0%, rgba(99, 102, 241, 0.075), transparent 31rem),
        radial-gradient(ellipse at 4% 55%, rgba(14, 165, 233, 0.035), transparent 26rem),
        var(--bg-body);
    color: #344054;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    letter-spacing: -0.01em;
}

body::before {
    position: fixed;
    z-index: -1;
    inset: 0;
    background-image: radial-gradient(rgba(71, 85, 105, 0.12) 0.65px, transparent 0.65px);
    background-size: 22px 22px;
    content: "";
    opacity: 0.16;
    pointer-events: none;
}

::selection {
    color: #312e81;
    background: rgba(129, 140, 248, 0.22);
}

:focus-visible {
    outline: 3px solid rgba(99, 102, 241, 0.38);
    outline-offset: 3px;
}

h1, h2, h3, h4, h5, h6,
.font-outfit {
    color: #111827;
    font-family: 'Outfit', 'Inter', sans-serif;
    letter-spacing: -0.035em;
}

a {
    text-underline-offset: 3px;
}

/* Navegación */
.sidebar {
    background:
        radial-gradient(ellipse at 15% 0%, rgba(99, 102, 241, 0.2), transparent 42%),
        linear-gradient(165deg, #111827 0%, #151d30 54%, #101827 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: 14px 0 44px rgba(15, 23, 42, 0.11) !important;
}

.sidebar-header {
    position: relative;
    padding-top: 1.65rem !important;
    padding-bottom: 1.35rem !important;
    border-bottom-color: rgba(255, 255, 255, 0.09) !important;
}

.sidebar-header img {
    transition: transform 500ms var(--ease-out-expo), filter 500ms ease;
}

.sidebar-header a:hover img {
    filter: drop-shadow(0 8px 16px rgba(99, 102, 241, 0.4));
    transform: translateY(-2px) scale(1.035);
}

.sidebar-heading {
    color: #8390a7 !important;
    font-size: 0.66rem !important;
    letter-spacing: 0.15em !important;
}

.sidebar .nav-link {
    position: relative;
    min-height: 43px;
    margin-top: 0.2rem !important;
    margin-bottom: 0.2rem !important;
    border: 1px solid transparent;
    border-radius: 12px !important;
    transition:
        color 220ms ease,
        background-color 220ms ease,
        border-color 220ms ease,
        transform 300ms var(--ease-out-expo),
        box-shadow 220ms ease !important;
}

.sidebar .nav-link:hover {
    border-color: rgba(255, 255, 255, 0.075);
    background-color: rgba(255, 255, 255, 0.075) !important;
    transform: translateX(3px);
}

.sidebar .nav-link.active,
.sidebar .nav-link[aria-expanded="true"] {
    border-color: rgba(165, 180, 252, 0.2);
    background: linear-gradient(115deg, #5b55e7, #4568dc 72%, #3474df) !important;
    box-shadow: 0 8px 20px rgba(54, 68, 190, 0.26) !important;
}

.sidebar .collapse .nav-link {
    min-height: 37px;
}

.sidebar .collapse .nav-link:hover {
    transform: translateX(3px);
}

.sidebar-footer {
    border-top-color: rgba(255, 255, 255, 0.09) !important;
    background: rgba(0, 0, 0, 0.12) !important;
}

.sidebar-footer .btn-danger {
    border: 1px solid rgba(248, 113, 113, 0.2);
    background: rgba(220, 38, 38, 0.13);
    color: #fecaca;
}

.sidebar-footer .btn-danger:hover {
    border-color: rgba(248, 113, 113, 0.45);
    background: #b91c1c;
    color: #fff;
}

.topbar {
    min-height: 74px;
    padding: 0.8rem clamp(1rem, 3vw, 2.2rem) !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.82) !important;
    background: rgba(255, 255, 255, 0.86) !important;
    box-shadow: 0 5px 24px rgba(25, 36, 62, 0.035) !important;
    backdrop-filter: saturate(160%) blur(18px);
    -webkit-backdrop-filter: saturate(160%) blur(18px);
}

.topbar h5 {
    font-size: 1.06rem;
}

.menu-toggle-btn {
    border: 1px solid var(--border-subtle) !important;
    background: #fff !important;
    box-shadow: var(--shadow-sm);
    transition: transform 220ms var(--ease-out-expo), box-shadow 220ms ease !important;
}

.menu-toggle-btn:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.main-content > .container-fluid {
    width: 100%;
    max-width: 1760px;
    margin-right: auto;
    margin-left: auto;
}

.footer {
    padding: 1.25rem 1rem;
    color: #8490a3;
    font-size: 0.78rem;
    text-align: center;
}

/* Superficies, paneles y métricas */
.card,
.card-modern {
    border: 1px solid rgba(226, 232, 240, 0.78) !important;
    border-radius: var(--radius-lg) !important;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-sm);
    transition:
        transform 420ms var(--ease-out-expo),
        box-shadow 320ms ease,
        border-color 320ms ease !important;
}

.card:hover,
.card-modern:hover {
    border-color: rgba(165, 180, 252, 0.55) !important;
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.card-header {
    border-bottom: 1px solid #edf0f6 !important;
    color: #263247 !important;
    font-size: 1rem !important;
}

.card-body {
    color: #475569;
}

.card-modern {
    border-radius: 20px !important;
    box-shadow: 0 10px 30px rgba(20, 31, 56, 0.055);
}

.card-modern:hover {
    box-shadow: 0 20px 44px rgba(35, 45, 82, 0.11);
    transform: translateY(-5px);
}

.icon-box {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.66), 0 8px 20px rgba(30, 41, 59, 0.06);
}

.section-title {
    letter-spacing: 0.12em !important;
}

.financial-card {
    border: 1px solid var(--border-subtle) !important;
    box-shadow: var(--shadow-sm) !important;
}

/* Formularios */
.form-control,
.form-select,
.input-group-text {
    min-height: 43px;
    border-color: #dfe5ef;
    border-radius: 11px;
    background-color: #fff;
    color: #243047;
    transition:
        border-color 180ms ease,
        box-shadow 220ms ease,
        background-color 180ms ease,
        transform 220ms var(--ease-out-expo);
}

.form-control::placeholder {
    color: #9aa5b5;
}

.form-control:focus,
.form-select:focus {
    border-color: #818cf8;
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

textarea.form-control {
    min-height: auto;
}

.input-group > .form-control,
.input-group > .form-select,
.input-group > .input-group-text {
    border-radius: 11px;
}

.form-label {
    color: #526078;
    font-size: 0.83rem;
    letter-spacing: 0.015em;
}

.form-check-input {
    border-color: #cbd5e1;
    transition: background-color 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.form-check-input:checked {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

/* Botones y acciones */
.btn {
    position: relative;
    overflow: hidden;
    border-radius: 11px;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition:
        transform 240ms var(--ease-out-expo),
        box-shadow 240ms ease,
        background-color 180ms ease,
        border-color 180ms ease,
        color 180ms ease !important;
}

.btn:not(:disabled):not(.disabled):hover {
    box-shadow: 0 8px 20px rgba(34, 48, 78, 0.12);
    transform: translateY(-2px);
}

.btn:not(:disabled):not(.disabled):active {
    box-shadow: none;
    transform: translateY(0) scale(0.98);
}

.btn-primary,
.btn-modern {
    border-color: transparent;
    background: linear-gradient(120deg, #5b55e7, #4668dc 58%, #3474df);
    box-shadow: 0 7px 17px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover,
.btn-modern:hover {
    border-color: transparent;
    background: linear-gradient(120deg, #4f46e5, #3f5fd0 58%, #2868cf);
    box-shadow: 0 11px 24px rgba(79, 70, 229, 0.28) !important;
}

.btn-success {
    border-color: #059669;
    background: linear-gradient(120deg, #10a37f, #059669);
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-light:hover {
    transform: translateY(-2px);
}

.btn i {
    transition: transform 260ms var(--ease-out-expo);
}

.btn:hover i.fa-plus,
.btn:hover i.fa-arrow-right,
.btn:hover i.fa-search {
    transform: translateX(2px);
}

/* Tablas, filtros y estados */
.table-responsive,
.table-wrapper {
    border-radius: 15px;
    scrollbar-color: #cbd5e1 transparent;
    scrollbar-width: thin;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #f6f8ff;
    color: #475569;
}

.table thead th {
    border-bottom: 1px solid #e5eaf3 !important;
    background: #f7f8fc !important;
    color: #77839a !important;
    font-size: 0.69rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.1em !important;
    white-space: nowrap;
}

.table tbody td {
    border-bottom-color: #edf0f5 !important;
}

.table tbody tr {
    transition: background-color 180ms ease, box-shadow 180ms ease;
}

.table-hover tbody tr:hover {
    --bs-table-bg-state: #f7f8ff;
}

.table-hover tbody tr:hover td {
    background: #f7f8ff;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.badge {
    font-weight: 650;
}

.alert {
    border: 1px solid transparent;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.pagination .page-link {
    margin: 0 2px;
    border: 0;
    border-radius: 9px !important;
    color: #5b6475;
    transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.pagination .page-link:hover {
    color: #4338ca;
    background: #eef0ff;
    transform: translateY(-1px);
}

.pagination .active > .page-link {
    background: var(--primary-color);
}

/* Diálogos, menús desplegables y mensajes */
.modal-backdrop.show {
    opacity: 0.48;
    backdrop-filter: blur(4px);
}

.modal.fade .modal-dialog {
    transform: translateY(16px) scale(0.985);
    transition: transform 320ms var(--ease-out-expo);
}

.modal.show .modal-dialog {
    transform: translateY(0) scale(1);
}

.modal-content {
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 21px;
    box-shadow: var(--shadow-lg);
}

.modal-header,
.modal-footer {
    border-color: #edf0f5;
}

.dropdown-menu,
.custom-dropdown,
.search-results {
    border: 1px solid #e8edf5;
    border-radius: 14px;
    box-shadow: 0 18px 42px rgba(20, 31, 56, 0.14);
}

.dropdown-item,
.list-group-item {
    transition: color 160ms ease, background-color 160ms ease, padding 200ms var(--ease-out-expo);
}

.list-group-item:hover {
    padding-left: 1.1rem;
    background: #f7f8ff;
}

/* Motion: carga progresiva y microinteracciones */
@keyframes interface-enter {
    from { opacity: 0; transform: translate3d(0, 16px, 0) scale(0.99); }
    to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes soft-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
    50% { box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.08); }
}

body:not(.motion-disabled) .main-content > .container-fluid > * {
    animation: interface-enter 560ms var(--ease-out-expo) both;
}

body:not(.motion-disabled) .main-content > .container-fluid > *:nth-child(2) { animation-delay: 45ms; }
body:not(.motion-disabled) .main-content > .container-fluid > *:nth-child(3) { animation-delay: 90ms; }
body:not(.motion-disabled) .main-content > .container-fluid > *:nth-child(4) { animation-delay: 135ms; }
body:not(.motion-disabled) .main-content > .container-fluid > *:nth-child(5) { animation-delay: 180ms; }

.animate-up {
    animation-timing-function: var(--ease-out-expo) !important;
}

.card-modern .icon-box {
    transition: transform 500ms var(--ease-out-expo), box-shadow 300ms ease;
}

.card-modern:hover .icon-box {
    box-shadow: 0 10px 22px rgba(79, 70, 229, 0.14);
    transform: translateY(-2px) rotate(-4deg) scale(1.07);
}

.stock-alert-btn:hover i {
    animation: ring 800ms ease-in-out;
}

@media (max-width: 991.98px) {
    .topbar {
        min-height: 66px;
    }

    .sidebar {
        box-shadow: 24px 0 60px rgba(15, 23, 42, 0.3) !important;
    }
}

@media (max-width: 575.98px) {
    .main-content > .container-fluid {
        padding-right: 0.85rem !important;
        padding-left: 0.85rem !important;
    }

    .card,
    .card-modern {
        border-radius: 16px !important;
    }

    .card-body {
        padding: 1rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.65rem;
    }

    .topbar .gap-3 {
        gap: 0.5rem !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }

    .animate-up,
    body:not(.motion-disabled) .main-content > .container-fluid > * {
        opacity: 1 !important;
        transform: none !important;
    }
}

@media print {
    body,
    body::before {
        background: #fff !important;
    }

    .card,
    .card-modern {
        box-shadow: none !important;
        transform: none !important;
    }
}