/* ==========================================================================
   Tema moderno para Inversión (sobre AdminLTE 3 / Bootstrap 4)
   Solo estilos: no altera la estructura ni los ids usados por el JS.
   ========================================================================== */

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --text: #1f2a44;
    --muted: #6b7a90;
    --line: #e6eaf2;
    --brand: #4f6df5;
    --brand-dark: #3a54d6;
    --brand-soft: #eaeefe;
    --success: #12b76a;
    --danger: #f04438;
    --warning: #f79009;
    --info: #1c9bd8;
    --sidebar-bg: #111936;
    --sidebar-hover: rgba(255, 255, 255, .07);
    --radius: .75rem;
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 6px 18px rgba(16, 24, 40, .08);
}

/* ---------- Base ---------- */
body,
.content-wrapper,
.main-footer {
    font-family: 'Inter', 'Source Sans Pro', -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
}
.content-wrapper { background: var(--bg); }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1, h2, h3, h4, h5 { color: var(--text); letter-spacing: -.01em; }

/* ---------- Encabezado de página ---------- */
.content-header { padding: 1.25rem .5rem .75rem; }
.content-header h1 { font-size: 1.6rem; font-weight: 700; }
.breadcrumb { background: transparent; margin: 0; font-size: .85rem; }
.breadcrumb-item + .breadcrumb-item::before { color: #b3bccb; }
.breadcrumb-item.active { color: var(--muted); }

/* ---------- Barra superior ---------- */
.main-header.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    min-height: 3.6rem;
}
.main-header .nav-link { color: var(--muted); border-radius: .5rem; transition: background .15s, color .15s; }
.main-header .nav-link:hover { background: var(--brand-soft); color: var(--brand); }

/* ---------- Menú lateral ---------- */
.main-sidebar { background: var(--sidebar-bg) !important; box-shadow: none; }
.main-sidebar .brand-link {
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    padding: .9rem 1rem;
}
.main-sidebar .brand-text { font-weight: 700; letter-spacing: .02em; color: #fff; }
.main-sidebar .user-panel { border-bottom: 1px solid rgba(255, 255, 255, .08) !important; }
.main-sidebar .user-panel .info a { color: #dfe5f5; font-weight: 600; }
.nav-sidebar .nav-header {
    color: #7d8bb0;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 1rem 1rem .35rem;
}
.nav-sidebar > .nav-item { margin: 2px .5rem; }
.nav-sidebar .nav-link {
    color: #b9c3de;
    border-radius: .6rem;
    transition: background .15s, color .15s;
}
.nav-sidebar .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-sidebar .nav-link.active,
.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active {
    background: var(--brand) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(79, 109, 245, .35);
}
.nav-sidebar .nav-treeview > .nav-item > .nav-link.active {
    background: var(--sidebar-hover) !important;
    box-shadow: none;
    color: #fff !important;
}
.nav-sidebar .nav-icon { opacity: .9; }

/* ---------- Tarjetas ---------- */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}
.card-outline { border-top-width: 1px; }
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: .9rem 1.25rem;
}
.card-header .card-title { font-weight: 700; }
.card-body { padding: 1.25rem; }
.card-footer { background: transparent; border-top: 1px solid var(--line); }
.card.card-outline.card-primary,
.card.card-outline.card-warning,
.card.card-outline.card-info,
.card.card-outline.card-success,
.card.card-outline.card-danger { border-top: 1px solid var(--line); }

