/* =====================================================
   ERP AyL - Estilos globales
   ===================================================== */

/* ==============================
   VARIABLES / BASE
============================== */

:root {
    --azul-principal: #326199;
    --azul-oscuro: #254b78;
    --azul-claro: #e8f0fa;

    --gris-fondo: #f4f6f9;
    --gris-borde: #d8dee6;

    --texto: #2c3e50;
    --texto-suave: #6c757d;

    --blanco: #ffffff;
}

html,
body {
    min-height: 100%;
}

body {
    min-height: 100vh;
    background-color: var(--gris-fondo);
    color: var(--texto);
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
    flex-direction: column;
}

/* ==============================
   HEADER / RIBBON
============================== */

.erp-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--gris-borde);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}

.erp-topbar {
    background-color: var(--azul-principal);
    color: #ffffff;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
}

.erp-brand a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.erp-brand a:hover {
    color: #ffffff;
}

.erp-brand-logo {
    height: 48px;
    max-width: 220px;
    object-fit: contain;
    background-color: #ffffff;
    border-radius: 6px;
    padding: 4px 8px;
}

.erp-user-info {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 0.88rem;
}

.erp-user-info span {
    white-space: nowrap;
}

/* Pestañas principales */

.erp-tabs {
    background-color: #f8f9fb;
    display: flex;
    align-items: end;
    gap: 2px;
    padding: 7px 14px 0 14px;
    border-bottom: 1px solid var(--gris-borde);
    overflow-x: auto;
}

.erp-tab {
    border: 1px solid transparent;
    background: transparent;
    color: #34495e;
    padding: 8px 14px;
    font-size: 0.90rem;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s ease-in-out;
}

.erp-tab i {
    margin-right: 5px;
}

.erp-tab:hover {
    background-color: #edf2f7;
}

.erp-tab.active {
    background-color: #ffffff;
    color: var(--azul-principal);
    border-color: var(--gris-borde);
    border-bottom-color: #ffffff;
    font-weight: 600;
}

/* Ribbon */

.erp-ribbon {
    background-color: #ffffff;
    min-height: 92px;
    padding: 10px 14px;
}

.erp-ribbon-panel {
    display: none;
    align-items: stretch;
    gap: 8px;
    flex-wrap: wrap;
}

.erp-ribbon-panel.active {
    display: flex;
}

.erp-ribbon-btn {
    width: 108px;
    min-height: 72px;
    text-decoration: none;
    color: #2c3e50;
    border: 1px solid transparent;
    border-radius: 8px;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 6px;
    text-align: center;
    transition: all 0.18s ease-in-out;
}

.erp-ribbon-btn i {
    font-size: 1.45rem;
    color: var(--azul-principal);
}

.erp-ribbon-btn span {
    font-size: 0.78rem;
    line-height: 1.1;
}

.erp-ribbon-btn:hover {
    background-color: var(--azul-claro);
    border-color: #b9cbe0;
    color: var(--azul-oscuro);
    transform: translateY(-1px);
}

/* ==============================
   CONTENIDO / LAYOUT
============================== */

.erp-main {
    width: calc(95% - 70px);
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    flex: 1;
}

.container-fluid {
    padding-left: 22px;
    padding-right: 22px;
}

.erp-footer {
    margin-top: auto;
    text-align: center;
    padding: 12px 0;
    color: #6c757d;
    font-size: 0.85rem;
}

/* ==============================
   CARDS / HEADERS
============================== */

.card {
    border-radius: 10px;
    border: none;
}

.card.shadow-sm {
    box-shadow: 0 4px 14px rgba(50, 97, 153, 0.08) !important;
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
}

.card-header-azul {
    background-color: var(--azul-principal);
}

.card-header.bg-light {
    background: linear-gradient(180deg, #ffffff, #eef3f8) !important;
    color: #1f2937 !important;
    border-bottom: 1px solid #cbd5e1;
    font-weight: 700;
}

.card-header.bg-light strong {
    color: #1f2937;
    font-weight: 700;
}

.card-header.bg-light i {
    color: var(--azul-principal);
}

/* ==============================
   FORMULARIOS / BOTONES
============================== */

.form-control,
.form-select {
    border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--azul-principal);
    box-shadow: 0 0 0 0.15rem rgba(50, 97, 153, 0.25);
}

