/* =========================================
   Reemplazo moderno de cake.generic.css
   Inspirado en Bootstrap 5 (sin dependencias)
   ========================================= */

/* ======= BASE ======= */
body {
  font-family: 'Inter', Arial, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  background: #f8f9fa;
  color: #212529;
  margin: 0;
  padding: 0;
}

/* Heredar fuente en todos los elementos de formulario */
input,
textarea,
select,
button,
optgroup,
option {
  font-family: 'Inter', Arial, sans-serif;
  font-size: inherit;
}

h1, h2, h3, h4 {
  margin-top: 0;
  margin-bottom: .5rem;
  font-weight: 600;
  line-height: 1.25;
}

h1, h2 {
  color: #ea2611; /* Ejemplo: "Nueva Factura" en rojo */
}

h3, h4 {
  color: #2c6877;
}

/* ======= FORMULARIOS ======= */
input[type=text],
input[type=password],
input[type=number],
input[type=date],
input[type=email],
select,
textarea {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #212529;
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.2rem rgba(13,110,253,.25);
  outline: none;
}

/* Checkbox */
input[type=checkbox] {
  margin-right: 0.5rem;
}

/* Fechas (CakePHP genera 3 selects) */
.input.date select {
  display: inline-block;
  width: auto;
  margin-right: 5px;
}

/* ======= BOTONES ======= */
button,
input[type=submit],
input[type=button] {
  display: inline-block;
  color: #fff;
  background-color: #0d6efd !important;
  border: 1px solid #0a58ca !important;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

button:hover,
input[type=submit]:hover,
input[type=button]:hover {
  background-color: #0b5ed7 !important;
  border-color: #0a58ca !important;
}

button:active,
input[type=submit]:active,
input[type=button]:active {
  background-color: #0a58ca !important;
  border-color: #0a53be !important;
}

button:disabled,
input[type=submit]:disabled,
input[type=button]:disabled {
  background-color: #6c757d;
  border-color: #6c757d;
  cursor: not-allowed;
  opacity: 0.65;
}

/* Variantes opcionales */
.btn-success { background-color: #198754; border-color: #157347; }
.btn-success:hover { background-color: #157347; }

.btn-danger { background-color: #dc3545; border-color: #bb2d3b; }
.btn-danger:hover { background-color: #bb2d3b; }

.btn-secondary { background-color: #6c757d; border-color: #5c636a; }
.btn-secondary:hover { background-color: #5c636a; }

/* ======= FIELDSETS ======= */
fieldset {
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 1rem;
  background-color: #fff;
}

fieldset legend {
  color: #ea2611;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: .75rem;
}

/* ======= TABLAS ======= */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  background-color: #fff;
}

th, td {
  padding: 0.5rem;
  border: 1px solid #dee2e6;
  text-align: left;
}

th {
  background-color: #e9ecef;
  font-weight: 600;
}

/* ======= ALERTAS ======= */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

.alert-success {
  background-color: #d1e7dd;
  border: 1px solid #badbcc;
  color: #0f5132;
}

.alert-danger {
  background-color: #f8d7da;
  border: 1px solid #f5c2c7;
  color: #842029;
}

.alert-warning {
  background-color: #fff3cd;
  border: 1px solid #ffecb5;
  color: #664d03;
}

.alert-info {
  background-color: #cff4fc;
  border: 1px solid #b6effb;
  color: #055160;
}

/* ======= UTILES ======= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }


/* Sobrescribe cake.generic.css */
form .submit input[type=submit],
input[type=submit],
button {
  display: inline-block;
  color: #fff;
  background-color: #0d6efd;
  border: 1px solid #0a58ca;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-shadow: none !important; /* anula sombra vieja */
  background-image: none !important; /* anula degradado */
}

form .submit input[type=submit]:hover,
input[type=submit]:hover,
button:hover {
  background-color: #0b5ed7;
  border-color: #0a58ca;
}

form .submit input[type=submit]:active,
input[type=submit]:active,
button:active {
  background-color: #0a58ca;
  border-color: #0a53be;
}


/* Sobrescribir fuente de todos los botones y submit */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    font-family: 'Inter', Arial, sans-serif !important;
}


/* =============================================
   RESPONSIVE LAYOUT
   ============================================= */

/* --- Tablas: scroll horizontal en contenedor --- */
div.index,
div.view,
div.form {
  overflow-x: visible; /* se maneja con wrapper en mobile */
}

/* --- Breakpoint tablet/mobile (≤ 768px) --- */
@media (max-width: 768px) {

  /* #content como columna flex para controlar el orden */
  #content {
    display: flex;
    flex-direction: column;
  }

  /* div.actions sube al tope (order:-1 lo pone antes del contenido) */
  div.actions {
    order: -1;
    float: none !important;
    width: 100% !important;
    padding: 8px 15px !important;
    box-sizing: border-box;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
  }

  /* Ocultar el h3 vacío que genera CakePHP en div.actions */
  div.actions h3:empty,
  div.actions h3 {
    display: none;
  }

  /* Links de acciones: fila horizontal compacta */
  div.actions ul {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0;
    margin: 0;
    list-style: none;
  }

  div.actions ul li {
    margin: 0;
  }

  div.actions ul li a {
    display: inline-block;
    clear: none;
    padding: 5px 10px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  /* Layout de dos columnas → columna única */
  div.form,
  div.index,
  div.view {
    float: none !important;
    width: 100% !important;
    border-left: none !important;
    padding: 12px 15px !important;
    box-sizing: border-box;
    order: 0;
  }

  /* Tablas: scroll horizontal */
  div.index table,
  div.view table,
  div.form table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Celdas de acciones en tablas: apiladas */
  td.actions {
    white-space: normal;
  }

  td.actions a,
  td.actions form {
    display: block;
    margin: 2px 0;
  }

  /* Solo botones de submit/form más grandes (touch-friendly) */
  button[type=submit],
  input[type=submit],
  input[type=button] {
    min-height: 38px;
    padding: 0.45rem 0.75rem;
  }

  /* Formularios a full ancho */
  form {
    width: 100% !important;
    margin-right: 0 !important;
    box-sizing: border-box;
  }

  /* Paginación centrada */
  .paging {
    text-align: center;
  }

  /* h2 más compacto */
  h2 {
    font-size: 130%;
  }

  /* Dl en vistas de detalle */
  dl {
    width: 100%;
  }
}

/* --- Breakpoint muy pequeño (≤ 480px) --- */
@media (max-width: 480px) {

  div.form,
  div.index,
  div.view {
    padding: 10px !important;
  }

  th, td {
    padding: 6px 4px;
    font-size: 0.8rem;
  }

  h2 {
    font-size: 115%;
  }
}