
/* ========= Base ========= */
body {
  font-family: 'Montserrat', sans-serif;
  background-color: #ecf0f1;
  color: #333;
  margin: 0;
  padding: 0;
  font-size: 15px; 
}

.app-layout {
  display: flex;
  min-height: 100vh;
    font-size: 15px; 
}

/* ========= Sidebar ========= */
.sidebar {
  width: 190px;
  background-color: #f9f9f9;
  padding: 15px;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.2);
  transition: width 0.3s ease;
}
.sidebar.collapsed { width: 60px; }

.sidebar h3 {
  color: #2c3e50;
  font-size: 1.2em;
  font-weight: bold;
  text-align: center;
  margin-bottom: 30px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar.collapsed h3 {
  font-size: 1.8em;
  text-align: center;
  color: #2c3e50;
  position: relative;
  overflow: visible;
  height: 35px;
  margin-bottom: 25px;
  text-indent: -9999px;
  line-height: 0;
}
.sidebar.collapsed h3::before {
  content: '8';
  text-indent: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  line-height: initial;
}

.sidebar ul { list-style-type: none; padding: 0; }

.sidebar ul li a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 15px;
  margin-bottom: 8px;
  background-color: #34495e;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  transition: background-color 0.3s ease;
  font-weight: 700;
  font-size: 0.7em;
  position: relative;
}
.sidebar ul li a:hover,
.sidebar ul li a.active { background-color: #2c3e50; }

.sidebar .icon { margin-right: 10px; font-size: 1.2em; }

.sidebar.collapsed ul li a .text { display: none; }
.sidebar.collapsed ul li a:hover .text {
  display: inline-block;
  position: absolute;
  left: 65px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 10;
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateX(0);
}
.sidebar.collapsed ul li a { justify-content: center; }
.sidebar.collapsed .icon { margin-right: 0; }

/* ========= Main ========= */
.main-content {
  flex-grow: 1;
  padding: 40px;
  background-color: #f9f9f9;
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
margin: 20px 0 20px 0;
  position: relative;
  z-index: 5;
}

h1 {
  color: #2c3e50;
  font-size: 2.5em;
  font-weight: 700;
  border-bottom: 3px solid #2c3e50;
  padding-bottom: 20px;
  margin-top: 0;
  margin-bottom: 40px;
}

p { font-size: 1.1em; color: #555; margin-bottom: 30px; }

.menu {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.button, .home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  padding: 10px 18px;
  background-color: #2c3e50;
  color: white;
  border: none;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  box-shadow: 0 3px 4px rgba(0, 0, 0, 0.1);
}

/* ========= Tablas ========= */
.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 13px;
}
th, td {
  border: 1px solid #e0e6ff;
  padding: 12px;
  text-align: left;
  font-size: 10px;
}
th {
  background-color: #ecf0f1;
  font-weight: bold;
  color: #2c3e50;
}
tr:nth-child(even) { background-color: #fafafa; }

td.action-links a {
  white-space: nowrap;
  color: #2c3e50;
  text-decoration: none;
}
td.action-links a:hover { text-decoration: underline; }

/* ========= Formularios ========= */
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px;
  border: 1px solid #e0e6ff;
  border-radius: 4px;
  box-sizing: border-box;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: #2c3e50;
  outline: none;
}

/* ========= Login ========= */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #f0f2f5;
}
.login-container form {
  width: 400px;
  padding: 40px;
  background-color: #f9f9f9;
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
}
.login-container h2 { color: #333; margin-bottom: 25px; }
.login-container .form-field { margin-bottom: 20px; text-align: left; }
.login-container .form-field label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #555;
}
.login-container .form-field input {
  width: 100%;
  padding: 12px;
  border: 1px solid #bdc3c7;
  border-radius: 6px;
  font-size: 16px;
}
.login-container .form-field input:focus {
  border-color: #2c3e50;
  outline: none;
}

