:root {
  --rojo-corporativo: #db0812;
  --rojo-hover: #b0060f;
  --rojo-soft: #ff9aa0;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #f5f6fa 0%, #dfe9f3 100%);
}
body {
  min-height: 100vh; /* asegura que el footer quede al fondo */
}

.app-wrapper {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}


/* --- Main: centrado horizontal y con espacio desde la cabecera --- */
main.flex-grow-1 {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;    /* apila hijos en columna */
  align-items: center;       /* centra horizontalmente */
  justify-content: flex-start; /* empieza desde arriba */
  padding: 20px 15px 25px;   /* reducido margen lateral de 25px a 15px */
  width: 100%;
  box-sizing: border-box;
  gap: 1rem;
}

/* Forzar un ancho máximo a los hijos directos de main */
main.flex-grow-1 > * {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  box-sizing: border-box;
}

.card {
  width: 100%;
  max-width: 500px;
  border-radius: 0.75rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Navbar personalizado */

/* ===== NAVBAR FLOTANTE MODERNA ===== */
.custom-navbar {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  border-radius: 20px;
  max-width: 1200px;
  margin: 20px auto 30px auto;
  padding: 12px 26px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  border: 1px solid rgba(230, 57, 70, 0.15);
}


.navbar-brand span { 
  color: #2a2a2a; 
}

.navbar-nav .nav-link { 
  color: #2b2b2b !important; 
  font-weight: 600;
  position: relative;
}

.navbar-nav .nav-link:hover { 
  color: var(--rojo-corporativo) !important;
}

.navbar-nav .nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 0%;
  height: 2px;
  background: var(--rojo-corporativo);
  transition: width 0.3s ease;
}

.navbar-nav .nav-link:hover::after {
  width: 100%;
}


/* Footer */

.custom-footer {
  background: rgba(43, 43, 43, 0.9);
  backdrop-filter: blur(8px);
  color: #fff;
  text-align: center;
  padding: 1rem;
  border-radius: 18px 18px 0 0;
  max-width: 1200px;
  margin: 40px auto 0 auto;
  border-top: 2px solid var(--rojo-corporativo);
}

.custom-footer small { opacity: 0.8; }

.card.login-card {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  border-radius: 18px;
}

/* Botones */

.btn-primary { 
  background-color: var(--rojo-corporativo); 
  border-color: var(--rojo-corporativo); 
}

.btn-primary:hover { 
  background-color: var(--rojo-hover); 
  border-color: var(--rojo-hover); 
}

.btn-danger { 
  background-color: var(--rojo-corporativo); 
  border-color: var(--rojo-corporativo); 
}

.btn-danger:hover { 
  background-color: var(--rojo-hover); 
  border-color: var(--rojo-hover); 
}


