/* =====================================================================
   Estilos del sistema - Constructora Alvatech
   Complementan a Bootstrap 5. Paleta "construcción": ámbar + pizarra.
   ===================================================================== */
:root {
  --marca:        #e8890c;   /* ámbar/naranja construcción */
  --marca-oscuro: #c56e00;
  --pizarra:      #1f2937;   /* sidebar oscuro */
  --pizarra-2:    #111827;
  --texto-tenue:  #9ca3af;
}

body {
  background-color: #f3f4f6;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---- Botón de marca -------------------------------------------------*/
.btn-marca {
  background-color: var(--marca);
  border-color: var(--marca);
  color: #fff;
}
.btn-marca:hover,
.btn-marca:focus {
  background-color: var(--marca-oscuro);
  border-color: var(--marca-oscuro);
  color: #fff;
}
.text-marca { color: var(--marca) !important; }
a { color: var(--marca-oscuro); }

/* ==== LOGIN ==========================================================*/
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--pizarra-2), var(--pizarra));
}
/* Manchas de color difuminadas que flotan de fondo (movimiento sutil). */
.login-wrap::before,
.login-wrap::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .32;
  pointer-events: none;
}
.login-wrap::before {
  width: 420px; height: 420px;
  background: var(--marca);
  top: -120px; left: -110px;
  animation: blob 15s ease-in-out infinite;
}
.login-wrap::after {
  width: 360px; height: 360px;
  background: #2563eb;
  bottom: -130px; right: -90px;
  animation: blob 19s ease-in-out infinite reverse;
}
@keyframes blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(45px, 30px) scale(1.15); }
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  overflow: hidden;
  position: relative;
  z-index: 1;
  animation: cardIn .7s cubic-bezier(.16, .84, .44, 1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-header {
  background: linear-gradient(135deg, var(--marca), var(--marca-oscuro));
  color: #fff;
  padding: 2rem 1.5rem 1.75rem;
  text-align: center;
}
.login-logo {
  width: 68px; height: 68px;
  margin: 0 auto .6rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, .16);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
  animation: logoPop .8s .15s cubic-bezier(.16, .84, .44, 1) both;
}
.login-logo i { font-size: 2.1rem; line-height: 1; }
@keyframes logoPop {
  from { opacity: 0; transform: scale(.5) rotate(-12deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

.login-body { padding: 1.75rem 1.75rem 1.5rem; }
/* Aparición escalonada de cada bloque del formulario. */
.login-body .field { animation: fieldIn .6s both; animation-delay: var(--d, 0s); }
@keyframes fieldIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-body .input-group-text {
  background: #f9fafb;
  color: var(--marca-oscuro);
  border-right: 0;
}
.login-body .form-control { border-left: 0; }
.login-body .form-control:focus { box-shadow: none; }
.login-body .input-group:focus-within {
  border-radius: .5rem;
  box-shadow: 0 0 0 .2rem rgba(232, 137, 12, .25);
}
.login-body .input-group:focus-within .form-control,
.login-body .input-group:focus-within .input-group-text,
.login-body .input-group:focus-within .btn-eye {
  border-color: var(--marca);
}
.btn-eye {
  background: #f9fafb;
  border: 1px solid #dee2e6;
  border-left: 0;
  color: #6b7280;
}
.btn-eye:hover, .btn-eye:focus { color: var(--marca-oscuro); }

.btn-marca { transition: transform .12s ease, background-color .15s ease; }
.btn-marca:active { transform: scale(.985); }

/* Respeta a quien prefiere menos movimiento. */
@media (prefers-reduced-motion: reduce) {
  .login-card, .login-logo, .login-body .field,
  .login-wrap::before, .login-wrap::after { animation: none !important; }
}

/* ==== LAYOUT (sidebar + contenido) ==================================*/
.app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 258px;
  background: linear-gradient(180deg, #202b3b 0%, var(--pizarra) 55%, var(--pizarra-2) 100%);
  color: #e5e7eb;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1030;
  transition: transform .25s ease;
  box-shadow: 2px 0 16px rgba(0, 0, 0, .18);
}
.sidebar-brand {
  padding: 1.1rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  display: flex;
  align-items: center;
  gap: .7rem;
}
.sidebar-brand .brand-logo {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--marca), var(--marca-oscuro));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.35rem;
  box-shadow: 0 4px 12px rgba(232, 137, 12, .35);
}
.sidebar-brand .brand-text {
  display: flex; flex-direction: column; line-height: 1.15;
  font-weight: 700; font-size: 1.05rem; color: #fff;
}
.sidebar-brand .brand-text small {
  font-size: .68rem; font-weight: 500; letter-spacing: .3px;
  color: var(--texto-tenue); text-transform: uppercase;
}
.sidebar-nav { padding: .6rem .55rem; flex: 1; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 3px; }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.nav-group { margin-bottom: .15rem; }
.nav-group + .nav-group { margin-top: .1rem; }

/* Ítems (enlaces) del menú -> pill redondeado */
.sidebar-nav .nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: 1px .1rem;
  padding: .58rem .7rem;
  border-radius: 9px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: .93rem;
  transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav .nav-item i { width: 20px; text-align: center; font-size: 1.02rem; color: var(--texto-tenue); transition: color .15s ease; }
.sidebar-nav .nav-item:hover i { color: #e5e7eb; }
.sidebar-nav .nav-item.activo {
  background: linear-gradient(90deg, rgba(232, 137, 12, .22), rgba(232, 137, 12, .10));
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(232, 137, 12, .28);
}
.sidebar-nav .nav-item.activo i { color: var(--marca); }
/* Acento a la izquierda del ítem activo */
.sidebar-nav .nav-item.activo::before {
  content: "";
  position: absolute; left: -.1rem; top: 20%; bottom: 20%;
  width: 3px; border-radius: 3px; background: var(--marca);
}

/* Sub-ítems: indentados con guía vertical */
.sidebar-nav .nav-item.sub { margin-left: 1.55rem; padding-left: .8rem; font-size: .9rem; }
.sidebar-nav .nav-item.sub::after {
  content: "";
  position: absolute; left: -.35rem; top: 0; bottom: 0;
  width: 1.5px; background: rgba(255, 255, 255, .09);
}
.sidebar-nav .nav-item.sub:hover::after { background: rgba(255, 255, 255, .18); }
.sidebar-nav .nav-item.sub.activo::after { background: var(--marca); }
.sidebar-nav .nav-item.sub.activo::before { display: none; }

/* Encabezado de un grupo (botón que colapsa) */
.nav-group-title {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: .35rem .1rem .1rem;
  padding: .4rem .7rem;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: #8a97a8;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.nav-group-title:hover { color: #e5e7eb; background: rgba(255, 255, 255, .03); }
.nav-group-title i:first-child { width: 20px; text-align: center; font-size: .9rem; color: var(--marca); opacity: .85; }
.nav-group-title .chevron {
  margin-left: auto;
  font-size: .7rem;
  opacity: .7;
  transition: transform .25s ease;
}
.nav-group-title.collapsed .chevron { transform: rotate(-90deg); }
.sidebar-foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: .8rem;
  color: var(--texto-tenue);
}

.contenido {
  margin-left: 250px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.topbar h1 { font-size: 1.15rem; margin: 0; font-weight: 600; }
.main { padding: 1.5rem; }

/* ---- Tarjetas de resumen (dashboard) --------------------------------*/
.stat-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
}
.stat-card .icono {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.stat-card .valor { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat-card .etiqueta { color: #6b7280; font-size: .85rem; }

.card { border: none; border-radius: 12px; box-shadow: 0 2px 10px rgba(0, 0, 0, .05); }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; color: #6b7280; }

/* ---- Responsive: sidebar colapsable en móvil ------------------------*/
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 1025;
}
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.abierto { transform: translateX(0); }
  .contenido { margin-left: 0; }
  .sidebar-backdrop.visible { display: block; }
}

/* ---- Impresión / PDF -----------------------------------------------*/
/* Bloques que SOLO se ven al imprimir (encabezado y pie del reporte). */
.solo-print { display: none; }

@media print {
  @page { margin: 1.2cm; }

  .sidebar, .topbar, .no-print { display: none !important; }
  .contenido { margin-left: 0; }
  .main { padding: 0; }
  body { background: #fff; font-size: 11px; }

  /* Conserva los colores de fondo (badges, iconos, tarjetas). */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .solo-print { display: block !important; }

  /* Tarjetas planas y sin cortes a mitad de página. */
  .card {
    box-shadow: none !important;
    border: 1px solid #d1d5db !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .card + .card, .row + .card, .card.mt-3 { margin-top: .5rem !important; }

  /* Las tarjetas de resumen (KPIs) caben en una fila. */
  #d-tarjetas .col-sm-6,
  #d-tarjetas .col-xl-3 { width: 25% !important; flex: 0 0 25% !important; }
  .stat-card .valor { font-size: 1rem !important; }

  /* Encabezados de tabla se repiten en cada página. */
  thead { display: table-header-group; }
  tr, td, th { page-break-inside: avoid; }
  table { font-size: 10px !important; }

  /* Encabezado del reporte. */
  .report-head { border-bottom: 3px solid var(--marca); margin-bottom: 1rem; padding-bottom: .6rem; }
  .report-head h3 { color: var(--marca); margin: 0; }
  .report-foot { margin-top: 1rem; padding-top: .5rem; border-top: 1px solid #d1d5db;
    font-size: 9px; color: #6b7280; display: flex; justify-content: space-between; }
}
