:root {
    --sidebar-bg: #16324F;
    --sidebar-w: 240px;
    --bg-color: #F5F8FA;
    --card-bg: #FFFFFF;
    --brand-blue: #0284C7;
    --brand-blue-hover: #026ca3;
    --brand-green: #22A06B;
    --brand-green-hover: #1C8559;
    --text-main: #1F2937;
    --text-muted: #6B7280;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background-color: var(--bg-color) !important;
    color: var(--text-main) !important;
    margin: 0;
    padding: 0;
}

/* ─── Layout ────────────────────────────────────────────────────── */
.app-layout { min-height: 100vh; }

@media (min-width: 992px) {
    .app-content { margin-left: var(--sidebar-w); }
}

/* ─── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.25s ease;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-head img {
    height: 35px;
    filter: brightness(0) invert(1);
}
.sidebar-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: #CBD5E1;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: background 0.2s;
    font-size: 0.9rem;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 700; }
.sidebar-nav a .material-symbols-rounded { font-size: 1.25rem; }
.sidebar-label {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    padding: 0.75rem 0.75rem 0.25rem;
}
.sidebar-nav hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 0.75rem 0;
}

/* Mobile: sidebar hidden by default */
@media (max-width: 991.98px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.show { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1049;
    }
    .sidebar-overlay.show { display: block; }
}

/* Desktop: always visible */
@media (min-width: 992px) {
    #sidebar { transform: translateX(0) !important; }
    .sidebar-overlay { display: none !important; }
    .sidebar-close { display: none !important; }
}

/* ─── Desktop navbar ────────────────────────────────────────────── */
.desktop-navbar {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    min-height: 60px;
}
.desktop-navbar .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* ─── Main content ──────────────────────────────────────────────── */
.main-content { flex: 1; overflow-y: auto; }

.card {
    background-color: var(--card-bg) !important;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
}

.text-dark, h1, h2, h3, h4, h5, h6 { color: var(--text-main) !important; }
.text-muted { color: var(--text-muted) !important; }

.text-soft-blue { color: var(--brand-blue) !important; }
.bg-soft-blue-subtle { background-color: rgba(2, 132, 199, 0.15) !important; }
.btn-soft-blue { background-color: var(--brand-blue) !important; border-color: var(--brand-blue) !important; color: white !important; }
.btn-soft-blue:hover { background-color: var(--brand-blue-hover) !important; border-color: var(--brand-blue-hover) !important; color: white !important; }

.btn-primary {
    --bs-btn-bg: var(--brand-blue);
    --bs-btn-border-color: var(--brand-blue);
    --bs-btn-hover-bg: var(--brand-blue-hover);
    --bs-btn-hover-border-color: var(--brand-blue-hover);
    --bs-btn-active-bg: var(--brand-blue-hover);
    --bs-btn-active-border-color: var(--brand-blue-hover);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-blue);
    --bs-btn-border-color: var(--brand-blue);
    --bs-btn-hover-bg: var(--brand-blue);
    --bs-btn-hover-border-color: var(--brand-blue);
}
.text-primary { color: rgba(2, 132, 199, var(--bs-text-opacity, 1)) !important; }
.bg-primary { background-color: rgba(2, 132, 199, var(--bs-bg-opacity, 1)) !important; }

.text-custom-success { color: var(--brand-green) !important; }
.bg-custom-success-subtle { background-color: rgba(34, 160, 107, 0.15) !important; }
.btn-custom-success { background-color: var(--brand-green) !important; border-color: var(--brand-green) !important; color: white !important; }
.btn-custom-success:hover { background-color: var(--brand-green-hover) !important; border-color: var(--brand-green-hover) !important; color: white !important; }

.table-responsive .dataTables_wrapper { width: 100%; }
.table-responsive .dataTables_wrapper .row { margin-left: 0 !important; margin-right: 0 !important; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
    .table-responsive table,
    .table-responsive .matrix-table {
        min-width: 700px;
    }
}
@media (min-width: 768px) {
    .table-responsive { overflow-x: visible !important; }
}

.custom-underline-tabs {
    border-bottom: 1px solid #e2e8f0 !important;
    gap: 1.5rem;
}
.custom-underline-tabs .nav-link {
    color: #64748b !important;
    font-weight: 600;
    padding: 0.75rem 0.25rem !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    background: transparent !important;
    transition: all 0.2s;
}
.custom-underline-tabs .nav-link:hover {
    color: var(--brand-blue) !important;
    border-bottom-color: #cbd5e1 !important;
}
.custom-underline-tabs .nav-link.active {
    color: var(--brand-blue) !important;
    border-bottom: 2px solid var(--brand-blue) !important;
}