.btn-proceso {
    background-color: var(--azul-principal);
    color: white;
    border: none;
}

.btn-proceso:hover {
    background-color: var(--azul-oscuro);
    color: white;
}

.form-inline-delete {
    display: inline-block;
}

/* ==============================
   TABLAS / BADGES / TEXTOS
============================== */

.table thead {
    background-color: var(--azul-principal);
    color: white;
}

.table-hover tbody tr:hover {
    background-color: #eef3f8;
}

.alert {
    border-radius: 8px;
}

.texto-secundario {
    font-size: 0.75rem;
    color: #6c757d;
}

.texto-endpoint {
    font-size: 0.72rem;
    color: #7f8c8d;
    margin-top: 2px;
}

.badge-accion {
    background-color: var(--azul-principal);
    color: #ffffff;
    font-weight: 500;
}

.icono-error-grande {
    font-size: 4rem;
}

/* ==============================
   PERMISOS / BITÁCORA / USUARIOS
============================== */

.tabla-permisos th {
    white-space: nowrap;
}

.fila-menu-padre {
    background-color: #eef3f8;
}

.fila-menu-padre td {
    border-top: 2px solid #c8d6e5;
}

.fila-menu-hijo td:first-child {
    padding-left: 34px;
}

.permiso-hijo {
    display: inline-block;
}

.tabla-bitacora {
    font-size: 0.88rem;
}

.tabla-bitacora .col-fecha {
    white-space: nowrap;
    min-width: 150px;
}

.descripcion-bitacora {
    max-width: 420px;
}

.col-empresas-acceso {
    max-width: 280px;
}

.badge-empresas-acceso {
    background-color: #e8f0fa;
    color: #254b78;
    border: 1px solid #c9d8ea;
    font-weight: 500;
    white-space: normal;
    text-align: left;
    line-height: 1.4;
    padding: 6px 8px;
}

/* ==============================
   LOGIN
============================== */

.login-header {
    background-color: var(--azul-principal);
}

.login-logo {
    max-height: 75px;
    max-width: 230px;
    object-fit: contain;
    background-color: #ffffff;
    border-radius: 8px;
    padding: 6px 10px;
}

/* ==============================
   COMPONENTES REUTILIZABLES ERP
============================== */

.modulo-hero {
    background: linear-gradient(135deg, var(--azul-principal), var(--azul-oscuro));
    color: #ffffff;
    border-radius: 14px;
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}

.modulo-hero h4 {
    font-weight: 700;
}

.modulo-hero p {
    color: rgba(255, 255, 255, 0.85);
}

.modulo-hero-actions {
    display: flex;
    gap: 8px;
}

.kpi-card {
    background-color: #ffffff;
    border: 1px solid #d8dee6;
    border-radius: 14px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 96px;
    box-shadow: 0 4px 14px rgba(50, 97, 153, 0.08);
}

.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background-color: #e8f0fa;
    color: var(--azul-principal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.kpi-label {
    color: #6c757d;
    font-size: 0.85rem;
}

.kpi-value {
    color: var(--texto);
    font-size: 1.25rem;
    font-weight: 700;
}

.kpi-card-warning .kpi-icon {
    background-color: #fff3cd;
    color: #996404;
}

.mini-card {
    border: 1px solid #d8dee6;
    border-radius: 12px;
    padding: 14px;
    background-color: #ffffff;
    transition: all 0.15s ease-in-out;
}

.contact-card {
    border: 1px solid #d8dee6;
    border-radius: 12px;
    padding: 12px;
    background-color: #f8fafc;
    transition: all 0.15s ease-in-out;
}

.mini-card:hover,
.contact-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(50, 97, 153, 0.12);
}

.timeline-demo {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
    border-left: 2px solid #d8dee6;
}

