/* ============================================================
   LogosDigital ERP — Estilos Personalizados
   ============================================================ */

@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter-semibold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* ── Variables ──────────────────────────────────────────────── */
:root {
    --ld-primary:       #1a56db;
    --ld-primary-dark:  #1341b0;
    --ld-primary-light: #e8f0fe;
    --ld-accent:        #0ea5e9;
    --ld-success:       #10b981;
    --ld-warning:       #f59e0b;
    --ld-danger:        #ef4444;
    --ld-info:          #6366f1;
    --sidebar-width:    260px;
    --sidebar-bg:       #0f172a;
    --sidebar-text:     #94a3b8;
    --sidebar-active:   #1a56db;
    --topbar-height:    60px;
    --body-bg:          #f1f5f9;
    --card-radius:      12px;
    --shadow-sm:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:        0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.05);
    --shadow-lg:        0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
}

/* ── Reset / Base ───────────────────────────────────────────── */
* { box-sizing: border-box; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    background: var(--body-bg);
    color: #1e293b;
    min-height: 100vh;
}
a { text-decoration: none; }
h1,h2,h3,h4,h5,h6 { font-weight: 600; }

/* ── Login ──────────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #1a56db 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0,0,0,.25);
}
.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    gap: 0.5rem;
}
.login-logo-img {
    max-width: 200px;
    max-height: 72px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.login-logo span { font-size: .8rem; color: #64748b; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1040;
    transition: transform .3s ease;
}
.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}
.sidebar-logo {
    max-width: 130px;
    max-height: 36px;
    width: auto;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
}
.sidebar-brand-text { line-height: 1.2; }
.sidebar-brand-text .sub  { color: #64748b; font-size: .72rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-section { padding: .5rem 1.5rem .25rem; }
.nav-section-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #475569;
}
.nav-item { list-style: none; }
.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem 1.5rem;
    color: var(--sidebar-text);
    font-size: .865rem;
    font-weight: 500;
    border-radius: 0;
    transition: all .2s;
    position: relative;
}
.nav-link i { font-size: 1rem; width: 20px; flex-shrink: 0; }
.nav-link:hover { color: #f1f5f9; background: rgba(255,255,255,.05); }
.nav-link.active {
    color: #fff;
    background: rgba(26,86,219,.25);
}
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--ld-primary);
    border-radius: 0 2px 2px 0;
}
.nav-link .badge { margin-left: auto; font-size: .65rem; }

/* Submenu */
.has-submenu > .nav-link::after {
    content: '\F285';
    font-family: 'bootstrap-icons';
    margin-left: auto;
    font-size: .75rem;
    transition: transform .25s;
}
.has-submenu.open > .nav-link::after { transform: rotate(90deg); }
.submenu {
    display: none;
    background: rgba(0,0,0,.15);
    padding: .25rem 0;
}
.has-submenu.open .submenu { display: block; }
.submenu .nav-link { padding-left: 3.5rem; font-size: .83rem; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.sidebar-user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ld-primary), var(--ld-accent));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.sidebar-user-info .name   { color: #f1f5f9; font-size: .83rem; font-weight: 600; }
.sidebar-user-info .role   { color: #64748b; font-size: .72rem; }
.sidebar-user-actions { margin-left: auto; display: flex; gap: .25rem; }
.sidebar-user-actions a {
    color: #64748b;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    transition: all .2s;
}
.sidebar-user-actions a:hover { color: #f1f5f9; background: rgba(255,255,255,.08); }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 1rem; font-weight: 600; color: #1e293b; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.topbar-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    color: #64748b;
    font-size: 1rem;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
}
.topbar-btn:hover { background: #f8fafc; color: var(--ld-primary); border-color: #cbd5e1; }
.topbar-menu-toggle { display: none; }
.breadcrumb { margin: 0; font-size: .82rem; }
.breadcrumb-item a { color: var(--ld-primary); }
.breadcrumb-item.active { color: #64748b; }

/* ── Main Content ───────────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    min-height: 100vh;
}
.main-content { padding: 1.75rem; }
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-title { font-size: 1.35rem; font-weight: 700; color: #0f172a; margin: 0; }
.page-subtitle { font-size: .82rem; color: #64748b; margin: .15rem 0 0; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    background: transparent;
    display: flex;
    align-items: center;
    gap: .75rem;
}
.card-title { font-size: .95rem; font-weight: 600; margin: 0; color: #1e293b; }
.card-body { padding: 1.25rem; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    padding: 1.25rem;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}
.stat-card-value { font-size: 1.6rem; font-weight: 700; line-height: 1; margin-bottom: .35rem; }
.stat-card-label { font-size: .8rem; color: #64748b; font-weight: 500; }
.stat-card-trend { font-size: .78rem; margin-top: .5rem; }
.stat-card-trend.up   { color: var(--ld-success); }
.stat-card-trend.down { color: var(--ld-danger); }

.stat-icon-blue   { background: #dbeafe; color: var(--ld-primary); }
.stat-icon-green  { background: #d1fae5; color: var(--ld-success); }
.stat-icon-yellow { background: #fef3c7; color: var(--ld-warning); }
.stat-icon-purple { background: #ede9fe; color: var(--ld-info); }
.stat-icon-red    { background: #fee2e2; color: var(--ld-danger); }
.stat-icon-cyan   { background: #e0f2fe; color: var(--ld-accent); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-container {
    overflow-x: auto;
    border-radius: var(--card-radius);
}
.table { margin: 0; font-size: .875rem; }
.table thead th {
    background: #f8fafc;
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    border-top: none;
    border-bottom: 2px solid #e2e8f0;
    padding: .75rem 1rem;
    white-space: nowrap;
}
.table tbody td { padding: .8rem 1rem; vertical-align: middle; border-color: #f1f5f9; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Badges de estado ───────────────────────────────────────── */
.badge-estado { font-size: .72rem; font-weight: 600; padding: .3em .65em; border-radius: 6px; }
.badge-activo, .badge-aprobada, .badge-pagada, .badge-confirmado, .badge-aprobado, .badge-aplicada { background: #d1fae5; color: #065f46; }
.badge-inactivo, .badge-anulada, .badge-anulado, .badge-rechazado, .badge-rechazada { background: #fee2e2; color: #991b1b; }
.badge-borrador, .badge-registrado { background: #f1f5f9; color: #475569; }
.badge-enviada, .badge-emitida { background: #dbeafe; color: #1e40af; }
.badge-vencida, .badge-sin_stock { background: #fef3c7; color: #92400e; }
.badge-facturada { background: #ede9fe; color: #5b21b6; }
.badge-pagada_parcial { background: #e0f2fe; color: #0c4a6e; }
.badge-suspendido { background: #fef3c7; color: #92400e; }

/* ── Botones ────────────────────────────────────────────────── */
.btn { font-size: .855rem; font-weight: 500; border-radius: 8px; }
.btn-sm { font-size: .78rem; padding: .3rem .7rem; }
.btn-primary { background: var(--ld-primary); border-color: var(--ld-primary); }
.btn-primary:hover { background: var(--ld-primary-dark); border-color: var(--ld-primary-dark); }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; }

/* ── Formularios ────────────────────────────────────────────── */
.form-label { font-size: .82rem; font-weight: 600; color: #374151; margin-bottom: .35rem; }
.form-control, .form-select {
    font-size: .875rem;
    border-color: #d1d5db;
    border-radius: 8px;
    padding: .5rem .85rem;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--ld-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.form-text { font-size: .78rem; }
.input-group-text { font-size: .875rem; border-radius: 8px; border-color: #d1d5db; }

/* ── Filtros de búsqueda ────────────────────────────────────── */
.search-bar {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--card-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination .page-link { font-size: .8rem; border-radius: 6px !important; margin: 0 2px; }
.pagination .page-item.active .page-link { background: var(--ld-primary); border-color: var(--ld-primary); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { border-radius: 10px; font-size: .875rem; border: none; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger   { background: #fee2e2; color: #991b1b; }
.alert-warning  { background: #fef3c7; color: #92400e; }
.alert-info     { background: #dbeafe; color: #1e40af; }

/* ── Modales ────────────────────────────────────────────────── */
.modal-content { border-radius: 16px; border: none; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid #f1f5f9; padding: 1.25rem 1.5rem; }
.modal-footer { border-top: 1px solid #f1f5f9; padding: 1rem 1.5rem; }

/* ── Tabla de items (cotización/factura) ────────────────────── */
.items-table { background: #fff; border-radius: var(--card-radius); overflow: hidden; }
.items-table .table { margin: 0; }
.items-table .table th { background: #f8fafc; }
.items-table .row-item { position: relative; }
.items-table .row-item:hover .btn-remove-item { opacity: 1; }
.btn-remove-item { opacity: .4; transition: opacity .2s; }
.totales-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--card-radius);
    padding: 1.25rem;
}
.totales-row { display: flex; justify-content: space-between; align-items: center; padding: .4rem 0; }
.totales-row.total-final {
    border-top: 2px solid #e2e8f0;
    margin-top: .5rem;
    padding-top: .75rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}

/* ── Timeline (detalle documento) ───────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: .45rem; top: 0; bottom: 0; width: 2px; background: #e2e8f0; }
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.6rem; top: .3rem;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--ld-primary); border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--ld-primary);
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #94a3b8;
}
.empty-state i { font-size: 3rem; display: block; margin-bottom: 1rem; opacity: .4; }
.empty-state h5 { color: #64748b; font-size: 1rem; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay { display: block !important; }
    .main-wrapper { margin-left: 0; }
    .topbar { left: 0; }
    .topbar-menu-toggle { display: flex; }
}
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1039;
}

/* ── Utilidades ─────────────────────────────────────────────── */
.fw-600 { font-weight: 600 !important; }
.text-muted-sm { color: #94a3b8; font-size: .8rem; }
.cursor-pointer { cursor: pointer; }
.loading-spinner { display: none; }
.loading-spinner.show { display: inline-block; }
.select2-container .select2-selection--single {
    height: calc(2rem + 2px);
    border-color: #d1d5db;
    border-radius: 8px;
}