.section-separator-card {
    border-left: 4px solid var(--brand-blue);
    padding-left: 15px;
    margin: 25px 0 15px;
    font-weight: 700;
    color: var(--sidebar-bg);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-style-modern {
    border-radius: 10px !important;
    border: 1px solid #e2e8f0 !important;
    background-color: #f8fafc !important;
    font-size: 0.9rem !important;
    padding: 0.75rem 1rem !important;
    color: #1e293b !important;
    transition: all 0.2s ease;
}
.input-style-modern:focus {
    background-color: #fff !important;
    border-color: var(--brand-blue) !important;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1) !important;
    outline: none !important;
}
.label-style-modern {
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 6px !important;
    display: block !important;
}

/* Upload button wrapper (CMS-style) */
.upload-btn-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
}
.upload-btn-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}

/* ─── Utility responsive ────────────────────────────────────────── */
@media (min-width: 576px) {
    .w-sm-auto { width: auto !important; }
}

/* ─── Responsive: Mobile first ─────────────────────────────────── */

/* Ajustes generales para móvil */
@media (max-width: 575.98px) {
    .card { border-radius: 10px; }
    .card .p-4 { padding: 1rem !important; }
    .card .p-5 { padding: 1.25rem !important; }
    h3.fw-bold { font-size: 1.1rem !important; }
    h5.fw-bold { font-size: 0.95rem !important; }
    .fs-5 { font-size: 0.95rem !important; }
    .btn-lg { font-size: 0.9rem !important; padding: 0.5rem 1rem !important; }
}

/* Ajustes para tablets */
@media (max-width: 767.98px) {
    .container-fluid.p-4 { padding: 0.75rem !important; }
    .gap-2 { gap: 0.4rem !important; }
}

/* ─── Dashboard responsive ─────────────────────────────────────── */
@media (max-width: 575.98px) {
    .card .btn-soft-blue.w-75,
    .card .btn-custom-success.w-75 {
        width: 100% !important;
        font-size: 0.9rem !important;
        padding: 0.65rem 1rem !important;
    }
    .card h5.fw-bold.text-dark { font-size: 0.95rem; }
    .card p.text-muted.small { font-size: 0.8rem !important; }
}

/* ─── Tablas responsive ────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .matrix-table thead tr.filters { display: none !important; }

    .table-responsive .dataTables_wrapper .dataTables_length,
    .table-responsive .dataTables_wrapper .dataTables_info {
        text-align: left !important;
        float: none !important;
        padding: 0.25rem 0 !important;
        font-size: 0.8rem;
    }

    .table-responsive .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
    }

    .table-responsive .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 100% !important;
    }

    .table-responsive .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        padding-top: 0.5rem;
    }

    /* DataTables no muestra bien columnas en pantallas muy pequeñas */
    div.dataTables_wrapper div.dataTables_paginate ul.pagination {
        justify-content: center;
    }
}

/* ─── Tickets: Bulk actions bar ─────────────────────────────────── */
@media (max-width: 575.98px) {
    #bulkAction { width: 100% !important; }
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 > h3 {
        font-size: 1.1rem;
    }
    .p-4 .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .p-4 .d-flex.justify-content-between.align-items-center.mb-3 select {
        width: 100% !important;
    }
}

/* ─── Escanear: Upload area ─────────────────────────────────────── */
@media (max-width: 575.98px) {
    #pdfPreviewContainer .label-style-modern {
        margin-bottom: 2px !important;
    }
    #dataContainer table.table-bordered {
        font-size: 0.75rem !important;
    }
    #dataContainer table.table-bordered input {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.4rem !important;
    }
    #dataContainer .row.g-2.mb-3[style*="max-width:400px"] {
        max-width: 100% !important;
        margin-left: 0 !important;
    }
}

/* ─── Ticket detail / Factura detail responsive ─────────────────── */
@media (max-width: 575.98px) {
    .col-md-8 .table.table-sm td:first-child {
        width: auto !important;
        white-space: nowrap;
        padding-right: 0.5rem;
    }
    .col-md-8 .table.table-sm td,
    .col-md-8 .table.table-sm th {
        padding: 0.35rem 0.3rem;
        font-size: 0.8rem;
    }
    .col-md-8 .table.table-sm .fw-bold.fs-5 {
        font-size: 1rem !important;
    }


}



/* ─── Footer tabs / acciones ────────────────────────────────────── */
@media (max-width: 575.98px) {
    .custom-underline-tabs {
        gap: 0.75rem;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .custom-underline-tabs .nav-link {
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 0.5rem 0 !important;
    }
}

@media print {
    .no-print { display: none !important; }
}