/* ========= Toggle Sidebar ========= */
.toggle-button {
  cursor: pointer;
  font-size: 1.5em;
  text-align: left;
  padding: 15px;
  color: #333;
}

/* ========= Responsive (global) ========= */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; padding: 10px; }
  .sidebar h3 { text-align: left; margin-bottom: 20px; }
  .sidebar ul { display: flex; flex-wrap: wrap; justify-content: center; }
  .sidebar ul li a { padding: 10px 15px; font-size: 0.8em; width: auto; }
  .main-content { width: auto; margin: 10px; padding: 20px; }
  h1 { font-size: 1.8em; }
  .button, .home-link { font-size: 0.9em; padding: 10px 20px; }
}

/* =================================================================== */
/* ====================  COTIZACIÓN — LIMPIO  ======================== */
/* =================================================================== */

/* Layout de cotización en bloque (totales abajo) */
.quote-layout { display: block; width: 100%; }
.quote-main-column { width: 100%; min-width: 0; display: block; }
.quote-summary-column { width: 100%; display: block; margin-top: 24px; position: static; }

/* Bloque de totales */
.quote-summary {
  padding: 16px;
  border: 1px solid #e0e6ff;
  border-radius: 8px;
  background: #fff;
}
.quote-summary__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed #e0e6ff;
}
.quote-summary__row:last-child { border-bottom: 0; }
.quote-summary__label { color: #555; }
.quote-summary__value { font-weight: 700; color: #2c3e50; }

.quote-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}



.search-input-wrap { position: relative; }
.search-input-wrap input {
  width: 100%;
  height: 42px;
  padding: 8px 44px 8px 12px;
  font-size: 15px;
  border: 1px solid #cfd4da;
  border-radius: 8px;
  box-sizing: border-box;
  background: #fff;
  color: #333;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search-input-wrap input:focus {
  border-color: #2c3e50;
  box-shadow: 0 0 0 2px rgba(44,62,80,.15);
}
.search-input-wrap .dropdown-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 1px solid #e0e6ff;
  border-radius: 6px;
  background: #f1f3f5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Sugerencias */
.suggestions {
  position: absolute;
  left: 0; right: 0;
  z-index: 1200;
  display: none;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(0,0,0,.08);
  max-height: 280px;
  overflow: auto;
  margin-top: 6px;
  padding: 4px 0;
}
.suggestions.is-open { display: block; }

.suggestion-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.suggestion-item:hover { background: #f5f7fb; }

.sku-muted { font-size: 12px; color: #666; }
.price-strong { white-space: nowrap; font-weight: 700; }

#product-suggestions-name,
#product-suggestions-sku { z-index: 1200; }

/* =================================================================== */
/* =========================  MODALES  =============================== */
/* =================================================================== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.35);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-content {
  position: relative;
  background: #fff;
  width: 100%;
  max-width: 720px;
  margin: auto;
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,.15);
  padding: 24px 24px 28px;
  animation: fadeIn 0.25s;
}
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

.close {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 22px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  line-height: 1;
  user-select: none;
}
.close:hover { color: #d00; }

#closeModalBtn { 
  position: absolute; top: 10px; right: 14px; 
  font-size: 22px; font-weight: 700; color: #334155; cursor: pointer; 
}
#closeModalBtn:hover { color: #d00; }

.modal-content .form-group,
.modal-content .form-field { margin-bottom: 12px; }
.modal-content label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}
.modal-content input[type="text"],
.modal-content input[type="email"],
.modal-content input[type="number"],
.modal-content textarea,
.modal-content select {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
  background: #fff;
  color: #111827;
  box-sizing: border-box;
}
.modal-content textarea { min-height: 90px; resize: vertical; }

.modal-content .btn-primary,
.modal-content button[type="submit"] {
  background: #233142;
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}
.modal-content .btn-primary:hover,
.modal-content button[type="submit"]:hover { filter: brightness(1.05); }

/* =================================================================== */
/* ========= Baseline para fila Cliente (otras páginas también) ====== */
/* =================================================================== */

client-row { display: flex; justify-content: space-between; /* CLAVE: Separa grupos */ align-items: center; flex-wrap: wrap; margin-bottom: 10px; }

.client-row__select {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    min-width: 200px;
    /* ¡CAMBIO CRUCIAL!: Agregamos el margen derecho para separar el Select del botón */
    margin-right: 15px; 
}
/* No forzamos .client-row .button a width:100% aquí */

/* =================================================================== */
/* ===== add_quote.php — versión compacta + SKU/Nombre iguales ======= */
/* =================================================================== */


.page-add-quote .client-row__label{
  font-weight: 600;
  margin: 0;
  align-self: center;
}
.page-add-quote .client-row__select{
  width: 100%;
  height: 38px; /* misma altura que botones */
}
.page-add-quote #addNewClientButton,
.page-add-quote #addNewProductButton{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 8px 12px;
  font-size: 0.9rem;
  width: auto;
  min-width: 120px;
  border-radius: 8px;
}

/* SKU y Nombre: mismo ancho y piel que el SELECT de Cliente */
.page-add-quote .search-row{
  display: grid;
  grid-template-columns: 360px 360px;  /* SKU 360 | Nombre 360 */
  gap: 16px;
  justify-content: start;
}
.page-add-quote .search-field{ width: 360px; max-width: 100%; }

.page-add-quote .search-input-wrap input{
  height: 38px;
  padding: 8px 44px 8px 12px;
  background: #eef0f4;           /* tono del select */
  border: 1px solid #cbd5e1;     /* borde del select */
  border-radius: 8px;
  outline: none;
  box-shadow: none;
}
.page-add-quote .search-input-wrap input:focus{
  border-color: #2c3e50;
  box-shadow: 0 0 0 2px rgba(44,62,80,.15);
}
.page-add-quote .search-input-wrap .dropdown-toggle{
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #eef0f4;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 0;
}

/* Sugerencias: ancho exacto y por encima de la tabla */
.page-add-quote .suggestions{
  left: 0; right: 0;
  max-width: 360px;
  z-index: 1200;
}

/* Responsive */
@media (max-width: 900px){
  .page-add-quote .client-row{ grid-template-columns: 1fr; }
  .page-add-quote #addNewClientButton,
  .page-add-quote #addNewProductButton{ width: 100%; }
    .page-add-quote .search-field { 
    position: relative; 
    flex-basis: 50%; 
    min-width: 0; 
}
  .page-add-quote .suggestions{ max-width: none; }
}
/* ======== add_quote.php — SKU/Nombre IGUAL al SELECT de Cliente ======== */

/* Mismo ancho que el select de cliente y dos columnas fijas */
.page-add-quote .search-row{
  display: grid;
  grid-template-columns: 360px 360px;  /* SKU 360 | Nombre 360 (igual al select de cliente) */
  gap: 16px;
  justify-content: start;
}
.page-add-quote .search-field{ width: 360px; max-width: 100%; }

/* Contenedor con UN SOLO BORDE (como el <select>) */
.page-add-quote .search-input-wrap{
  display: flex;
  align-items: center;
  height: 38px;                       /* misma altura que el select */
  border: 1px solid #cbd5e1;          /* mismo borde */
  border-radius: 8px;
  background: #eef0f4;                /* mismo fondo */
  overflow: hidden;                   /* oculta bordes internos */
}

/* El input ya no lleva su propio borde: se integra al contenedor */
.page-add-quote .search-input-wrap input{
  flex: 1 1 auto;
  height: 100%;
  border: 0;                          /* clave: sin borde propio */
  padding: 0 12px;
  background: transparent;
  font: inherit;
  color: #333;
}
.page-add-quote .search-input-wrap input:focus{ outline: none; }

/* Estado de foco igual al select */
.page-add-quote .search-input-wrap:focus-within{
  border-color: #2c3e50;
  box-shadow: 0 0 0 2px rgba(44,62,80,.15);
}

/* Caret integrado como el área derecha del <select> */
.page-add-quote .search-input-wrap .dropdown-toggle{
  position: static;                   /* saca absolute */
  transform: none;
  width: 42px;
  height: 100%;
  border: 0;
  border-left: 1px solid #cbd5e1;     /* separador, como el select */
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 0;
}
.page-add-quote .search-input-wrap .dropdown-toggle svg{ opacity: .7; }

/* Dropdown de sugerencias con el mismo “feeling” del select */
.page-add-quote .suggestions{
  left: 0; right: 0;
  max-width: 360px;                   /* calza con el campo */
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(0,0,0,.08);
  overflow: hidden;                   /* bordes limpios */
  z-index: 1200;
}
.page-add-quote .suggestion-item{ padding: 10px 12px; }
.page-add-quote .suggestion-item:hover{ background: #e9eef5; }

/* Responsive: en móvil se apilan */
@media (max-width: 900px){
  .page-add-quote .search-row{ grid-template-columns: 1fr; }
  .page-add-quote .search-field{ width: auto; max-width: none; }
  .page-add-quote .suggestions{ max-width: none; }
 
}

/* SKU/Nombre con el MISMO ancho/alto del select de Cliente en add_quote.php */
.page-add-quote .search-row{
  display: grid;
  grid-template-columns: 360px 360px;  /* mismo ancho visual que Cliente */
  gap: 16px;
  justify-content: start;
}
.page-add-quote .search-field select.client-row__select{
  width: 360px;   /* si cambias el de Cliente, cambia este número igual */
  height: 38px;   /* misma altura */
}
@media (max-width: 900px){
  .page-add-quote .search-row{ grid-template-columns: 1fr; }
  .page-add-quote .search-field select.client-row__select{ width: 100%; }
}

/* === add_quote.php — forzar 1 solo panel de totales en flujo === */
.page-add-quote .quote-layout { display: block !important; }

/* Oculta cualquier otra columna/panel de totales que no sea el nuestro */
.page-add-quote .quote-summary-column:not(#totalsBlock) {
  display: none !important;
}

/* Nuestro bloque: ancho completo, sin sticky ni flotados */
.page-add-quote #totalsBlock {
  display: block !important;
  position: static !important;
  float: none !important;
  clear: both !important;
  width: 100% !important;
  margin-top: 24px !important;
}

/* (Defensivo) si un JS antiguo inyecta un panel pegado, lo neutralizamos */
.page-add-quote [style*="position:sticky"],
.page-add-quote [style*="position: fixed"] {
  position: static !important;
}

/* --- REGLAS DE DISEÑO DE COLUMNAS PARA add_quote.php --- */

/* Estilo general para filas de elementos (Cliente y Búsqueda) */



/* Permitir que el select ocupe un ancho razonable */
.client-row .client-row__label, .client-row .client-row__select {
    flex-grow: 1; 
    max-width: 300px;
}

/* Ajuste para que los botones se vean bien sin ocupar todo el ancho */
.client-row button {
    flex-shrink: 0;
    white-space: nowrap; 
}


.search-field {
    /* Mantenemos las reglas de columna para que el label esté encima del select */
    display: flex;
    flex-direction: column; 
    /* CLAVE FINAL: Usamos flex-basis para que cada uno ocupe exactamente la mitad */
    flex-basis: 50%;
    /* Quitamos el 'width: 48%;' porque 'flex-basis: 50%;' es más preciso */
}



.search-field label {
    margin-bottom: 5px;
    font-weight: 500;
}

.search-field select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
/* Fin de las reglas de diseño de columnas */

/* CLASE PRINCIPAL: Alinea selección (izquierda) y botones (derecha) */

.header-clientes {
    display: flex;
    justify-content: space-between;
    /* CAMBIO CLAVE: Cambiamos 'center' por 'flex-start' o 'baseline' */
    align-items: flex-start; 
    /* Opcional: Puedes probar con 'align-items: baseline;' si 'flex-start' no funciona perfectamente */
    width: 100%;
    margin-bottom: 20px;
}


/* GRUPO DE SELECCIÓN: Alinea los elementos internos del lado izquierdo (Label, Select, Botón) */
.client-row__selection {
    display: flex;
    align-items: center;
    gap: 15px; /* Espacio entre los elementos */
}

/* Opcional: Asegura que los botones se vean bien si están juntos */
.client-row__actions button {
    margin-left: 10px; 
}


/* GRUPO DE ELEMENTOS DE INFORMACIÓN DEL CLIENTE (Label, Select, Botón Nuevo Cliente) */
.client-info-group {
    display: flex;
    /* CAMBIO CLAVE: Volvemos a 'center' para que el botón esté centrado con el select */
    align-items: center; 
    gap: 10px; 
}

/* GRUPO DE BOTÓN "NUEVO PRODUCTO" (Derecha) */
.product-action-group {
    display: flex;
    align-items: center; /* Alineamos verticalmente */
}

/* BLOQUE 1: ANCLAJE PRINCIPAL SUPERIOR (Anula el centrado) */
.app-layout {
    margin: 0 !important;
    padding: 0 !important;
}
.main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 30px !important;
    padding-right: 30px !important;
    flex-grow: 1;
}

/* BLOQUE 2: FILA DE CLIENTES (Alineación Horizontal y Vertical) */
.header-clientes {
    justify-content: space-between !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 20px 0 !important;
    width: 100%;
}

/* BLOQUE 3: GRUPOS INTERNOS (Alineación Vertical Final) */
.client-info-group, .product-action-group {
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
}



/* ANULACIÓN DE CENTRADO Y ALINEACIÓN (SOLUCIÓN FINAL) */

/* 1. ANCLAJE PRINCIPAL: Obliga al contenido a pegarse al borde izquierdo */
.main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 30px !important; 
    padding-right: 30px !important;
}

