/* ==========================================================================
   VARIABLES Y CONFIGURACIÓN BASE
   ========================================================================== */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-main: #334155;
    --text-muted: #64748b;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --border-color: #cbd5e1;
    --radius: 10px;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 15px;
    display: flex; /* Permite alinear el menú lateral con el contenido */
    min-height: 100vh;
}

/* ==========================================================================
   ESTRUCTURA DEL MENÚ LATERAL (SIDEBAR) RESPONSIVO
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: #0f172a; /* Azul marino oscuro corporativo */
    color: #f8fafc;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 20px 0;
    transition: transform 0.3s ease;
}

.sidebar .brand {
    padding: 0 20px 20px 20px;
    font-size: 20px;
    font-weight: bold;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar ul { list-style: none; margin-top: 20px; }

.sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar ul li a:hover, .sidebar ul li.active a {
    background: #1e293b;
    color: #fff;
    border-left: 4px solid var(--primary);
}

/* BOTÓN HAMBURGUESA (Escondido en PC, visible en celular) */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    background: #0f172a;
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    z-index: 110;
    font-size: 16px;
}

/* CONTENEDOR PRINCIPAL DE TRABAJO */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width); /* Desplaza el contenido para no tapar el menú */
    padding: 30px;
    width: calc(100% - var(--sidebar-width));
}

.container {
    background: var(--bg-card);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    margin-bottom: 20px;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 15px;
    margin-bottom: 20px;
    gap: 15px;
}

.header-bar h2 { font-size: 22px; color: #1e293b; }

/* REJILLAS ADAPTABLES (GRID) */
.grid-1 { display: grid; grid-template-columns: 1fr; gap: 15px; margin-bottom: 15px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 15px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 15px; }

.col { display: flex; flex-direction: column; width: 100%; }

/* ==========================================================================
   FORMULARIOS Y CAMPOS
   ========================================================================== */
label { font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }
select, input { padding: 11px 14px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 14px; outline: none; background-color: #fff; width: 100%; color: var(--text-main); }
select:focus, input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.calc-box { background: #f8fafc; border: 1px solid #e2e8f0; padding: 20px; border-radius: var(--radius); margin-bottom: 25px; }

.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    background: white;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 140px;
    overflow-y: auto;
}
.tool-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tool-item input { width: auto; margin: 0; cursor: pointer; }

.summary-box { margin-top: 20px; text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; padding: 15px; background: #f8fafc; border-radius: 8px; }
.summary-box span { font-weight: bold; font-size: 18px; color: #0f172a; }

/* ==========================================================================
   TABLAS RESPONSIVAS
   ========================================================================== */
.table-responsive { width: 100%; overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 8px; margin-top: 15px; }
.main-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.main-table th { background: #f1f5f9; padding: 12px; text-align: left; font-size: 13px; font-weight: 600; color: #475569; }
.main-table td { padding: 12px; border-bottom: 1px solid #e2e8f0; background: white; font-size: 14px; }

/* ==========================================================================
   BOTONES
   ========================================================================== */
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { padding: 11px 18px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; text-align: center; }
.btn-blue { background: var(--primary); color: white; }
.btn-blue:hover { background: var(--primary-hover); }
.btn-green { background: var(--success); color: white; }
.btn-green:hover { background: var(--success-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }

/* ==========================================================================
   VENTANA MODAL FLOTANTE (CREAR CLIENTE)
   ========================================================================== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 15px;
}
.modal.open { display: flex; }
.modal-content {
    background: white;
    padding: 25px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 550px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ==========================================================================
   MEDIA QUERIES - CELULARES Y TABLETS
   ========================================================================== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); } /* Esconde el menú a la izquierda */
    .sidebar.open { transform: translateX(0); } /* Lo despliega al pulsar el botón */
    
    .menu-toggle { display: block; } /* Muestra el botón hamburguesa */
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 70px 10px 15px 10px; /* Margen superior para no chocar con el botón hamburguesa */
    }
    
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 12px; }
    .tools-grid { grid-template-columns: 1fr; }
    .header-bar { flex-direction: column; align-items: flex-start; gap: 12px; }
    .btn-group { width: 100%; }
    .btn { width: 100%; padding: 12px; }
}