/* ===========================
   Estilos calendario
=========================== */
.clave-input { width: 200px; max-width: 200px; }
.total-input { background: #f0f0f0; font-weight: bold; }
.sum-row { background: #e9ecef; font-weight: bold; }

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
  text-align: center;
}

/* Desktop / Mobile views */
.desktop-view { display: block; }
.mobile-view { display: none; }

/* Mobile */
@media (max-width:991px) {
  .desktop-view { display: none !important; }
  .mobile-view { display: block !important; }
}
/* ===========================
   Estilos para cards móviles
=========================== */
.mobile-view .card-body .pnp-clave {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

/* Etiquetas más compactas */
.mobile-view .card-body .pnp-clave label {
  margin-bottom: 0;
  white-space: nowrap;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Select P/NP tamaño fijo */
.mobile-view .card-body .pnp-clave .pnp-select {
  width: 70px !important;
  min-width: 70px !important;
  max-width: 70px !important;
  flex-shrink: 0;
}

/* Campo Clave tamaño fijo */
.mobile-view .card-body .pnp-clave .clave-input {
  width: 120px !important;
  min-width: 120px !important;
  max-width: 120px !important;
  flex-shrink: 0;
}

/* Campo CCN tamaño fijo */
.mobile-view .card-body .pnp-clave .ccn-input {
  width: 100px !important;
  min-width: 100px !important;
  max-width: 100px !important;
  flex-shrink: 0;
}

/* ===========================
   Ajustes responsive específicos
=========================== */
@media (min-width: 768px) and (max-width: 991px) {
  .mobile-view .card-body .pnp-clave { 
    flex-wrap: nowrap !important; 
    flex-direction: row !important; 
    align-items: center !important; 
    gap: 0.5rem; 
  }
  .mobile-view .card-body .pnp-clave .first-line { 
    display: contents !important; 
  }
  .mobile-view .card-body .pnp-clave .ccn-line { 
    display: contents !important; 
  }
  .mobile-view .card { 
    max-width: 600px !important; 
    margin: 0 auto; 
  }
  .mobile-view .card-body { 
    padding: 1.25rem; 
  }
  main.flex-grow-1 { 
    padding: 20px 10px 25px; 
  }
  .mobile-view .card-body .dias-row .small-input { 
    min-width: 50px; 
    max-width: 70px; 
    font-size: 0.9rem; 
  }
}

@media (max-width: 767px) {
  .mobile-view .card-body .pnp-clave { 
    flex-direction: column; 
    align-items: flex-start; 
    gap: 0.5rem; 
  }
  .mobile-view .card-body .pnp-clave .first-line { 
    display: flex; 
    flex-direction: row; 
    align-items: center; 
    gap: 0.5rem; 
    flex-wrap: nowrap; 
    width: 100%; 
  }
  .mobile-view .card-body .pnp-clave .ccn-line { 
    display: flex; 
    flex-direction: row; 
    align-items: center; 
    gap: 0.5rem; 
    width: 100%; 
    margin-top: 0.25rem; 
  }
  .mobile-view .card-body .pnp-clave .ccn-input { 
    width: 120px !important; 
    min-width: 120px !important; 
    max-width: 120px !important; 
  }
  main.flex-grow-1 { 
    padding: 15px 8px 20px; 
  }
}

.mobile-view .card-body .dias-row { 
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 0.3rem;
  flex-wrap: nowrap; 
  margin-bottom: 0.75rem;
}
.mobile-view .card-body .dias-row .text-center {
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
}
.mobile-view .card-body .dias-row .small-input { 
  min-width: 45px; 
  max-width: 60px; 
  padding: 4px 6px; 
  font-size: 0.85rem; 
  text-align: center;
  flex: 1 1 40px; 
  box-sizing: border-box;
}
.mobile-view .card-body .dias-row small { 
  font-size: 0.75rem; 
  font-weight: 500; 
  margin-bottom: 2px; 
}
.mobile-view .card-body .total-input { 
  width: 80px !important; 
  display: inline-block !important; 
  margin-left: 0.5rem; 
}

@media (max-width: 400px) {
  .mobile-view .card-body .pnp-clave .first-line { 
    gap: 0.3rem; 
  }
  .mobile-view .card-body .pnp-clave .pnp-select { 
    width: 60px !important; 
    min-width: 60px !important; 
    max-width: 60px !important; 
  }
  .mobile-view .card-body .pnp-clave .clave-input { 
    width: 100px !important; 
    min-width: 100px !important; 
    max-width: 100px !important; 
  }
  .mobile-view .card-body .pnp-clave .ccn-input { 
    width: 100px !important; 
    min-width: 100px !important; 
    max-width: 100px !important; 
  }
  .mobile-view .card-body .dias-row .small-input { 
    min-width: 40px; 
    max-width: 50px; 
    font-size: 0.8rem; 
    padding: 3px 4px; 
  }
  main.flex-grow-1 { 
    padding: 12px 5px 15px; 
  }
}

/* Campo select P/NP con ancho fijo */
select.form-select.pnp-select { 
  width: 75px; 
  min-width: 75px; 
  max-width: 75px; 
}
.ccn-input { 
  width: 150px; 
  max-width: 150px; 
}

/* ===========================
   Ajuste de ancho columnas Desktop (P/NP, CLAVE, CCN)
=========================== */
@media (min-width: 992px) {

  .desktop-table-wrapper {
    max-height: 55vh; /* ocupa máximo 60% de la altura de la pantalla */
    overflow-y: auto;
  }

  /* Opcional: mantener cabecera fija */
  .desktop-table-wrapper table thead {
    position: sticky;
    top: 0;
    background: #343a40; /* igual que .table-dark */
    z-index: 2;
  }

  #tablaHoras {
    table-layout: fixed;  /* fuerza que se respeten anchos */
    width: 100%;
  }

  /* P/NP */
  #tablaHoras th:nth-child(1),
  #tablaHoras td:nth-child(1) { width: 80px; }

  /* CLAVE */
  #tablaHoras th:nth-child(2),
  #tablaHoras td:nth-child(2) { width: 180px; }

  /* CCN */
  #tablaHoras th:nth-child(3),
  #tablaHoras td:nth-child(3) { width: 150px; }

  /* Columnas horas L-D */
  #tablaHoras th:nth-child(n+4):nth-child(-n+10),
  #tablaHoras td:nth-child(n+4):nth-child(-n+10) { width: 60px; }

  /* Total final */
  #tablaHoras th:nth-child(11),
  #tablaHoras td:nth-child(11) { width: 70px; }
}

/* ===========================
   Resto de estilos (modal, login, teoricos-row...)
=========================== */
.teoricos-row { 
  background: #f1f8ff; 
  font-weight: 600; 
}
#modalCopiarSemana .modal-content { 
  border-radius: 12px; 
  box-shadow: 0 4px 20px rgba(0,0,0,0.15); 
  padding: 1rem; 
}
#modalCopiarSemana .modal-body { 
  max-height: 400px; 
  overflow-y: auto; 
}
#modalCopiarSemana .modal-dialog { 
  max-width: 500px; 
  width: 90%; 
  margin: auto; 
}