.timeline-demo li {
    position: relative;
    padding-left: 14px;
    margin-bottom: 14px;
}

.timeline-demo li:last-child {
    margin-bottom: 0;
}

.timeline-demo li::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 4px;
    width: 10px;
    height: 10px;
    background-color: var(--azul-principal);
    border-radius: 50%;
}

.timeline-title {
    font-weight: 600;
    color: var(--texto);
}

.timeline-meta {
    font-size: 0.8rem;
    color: #6c757d;
}

/* ==============================
   TEMPORAL MÓDULOS
   Luego podemos moverlo a modulos/clientes.css
============================== */

.tabla-clientes td {
    vertical-align: middle;
}

/* ==============================
   RESPONSIVE
============================== */

@media (max-width: 768px) {
    .erp-main {
        width: 100%;
        padding-left: 12px;
        padding-right: 12px;
    }

    .erp-topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 10px 14px;
        gap: 8px;
    }

    .erp-user-info {
        gap: 8px;
    }

    .erp-ribbon {
        min-height: auto;
    }

    .erp-ribbon-btn {
        width: 96px;
        min-height: 68px;
    }

    .modulo-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .modulo-hero-actions {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* =====================================================
   TEMA OSCURO
   ===================================================== */

body.tema-oscuro {
    --azul-principal: #2563eb;
    --azul-oscuro: #1d4ed8;
    --azul-claro: #1e3a5f;
    --gris-fondo: #0f172a;
    --gris-borde: #334155;
    --texto: #e5e7eb;
    --texto-suave: #9ca3af;

    background-color: #0f172a;
    color: #e5e7eb;
}

/* Header / Ribbon */

body.tema-oscuro .erp-header {
    background-color: #111827;
    border-bottom-color: #334155;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

body.tema-oscuro .erp-topbar {
    background-color: #111827;
    border-bottom: 1px solid #334155;
}

body.tema-oscuro .erp-tabs {
    background-color: #1f2937;
    border-bottom-color: #334155;
}

body.tema-oscuro .erp-tab {
    color: #d1d5db;
}

body.tema-oscuro .erp-tab:hover {
    background-color: #374151;
    color: #ffffff;
}

body.tema-oscuro .erp-tab.active {
    background-color: #0f172a;
    color: #93c5fd;
    border-color: #334155;
    border-bottom-color: #0f172a;
}

body.tema-oscuro .erp-ribbon {
    background-color: #0f172a;
    border-bottom: 1px solid #334155;
}

body.tema-oscuro .erp-ribbon-btn {
    background-color: #111827;
    color: #e5e7eb;
    border-color: #1f2937;
}

body.tema-oscuro .erp-ribbon-btn i {
    color: #93c5fd;
}

body.tema-oscuro .erp-ribbon-btn:hover {
    background-color: #1e3a5f;
    border-color: #3b82f6;
    color: #ffffff;
}

/* Layout / Footer */

body.tema-oscuro .erp-main {
    color: #e5e7eb;
}

body.tema-oscuro .erp-footer {
    color: #9ca3af;
}

/* Cards */

body.tema-oscuro .card {
    background-color: #111827;
    color: #e5e7eb;
    border: 1px solid #334155;
}

body.tema-oscuro .card-body {
    background-color: #111827;
    color: #e5e7eb;
}

body.tema-oscuro .card-header {
    background-color: #172033 !important;
    color: #f9fafb !important;
    border-bottom: 1px solid #334155;
}

body.tema-oscuro .card-header-azul {
    background-color: #1e3a5f;
    border-bottom: 1px solid #334155;
}

body.tema-oscuro .card-header.bg-light {
    background: linear-gradient(180deg, #1f2937, #172033) !important;
    color: #f9fafb !important;
    border-bottom: 1px solid #334155;
}

body.tema-oscuro .card-header.bg-light strong {
    color: #f9fafb;
}

body.tema-oscuro .card-header.bg-light i {
    color: #93c5fd;
}

body.tema-oscuro .border-0 {
    border-color: #334155 !important;
}

/* Textos */

body.tema-oscuro .text-muted,
body.tema-oscuro .texto-secundario,
body.tema-oscuro .texto-endpoint {
    color: #9ca3af !important;
}

body.tema-oscuro strong {
    color: #f9fafb;
}

body.tema-oscuro code {
    color: #93c5fd;
    background-color: #1f2937;
    padding: 2px 4px;
    border-radius: 4px;
}

body.tema-oscuro hr {
    border-color: #334155;
    opacity: 1;
}

/* Formularios */

body.tema-oscuro .form-control,
body.tema-oscuro .form-select,
body.tema-oscuro textarea {
    background-color: #1f2937;
    color: #f9fafb;
    border-color: #374151;
}

body.tema-oscuro .form-control:focus,
body.tema-oscuro .form-select:focus,
body.tema-oscuro textarea:focus {
    background-color: #1f2937;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.15rem rgba(59, 130, 246, 0.35);
}

body.tema-oscuro .form-control::placeholder {
    color: #9ca3af;
}

body.tema-oscuro .form-label {
    color: #e5e7eb;
}

/* Tablas Bootstrap */

body.tema-oscuro .table {
    --bs-table-color: #e5e7eb;
    --bs-table-bg: #111827;
    --bs-table-border-color: #334155;
    --bs-table-striped-color: #e5e7eb;
    --bs-table-striped-bg: #172033;
    --bs-table-hover-color: #ffffff;
    --bs-table-hover-bg: #1f2937;

    color: #e5e7eb;
    background-color: #111827;
    border-color: #334155;
}

body.tema-oscuro .table > :not(caption) > * > * {
    background-color: #111827;
    color: #e5e7eb;
    border-color: #334155;
    box-shadow: none;
}

body.tema-oscuro .table-hover > tbody > tr:hover > * {
    background-color: #1f2937;
    color: #ffffff;
}

body.tema-oscuro .table thead th,
body.tema-oscuro .table thead td {
    background-color: #1e3a5f;
    color: #ffffff;
    border-color: #334155;
}

body.tema-oscuro .table a {
    color: #93c5fd;
}

body.tema-oscuro .table a:hover {
    color: #bfdbfe;
}

body.tema-oscuro .table .text-muted,
body.tema-oscuro .table .texto-secundario,
body.tema-oscuro .table .texto-endpoint {
    color: #9ca3af !important;
}

/* List groups */

body.tema-oscuro .list-group-item {
    background-color: #111827;
    color: #e5e7eb;
    border-color: #334155;
}

body.tema-oscuro .list-group-flush .list-group-item {
    border-color: #334155;
}

/* Permisos */

body.tema-oscuro .fila-menu-padre {
    background-color: #1f2937;
}

body.tema-oscuro .fila-menu-padre td {
    border-top-color: #475569;
}

body.tema-oscuro .table tbody tr.fila-menu-padre > td {
    background-color: #1f2937;
    color: #f9fafb;
}

body.tema-oscuro .table tbody tr.fila-menu-hijo > td {
    background-color: #111827;
    color: #e5e7eb;
}

/* Alerts */

body.tema-oscuro .alert-info {
    background-color: #1e3a5f;
    color: #dbeafe;
    border-color: #3b82f6;
}

body.tema-oscuro .alert-warning {
    background-color: #4a3513;
    color: #fde68a;
    border-color: #f59e0b;
}

body.tema-oscuro .alert-danger {
    background-color: #4c1d1d;
    color: #fecaca;
    border-color: #ef4444;
}

body.tema-oscuro .alert-success {
    background-color: #064e3b;
    color: #bbf7d0;
    border-color: #10b981;
}

/* Botones */

body.tema-oscuro .btn-proceso {
    background-color: #2563eb;
    color: #ffffff;
}

body.tema-oscuro .btn-proceso:hover {
    background-color: #1d4ed8;
    color: #ffffff;
}

body.tema-oscuro .btn-light {
    background-color: #e5e7eb;
    color: #111827;
    border-color: #d1d5db;
}

body.tema-oscuro .btn-secondary {
    background-color: #374151;
    border-color: #4b5563;
    color: #ffffff;
}

body.tema-oscuro .btn:disabled,
body.tema-oscuro .btn.disabled {
    opacity: 0.55;
}

body.tema-oscuro .btn-outline-primary {
    color: #93c5fd;
    border-color: #3b82f6;
}

body.tema-oscuro .btn-outline-primary:hover {
    color: #ffffff;
    background-color: #2563eb;
    border-color: #2563eb;
}

body.tema-oscuro .btn-outline-success {
    color: #86efac;
    border-color: #22c55e;
}

body.tema-oscuro .btn-outline-success:hover {
    color: #ffffff;
    background-color: #16a34a;
    border-color: #16a34a;
}

body.tema-oscuro .btn-outline-danger {
    color: #fca5a5;
    border-color: #ef4444;
}

body.tema-oscuro .btn-outline-danger:hover {
    color: #ffffff;
    background-color: #dc2626;
    border-color: #dc2626;
}

body.tema-oscuro .btn-outline-secondary:disabled,
body.tema-oscuro .btn-outline-secondary.disabled {
    color: #64748b;
    border-color: #475569;
    background-color: transparent;
}

/* Badges */

body.tema-oscuro .badge.bg-secondary {
    background-color: #4b5563 !important;
    color: #ffffff;
}

body.tema-oscuro .badge.bg-success {
    background-color: #047857 !important;
    color: #ffffff;
}

body.tema-oscuro .badge.bg-primary {
    background-color: #2563eb !important;
    color: #ffffff;
}

body.tema-oscuro .badge.bg-danger {
    background-color: #dc2626 !important;
    color: #ffffff;
}

body.tema-oscuro .badge-empresas-acceso {
    background-color: #1f2937;
    color: #bfdbfe;
    border-color: #334155;
}

/* Componentes ERP */

body.tema-oscuro .modulo-hero {
    background: linear-gradient(135deg, #1e3a5f, #111827);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

body.tema-oscuro .kpi-card {
    background-color: #111827;
    border-color: #334155;
    box-shadow: none;
}

body.tema-oscuro .kpi-icon {
    background-color: #1f2937;
    color: #93c5fd;
}

body.tema-oscuro .kpi-label {
    color: #9ca3af;
}

body.tema-oscuro .kpi-value {
    color: #f9fafb;
}

body.tema-oscuro .kpi-card-warning .kpi-icon {
    background-color: #451a03;
    color: #facc15;
}

body.tema-oscuro .mini-card,
body.tema-oscuro .contact-card {
    background-color: #111827;
    border-color: #334155;
    color: #e5e7eb;
}

body.tema-oscuro .contact-card {
    background-color: #172033;
}

body.tema-oscuro .timeline-demo {
    border-left-color: #334155;
}

body.tema-oscuro .timeline-demo li::before {
    background-color: #93c5fd;
}

body.tema-oscuro .timeline-title {
    color: #f9fafb;
}

body.tema-oscuro .timeline-meta {
    color: #9ca3af;
}

/* Leyendas / ayudas de formulario */
.form-text {
    color: #6c757d;
}

/* Tema oscuro */
body.dark-mode .form-text,
html[data-bs-theme="dark"] .form-text,
[data-theme="dark"] .form-text {
    color: #cbd5e1 !important;
}

.ayuda-formulario {
    font-size: 0.86rem;
}

body.dark-mode .ayuda-formulario,
html[data-bs-theme="dark"] .ayuda-formulario,
[data-theme="dark"] .ayuda-formulario {
    color: #dbeafe !important;
}

.json-viewer-box {
    max-height: 520px;
    overflow: auto;
    white-space: pre-wrap;
    background-color: #0b1220;
    color: #e5e7eb;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.875rem;
}

.error-viewer-box {
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    background-color: #1f1111;
    color: #ffb4b4;
    border: 1px solid rgba(248, 113, 113, 0.45);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.875rem;
}