/* RESET */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-width: 250px;
    --primary: #2563eb;
    --bg: #f1f5f9;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg);
    overflow-x: hidden;
}

/* SIDEBAR: Fija y estrecha */
/* SIDEBAR: Fija, con altura total y scroll independiente */
.sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh; /* Altura de toda la ventana */
    padding: 20px;
    z-index: 1000;
    
    /* ACTIVAR SCROLL VERTICAL */
    overflow-y: auto; 
    overflow-x: hidden; /* Evita scroll hacia los lados */
}

/* --- ESTILO DE LA BARRA DE SCROLL (Para que se vea moderna y oscura) --- */
.sidebar::-webkit-scrollbar {
    width: 6px; /* Barra delgada */
}

.sidebar::-webkit-scrollbar-track {
    background: #1e293b; /* Color del fondo del menú */
}

.sidebar::-webkit-scrollbar-thumb {
    background: #334155; /* Color de la barrita que se mueve */
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #38bdf8; /* Color cuando pasas el ratón */
}

/* CONTENIDO: Con margen real para que no se toque con el menú */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 40px;
    width: calc(100% - var(--sidebar-width));
    position: relative;
    z-index: 10; /* Por debajo del menú pero por encima del fondo */
}

/* CARDS: Estilo moderno */
.card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    margin-bottom: 25px;
}

.nav-link {
    display: block;
    color: #cbd5e1;
    text-decoration: none;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 5px;
}

.nav-link:hover { background: #334155; color: white; }

/* BOTONES Y TABLAS */
.btn { padding: 10px 18px; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-block; }
.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: #ef4444; color: white; }

table { width: 100%; border-collapse: collapse; margin-top: 15px; }
th { text-align: left; padding: 12px; background: #f8fafc; border-bottom: 2px solid #e2e8f0; font-size: 0.8rem; }
td { padding: 12px; border-bottom: 1px solid #f1f5f9; }

/* --- ESTILOS PARA DATATABLES (BUSCADOR INSTANTÁNEO) --- */

/* El cuadro de búsqueda */
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 20px;
}

.dataTables_wrapper .dataTables_filter input {
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-left: 10px;
    outline: none;
    transition: 0.3s;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Ajustes de la tabla */
table.dataTable {
    border-collapse: collapse !important;
    margin-top: 15px !important;
    border: 1px solid #e2e8f0 !important;
}

table.dataTable thead th {
    background: #f8fafc !important;
    color: #475569 !important;
    border-bottom: 2px solid #e2e8f0 !important;
    font-size: 0.8rem;
}

/* Paginación (Botones de Siguiente/Anterior) */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px;
}

.dataTables_wrapper .dataTables_length select {
    padding: 5px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

/* --- ESTILOS PARA DOCUMENTOS (PRESUPUESTOS / PDF) --- */

.invoice-wrapper {
    background: #f1f5f9;
    padding: 30px 10px;
    min-height: 100vh;
}

.invoice-box {
    max-width: 850px;
    margin: 0 auto;
    background: white;
    padding: 50px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border-radius: 8px;
    color: #334155;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
}

.invoice-logo {
    max-height: 80px;
    max-width: 250px;
}

.taller-info h2 { margin: 0; color: #1e293b; }
.taller-info p { margin: 5px 0; font-size: 13px; color: #64748b; }

.doc-title { text-align: right; }
.doc-title h1 { margin: 0; color: #2563eb; font-size: 28px; letter-spacing: -1px; }
.doc-title p { margin: 5px 0; font-weight: bold; }

.client-project-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 30px;
}

.box-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: bold;
    margin-bottom: 5px;
    display: block;
}

/* Tabla de items específica para documentos */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

.doc-table th {
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid #e2e8f0;
    font-size: 12px;
    text-transform: uppercase;
    color: #64748b;
}

.doc-table td {
    padding: 15px 12px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}

.totals-container {
    display: flex;
    justify-content: flex-end;
}

.totals-table {
    width: 320px;
}

.totals-table td {
    padding: 8px 0;
    border: none !important;
}

.totals-table .label { text-align: right; color: #64748b; padding-right: 20px; }
.totals-table .value { text-align: right; font-weight: bold; width: 130px; }

.grand-total-row td {
    border-top: 2px solid #e2e8f0 !important;
    padding-top: 15px !important;
}

.grand-total-row .value {
    font-size: 22px;
    color: #2563eb;
}

.doc-footer {
    margin-top: 50px;
    font-size: 12px;
    color: #94a3b8;
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
}

/* AJUSTES PARA IMPRESIÓN */
@media print {
    .invoice-wrapper { background: white; padding: 0; }
    .no-print { display: none !important; }
    .invoice-box { box-shadow: none; margin: 0; padding: 0; width: 100%; max-width: 100%; }
    body { background: white; }
}

/* Botón versión pequeña */
.btn-sm {
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
    height: auto !important;
}

/* Agrupador de botones para que no se vean desordenados */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Grupo de entrada compacto para el QR */
.qr-group {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid #475569;
    border-radius: 6px;
    overflow: hidden; /* Esto hace que las esquinas del input y el botón se redondeen juntas */
    height: 32px; /* Altura fija para alinear con botones btn-sm */
}

.qr-group input {
    width: 40px;
    border: none;
    text-align: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: #475569;
    outline: none;
    background: #ffffff;
}

.qr-group button {
    background: #475569;
    color: white;
    border: none;
    padding: 0 12px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: 0.2s;
}

.qr-group button:hover {
    background: #334155;
}

/* Ajuste para los demás botones pequeños */
.btn-sm {
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
    height: 32px !important;
    display: inline-flex;
    align-items: center;
}