.card.login-card { 
  width: 500px; 
  max-width: 500px; 
  margin: 2rem auto; 
}
@media (max-width: 550px) {
  .card.login-card { 
    width: calc(100vw - 50px); 
    max-width: none; 
    margin: 1rem auto; 
  }
  .app-wrapper { 
    padding: 0 12px; 
  }
  main.flex-grow-1 { 
    padding: 15px 0; 
  }
}
/* ===========================
   Forzar dias L-D en una sola fila en móviles y tablets
=========================== */
.mobile-view .card-body .dias-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important; /* nunca apilen */
  justify-content: space-between !important;
  gap: 4px !important;
}

.mobile-view .card-body .dias-row > div {
  flex: 1 1 auto !important;  /* que se ajusten al ancho disponible */
  min-width: 30px !important;  /* suficiente para "24" */
  text-align: center;
}

.mobile-view .card-body .dias-row input.small-input {
  width: 100% !important;
  box-sizing: border-box !important;
  text-align: center !important;
  padding: 2px 4px !important;
  font-size: 0.85rem !important;
}

/* Ajuste extra para pantallas muy pequeñas (<488px) */
@media (max-width: 488px) {
  .mobile-view .card-body .dias-row > div {
    min-width: 25px !important;
  }
  .mobile-view .card-body .dias-row input.small-input {
    font-size: 0.8rem !important;
    padding: 1px 3px !important;
  }
}

/* ===== FONDO GENERAL MODERNO ===== */
body {
  background: 
    linear-gradient(rgba(255,255,255,0.65), rgba(255,255,255,0.65)),
    url('../img/codioful-formerly.jpg') no-repeat center center fixed;
  background-size: cover;
}
/* ===========================
   TÍTULO PRINCIPAL LOGIN
=========================== */

.hero-title {
  margin-top: 30px;
  margin-bottom: 20px;
}

.main-title {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(
    90deg,
    var(--rojo-corporativo),
    var(--rojo-soft)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* Móvil */
@media (max-width: 576px) {
  .main-title {
    font-size: 1.7rem;
  }

  .main-subtitle {
    font-size: 0.95rem;
  }
}

.texto-color-principal {
  color: var(--rojo-corporativo);
}

/* ===========================
   TABLA PRINCIPAL ESTILO PRO
=========================== */

#tablaHoras {
  border-radius: 16px;
  overflow: hidden; /* necesario para que se vean las esquinas */
  /*box-shadow: 0 14px 35px rgba(0, 0, 0, 0.18);*/
  background: #fff;
  border-collapse: separate;
  border-spacing: 0;
}

/* Mantener bordes finos y limpios */
#tablaHoras th,
#tablaHoras td {
  border: 1px solid #dee2e6;
}

/* Esquinas reales */
#tablaHoras thead tr:first-child th:first-child {
  border-top-left-radius: 16px;
}

#tablaHoras thead tr:first-child th:last-child {
  border-top-right-radius: 16px;
}

#tablaHoras tfoot tr:last-child td:first-child {
  border-bottom-left-radius: 16px;
}

#tablaHoras tfoot tr:last-child td:last-child {
  border-bottom-right-radius: 16px;
}

/* Hover elegante corporativo */
#tablaHoras tbody tr:hover {
  background: rgba(219, 8, 18, 0.06);
}

/* Cabecera más contundente */
#tablaHoras thead th {
  letter-spacing: 0.03em;
  font-weight: 700;
}