/* ---------- Botones ---------- */
.btn {
    border-radius: .55rem;
    font-weight: 600;
    padding: .45rem .95rem;
    transition: transform .1s, box-shadow .15s, background-color .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:focus, .btn.focus { box-shadow: 0 0 0 .2rem var(--brand-soft); }
.btn i, .btn svg { margin-right: .3rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-info { background: var(--info); border-color: var(--info); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--text); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn:active { transform: translateY(0); }
.btn-sm { padding: .25rem .6rem; border-radius: .45rem; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-info { background: var(--info); border-color: var(--info); color: #fff; }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-success:hover, .btn-danger:hover, .btn-warning:hover, .btn-info:hover {
    box-shadow: var(--shadow-md);
}
.btn:focus { box-shadow: 0 0 0 .2rem rgba(79, 109, 245, .25); }

/* ---------- Formularios ---------- */
.form-control, .custom-select, .select2-container--default .select2-selection--single {
    border: 1px solid #d5dbe8;
    border-radius: .55rem;
    background: #fff;
    min-height: calc(1.5em + .8rem + 2px);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .custom-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(79, 109, 245, .15);
}
label, .control-label { font-weight: 600; font-size: .85rem; color: #3b4863; }
.input-group-text { border-radius: .55rem; background: #f1f4fa; border-color: #d5dbe8; color: var(--muted); }
.has-error .form-control, .form-control.is-invalid { border-color: var(--danger); }
.help-block, .invalid-feedback { font-size: .8rem; }
.custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--brand);
    border-color: var(--brand);
}

/* ---------- Tablas y GridView ---------- */
.table { color: var(--text); }
.table thead th {
    background: #f7f9fd;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: middle;
}
.table thead th a { color: var(--muted); }
.table td { vertical-align: middle; border-color: var(--line); }
.table-bordered, .table-bordered td, .table-bordered th { border-color: var(--line); }
.table-striped tbody tr:nth-of-type(odd) { background: #fafbfe; }
.table-hover tbody tr:hover,
.grid-view tbody tr:hover { background: var(--brand-soft); }
.grid-view .filters input,
.grid-view .filters select { font-size: .85rem; padding: .25rem .5rem; min-height: 0; }
.table td a { color: var(--muted); margin: 0 .15rem; }
.table td a:hover { color: var(--brand); }
.summary { color: var(--muted); font-size: .82rem; margin-bottom: .5rem; }
.table-responsive { border-radius: var(--radius); }
td.bg-success, .bg.bg-success { background-color: rgba(18, 183, 106, .15) !important; color: #067647 !important; }

/* Paginación */
.pagination .page-link {
    border: 0;
    margin: 0 2px;
    border-radius: .5rem;
    color: var(--muted);
}
.pagination .page-item.active .page-link { background: var(--brand); color: #fff; }
.pagination .page-link:hover { background: var(--brand-soft); color: var(--brand); }

/* ---------- Insignias y alertas ---------- */
.badge { border-radius: 2rem; padding: .35em .7em; font-weight: 600; }
.alert { border: 0; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.alert-info { background: #e8f4fc; color: #0b5d8a; }
.alert-success { background: #e7f8ef; color: #067647; }
.alert-danger { background: #fdecea; color: #b42318; }
.alert-warning { background: #fff4e0; color: #93500a; }
.progress { background: #e9edf5; border-radius: 1rem; overflow: hidden; }

/* ---------- Modales ---------- */
.modal-content {
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 20px 50px rgba(16, 24, 40, .25);
    overflow: hidden;
}
.modal-header { border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; }
.modal-title { font-weight: 700; }
.modal-footer { border-top: 1px solid var(--line); }
.modal-backdrop.show { opacity: .45; }

/* ---------- Menús desplegables ---------- */
.dropdown-menu {
    border: 1px solid var(--line);
    border-radius: .75rem;
    box-shadow: var(--shadow-md);
    padding: .4rem;
}
.dropdown-item { border-radius: .5rem; padding: .45rem .8rem; }
.dropdown-item:hover { background: var(--brand-soft); color: var(--brand); }

/* ---------- Detalle (DetailView) ---------- */
.detail-view th { width: 25%; color: var(--muted); font-weight: 600; background: #fafbfe; }

/* ---------- Pie de página ---------- */
.main-footer {
    background: transparent;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .82rem;
}

/* ---------- Barra de scroll ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c9d1e2; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #a9b4cc; }

/* ---------- Inicio de sesión ---------- */
body.login-page {
    background: linear-gradient(135deg, #111936 0%, #2b3a8c 55%, #4f6df5 100%) !important;
    min-height: 100vh;
}
body.login-page .login-box { width: 400px; max-width: 92vw; }
body.login-page .login-form { width: 100%; }
body.login-page .login-form form {
    border-radius: 1rem !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .3) !important;
    padding: 2rem !important;
}
body.login-page .login-form h2 { font-size: 1.6rem; font-weight: 700; text-align: center; color: var(--text); }
body.login-page .form-control {
    background: #fff !important;
    border: 1px solid #d5dbe8 !important;
    border-radius: .55rem !important;
}
body.login-page .login-form .btn {
    background: var(--brand) !important;
    border-radius: .55rem !important;
    width: 100%;
}
body.login-page .login-form .btn:hover { background: var(--brand-dark) !important; }
body.login-page .login-form a { color: var(--brand); }

/* ---------- Botones de acción en grids ---------- */
.table td a[data-pjax],
.table td a[aria-label],
.table td a[title]:has(> i, > svg) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0 .15rem;
    border-radius: .5rem;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--line);
    font-size: .85rem;
    text-decoration: none;
    transition: background .15s, color .15s, border-color .15s, transform .15s, box-shadow .15s;
}
.table td a[data-pjax]:hover,
.table td a[aria-label]:hover,
.table td a[title]:has(> i, > svg):hover {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: var(--brand);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.table td a[href*="delete"]:hover,
.table td a[data-method="post"]:hover {
    background: #fee4e2;
    color: var(--danger);
    border-color: var(--danger);
}
.table td a[href*="view"]:hover { background: #e0f2fb; color: var(--info); border-color: var(--info); }
.table td a svg, .table td a i { pointer-events: none; }

/* ---------- Dashboard: KPIs y gráficas ---------- */
.kpi-card .card-body { position: relative; padding: 1rem; }
.kpi-card { border-left: 4px solid var(--brand); }
.kpi-card.kpi-success { border-left-color: var(--success); }
.kpi-card.kpi-danger { border-left-color: var(--danger); }
.kpi-card.kpi-warning { border-left-color: var(--warning); }
.kpi-card.kpi-info { border-left-color: var(--info); }
.kpi-card.kpi-secondary { border-left-color: var(--muted); }
.kpi-icon { position: absolute; top: .9rem; right: 1rem; font-size: 1.2rem; color: var(--muted); opacity: .45; }
.kpi-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.35rem; font-weight: 700; color: var(--text); margin: .15rem 0; }
.kpi-sub { font-size: .75rem; color: var(--muted); }
.stat-card .card-body { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.stat-card { overflow: hidden; transition: transform .15s, box-shadow .15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
    flex: 0 0 3.2rem; height: 3.2rem; border-radius: .9rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; color: #fff; background: var(--brand);
    box-shadow: 0 4px 10px rgba(79, 109, 245, .3);
}
.stat-success .stat-icon { background: var(--success); box-shadow: 0 4px 10px rgba(18, 183, 106, .3); }
.stat-danger .stat-icon { background: var(--danger); box-shadow: 0 4px 10px rgba(240, 68, 56, .3); }
.stat-warning .stat-icon { background: var(--warning); box-shadow: 0 4px 10px rgba(247, 144, 9, .3); }
.stat-info .stat-icon { background: var(--info); box-shadow: 0 4px 10px rgba(28, 155, 216, .3); }
.stat-info, .stat-info-box { min-width: 0; flex: 1; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-badge { font-size: .7rem; vertical-align: middle; margin-left: .35rem; padding: .25em .55em; border-radius: 999px; }
.chart-card .card-title { font-size: .95rem; font-weight: 600; }
.meta-top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: .75rem; }
.meta-monto { font-size: 1.8rem; font-weight: 700; line-height: 1.1; color: var(--text); }
.meta-pct { font-size: 2rem; font-weight: 700; line-height: 1; }
.meta-bar { position: relative; height: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: visible; }
.meta-fill { height: 100%; border-radius: 999px; transition: width .6s ease; }
.meta-marca { position: absolute; top: -4px; width: 2px; height: 20px; background: var(--text); opacity: .55; border-radius: 1px; }
.meta-pie { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .25rem; margin-top: .75rem; font-size: .85rem; }
.chart-box { position: relative; height: 280px; }

/* ---------- Estilos Generales de Modales ---------- */
.modal-dialog {
    transition: transform .2s ease-out;
}
.modal-content {
    border: 0;
    border-radius: 1.15rem;
    box-shadow: 0 25px 60px rgba(17, 25, 54, 0.25);
    overflow: hidden;
}
.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 1.1rem 1.4rem;
}
.modal-header .close {
    font-size: 1.6rem;
    font-weight: 400;
    opacity: 0.7;
    transition: opacity .15s;
    text-shadow: none;
    outline: none;
}
.modal-header .close:hover { opacity: 1; }
.modal-body {
    padding: 1.25rem 1.4rem;
}
.modal-summary-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    padding: 0.85rem 1rem;
}
.modal-summary-box .summary-tile {
    padding: 0.4rem 0.5rem;
}
.modal-summary-box .summary-tile b {
    font-size: 1.05rem;
    display: block;
    line-height: 1.2;
}

/* Evitar salto/wrap feo en input groups */
.input-group {
    flex-wrap: nowrap !important;
}
.input-group > .form-group {
    margin-bottom: 0 !important;
}
.input-group > .form-control,
.input-group > .form-group > .form-control {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}
.input-group-prepend > .input-group-text {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    font-weight: 600;
}

/* ---------- Optimización para Dispositivos Móviles ---------- */
@media (max-width: 991.98px) {
    .main-sidebar {
        box-shadow: 0 0 30px rgba(0,0,0,0.4) !important;
    }
    .mv-hero .mv-actions {
        width: 100%;
        margin-top: 0.5rem;
    }
}

@media (max-width: 767.98px) {
    /* Header y navegación */
    .content-header { padding: 0.85rem 0.5rem 0.5rem; }
    .content-header h1 { font-size: 1.25rem; font-weight: 700; }
    .breadcrumb { float: none !important; margin-top: .2rem; font-size: .8rem; }
    .main-header.navbar { padding: .4rem .6rem; min-height: 3.2rem; }

    /* Tarjetas y contenedores */
    .card { border-radius: .75rem; margin-bottom: .85rem; }
    .card-header { padding: .75rem 1rem; }
    .card-body { padding: .95rem; }
    .card-title { font-size: 1rem; }

    /* Modales en móvil */
    .modal-dialog {
        margin: 0.4rem auto;
        max-width: 96vw;
    }
    .modal-content {
        border-radius: 1rem;
    }
    .modal-header {
        padding: 0.85rem 1rem;
    }
    .modal-body {
        padding: 1rem;
    }
    .modal-title {
        font-size: 1.15rem;
    }
    .form-control, .custom-select {
        font-size: 16px !important; /* Previene auto-zoom en iOS */
        min-height: 2.75rem;
    }
    .form-control-lg, .custom-select-lg {
        font-size: 16px !important;
        height: 2.9rem;
    }
    .input-group-text {
        font-size: 0.95rem;
        padding: 0.375rem 0.65rem;
    }

    /* Resumen en vivo de modales (2x2 en móvil) */
    .modal-summary-box .row > div {
        margin-bottom: 0.5rem;
    }
    .modal-summary-box .summary-tile b {
        font-size: 0.95rem !important;
    }

    /* Detalle de Moneda (views/moneda/view.php) */
    .mv-hero {
        padding: 0;
    }
    .mv-hero .card-body {
        padding: 1rem;
    }
    .mv-hero .mv-price {
        font-size: 1.35rem;
    }
    .mv-actions {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem !important;
    }
    .mv-actions > .btn,
    .mv-actions > .btn-group,
    .mv-actions > a {
        width: 100%;
    }
    .mv-actions .btn-group {
        display: flex;
    }
    .mv-actions .btn-group .btn {
        flex: 1;
        font-size: 0.82rem;
        padding: 0.45rem 0.35rem;
    }

    /* KPIs en móvil */
    .mv-kpi {
        border-radius: .65rem;
    }
    .mv-kpi .card-body {
        padding: .75rem .6rem !important;
    }
    .mv-kpi .mv-label {
        font-size: .65rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mv-kpi .mv-value {
        font-size: 1.1rem;
        word-break: break-all;
        line-height: 1.2;
    }
    .mv-kpi .mv-sub {
        font-size: .7rem;
    }

    /* Sumario de selección ("Si vendes lo seleccionado") */
    .mv-sum-item {
        flex: 0 0 calc(50% - 0.5rem);
        padding: 0.4rem 0.25rem;
        background: #fff;
        border-radius: 0.5rem;
        border: 1px solid var(--line);
        margin-bottom: 0.35rem;
    }
    .mv-sum-item b {
        font-size: 0.95rem;
    }

    /* Stat cards del dashboard */
    .stat-card .card-body {
        padding: 0.85rem 1rem;
        gap: 0.75rem;
    }
    .stat-icon {
        flex: 0 0 2.75rem;
        height: 2.75rem;
        font-size: 1.15rem;
        border-radius: .7rem;
    }
    .stat-value {
        font-size: 1.25rem;
    }
    .kpi-label {
        font-size: .7rem;
    }
    .kpi-sub {
        font-size: .72rem;
    }

    /* Tablas y GridView en móvil */
    .table-responsive {
        border: 1px solid var(--line);
        border-radius: var(--radius);
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0.5rem;
    }
    .table thead th {
        font-size: .68rem;
        padding: .55rem .5rem;
    }
    .table tbody td {
        font-size: .82rem;
        padding: .55rem .5rem;
        white-space: nowrap;
    }
    .table td a[data-pjax],
    .table td a[aria-label],
    .table td a[title]:has(> i, > svg),
    .table td .btnVender {
        min-height: 2rem;
        padding: .25rem .5rem;
    }

    /* Callout en móvil */
    .callout {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Chips y filtros */
    .mv-chip {
        font-size: 0.75rem;
        padding: 0.15rem 0.55rem;
        margin-bottom: 0.25rem;
    }
}

@media (max-width: 480px) {
    .mv-kpi .mv-value {
        font-size: 0.98rem;
    }
    .stat-value {
        font-size: 1.15rem;
    }
}