/* 2. FILA DE CLIENTES: Anclaje y Alineación Vertical */
.header-clientes {
    display: flex;
    /* Fuerza el anclaje a la izquierda (en lugar de space-between) */
    justify-content: flex-start !important; 
    /* Fuerza la alineación vertical */
    align-items: center !important; 
    margin: 0 !important;
    padding: 20px 0;
    /* Espacio entre el grupo de clientes y el botón de producto */
    gap: 40px; 
    width: 100%;
}

/* 3. GRUPOS INTERNOS Y SELECTOR: Espaciado y Alineación Vertical Final */
.client-info-group, .product-action-group {
    align-items: center !important;
}

.client-info-group {
    /* Espacio entre label, select y botón Nuevo Cliente */
    gap: 15px;
}

.client-row__select {
    min-width: 200px;
    /* Margen adicional para el select si lo necesita */
    margin-right: 5px; 
}




/* --- CORRECCIÓN FINAL DE ANCLAJE Y ALINEACIÓN --- */

/* 1. Ancla el contenido principal al borde izquierdo, quitando el centrado */
.main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 30px !important;
}

/* 2. Alinea la fila de clientes a la izquierda y resuelve la alineación vertical */
.client-row.header-clientes {
    justify-content: flex-start !important; /* ANCLA LA FILA A LA IZQUIERDA */
    align-items: center !important; /* ALINEACIÓN VERTICAL */
    gap: 20px; /* Espacio entre los grupos */
}

/* 3. Ajuste de los grupos internos para que no haya superposiciones */
.client-info-group, .product-action-group {
    align-items: center !important;
    display: flex;
}

.client-info-group {
    gap: 10px; /* Espacio entre label, select y botón Nuevo Cliente */
}

/* Nuevo formato para la fila de buscadores */
.search-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

/* Dar el 50% de ancho a cada buscador de Tom Select */
.search-field .ts-wrapper {
    width: 100%; /* Asegura que la caja de Tom Select llene el .search-field */
}

/* Dar el 50% al contenedor padre */
.search-field {
    flex-basis: 50%;
    min-width: 0;
}

















