@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@500;600;700;800;900&display=swap');

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', sans-serif;
}

body {
  font-family: var(--font-sans);
  background-color: #f8fafc;
  color: #1e293b;
}

h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
}

/* Custom scrollbars (Light mode) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Glassmorphism & Card styling (Light mode) */
.glass-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
}

.glass-card-hover {
  transition: all 0.2s ease-in-out;
}

.glass-card-hover:hover {
  border-color: #38bdf8;
  box-shadow: 0 10px 25px -5px rgba(14, 165, 233, 0.1), 0 8px 10px -6px rgba(14, 165, 233, 0.05);
  transform: translateY(-1px);
}

/* -------------------------------------------------------------
   FOLIO A4 VERTICAL (PRESUPUESTOS Y FACTURAS) - 1 PÁGINA EXACTA
   ------------------------------------------------------------- */
.folio-a4-sheet {
  width: 210mm;
  min-height: 296mm;
  height: 296mm;
  max-height: 296mm;
  margin: 0 auto;
  padding: 6mm 10mm 4mm 10mm;
  background: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  position: relative;
  font-family: 'Inter', sans-serif;
  box-sizing: border-box !important;
  font-size: 11px;
  line-height: 1.25;
  overflow: hidden !important;
}

/* -------------------------------------------------------------
   FOLIO A4 HORIZONTAL / LANDSCAPE (CERTIFICADO) - 1 PÁGINA EXACTA
   ------------------------------------------------------------- */
.folio-certificado-sheet {
  width: 297mm;
  min-height: 209mm;
  height: 209mm;
  max-height: 209mm;
  margin: 0 auto;
  padding: 5mm 9mm 5mm 9mm;
  background: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  position: relative;
  font-family: 'Inter', sans-serif;
  box-sizing: border-box !important;
  font-size: 10px;
  line-height: 1.3;
  overflow: hidden !important;
}

.folio-a4-sheet *, .folio-certificado-sheet * {
  color-adjust: exact;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* MARCA DE AGUA EXCLUSIVA PARA PRESUPUESTOS */
.watermark-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-25deg);
  pointer-events: none;
  user-select: none;
  z-index: 2;
  opacity: 0.22;
  text-align: center;
  width: 170mm;
}

.watermark-container img {
  width: 75mm;
  height: auto;
  margin: 0 auto;
  display: block;
}

.watermark-text {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #0369a1;
  margin-top: 6px;
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  *, *::before, *::after {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  html, body {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #0f172a !important;
    overflow: visible !important;
  }

  /* Hide app chrome, sidebar, dashboard, notifications and non-printable buttons */
  .no-print,
  aside,
  header,
  nav,
  .flex.h-screen,
  #toast-container,
  [x-show="modalPresupuestoForm"],
  [x-show="modalTarifaForm"],
  [x-show="modalCertificadoEdit"],
  [x-show="modalNuevoUsuario"],
  [x-show="modalNuevoCliente"],
  [x-show="modalCompartirDoc"] {
    display: none !important;
  }

  /* Reset all modal containers so they don't clip, offset, or add backdrops/margins */
  [x-show="modalA4Type"],
  [x-show="modalFichaOficial"] {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    overflow: visible !important;
    z-index: auto !important;
  }

  [x-show="modalA4Type"] > div,
  [x-show="modalFichaOficial"] > div {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  [x-show="modalA4Type"] > div > div:not(.no-print),
  [x-show="modalFichaOficial"] > div > div:not(.no-print) {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
  }

  #folio-a4-render,
  #fichaOficialContenedorA4 {
    display: block !important;
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 auto !important;
    background: #ffffff !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
    overflow: visible !important;
  }

  .folio-a4-sheet {
    width: 210mm !important;
    height: 296mm !important;
    min-height: 296mm !important;
    max-height: 296mm !important;
    padding: 6mm 10mm 4mm 10mm !important;
    margin: 0 auto !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .folio-certificado-sheet {
    width: 297mm !important;
    height: 209mm !important;
    min-height: 209mm !important;
    max-height: 209mm !important;
    padding: 5mm 9mm 5mm 9mm !important;
    margin: 0 auto !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }
}

/* =============================================================
   SIDEBAR PRINCIPAL MIRANDA ERP (GARANTÍA VISUAL TOTAL)
   ============================================================= */
@media (min-width: 768px) {
  #main-sidebar {
    position: static !important;
    transform: none !important;
    width: 16rem !important;
    min-width: 16rem !important;
    max-width: 16rem !important;
    flex-shrink: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* Anular cualquier ocultado de Alpine o Tailwind */
    pointer-events: auto !important;
  }
  /* Forzar que los menús dentro del sidebar sean siempre visibles */
  #main-sidebar [x-show] {
    /* Alpine gestiona display internamente, no interferir */
  }
}

@media (max-width: 767px) {
  #main-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    z-index: 50 !important;
    width: 18rem !important;
    max-width: 85vw !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  #main-sidebar.drawer-closed {
    transform: translateX(-100%) !important;
  }
  #main-sidebar.drawer-open {
    transform: translateX(0) !important;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35) !important;
  }
}

/* =============================================================
   CALENDARIO DE INTERVENCIONES (PROTECCIÓN CONTRA DESBORDAMIENTO)
   ============================================================= */
.calendar-grid-cell {
  min-width: 0 !important;
  overflow: hidden !important;
  word-break: break-word !important;
}

.calendar-appointment-pill {
  display: flex !important;
  align-items: center !important;
  gap: 0.25rem !important;
  min-width: 0 !important;
  width: 100% !important;
  overflow: hidden !important;
}

.calendar-appointment-pill span {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.calendar-appointment-pill span.truncate {
  display: block !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  flex: 1 1 0% !important;
  min-width: 0 !important;
}

/* =============================================================
   ADAPTACIONES GLOBALES RESPONSIVAS (MÓVIL Y TABLET)
   ============================================================= */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

main {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

@media (max-width: 767px) {
  /* Evitar zoom automático excesivo en inputs de iOS al enfocar */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 15px !important;
  }

  /* Ajuste de márgenes y paddings en modales para pantallas pequeñas */
  .fixed.inset-0.flex.items-center.justify-center {
    padding: 0.5rem !important;
  }

  /* Asegurar que las tarjetas y contenedores ocupen ancho completo sin desborde */
  .glass-card,
  .rounded-3xl,
  .rounded-2xl {
    max-width: 100% !important;
  }

  /* Scrollbars táctiles fluidos */
  .overflow-x-auto,
  .overflow-y-auto {
    -webkit-overflow-scrolling: touch;
  }
}


