/* ==============================
   Variables locales (Index)
   ============================== */
:root {
  --h-ficha: 16.5rem;
  --h-transcripcion: 250px;
}

/* ==============================
   Layout general y fichas
   ============================== */
.header-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: calc(100% - 40px);
  margin-left: 20px;
  margin-right: 20px;
}
.header-row .header-row-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* Fijamos el ancho de la ficha para que no varíe entre tabs */
.header-row .ficha {
  min-height: var(--h-ficha);
  flex: 0 0 42.5rem;
}
/* El historial ocupa el resto del espacio */
.header-row .historial {
  flex: 1 1 20rem;
  min-width: 20rem;
  min-height: var(--h-ficha);
}
.header-row .story-grid {
  flex: 1 1 auto;
}
/* Divisor vertical entre columnas */
.header-row .v-divider {
  width: 1px;
  background: var(--line);
  align-self: stretch;
}

/* Breakpoint de header-row: ver index-responsive.css */

/* Historial: hacer que la grilla ocupe el alto y el botón quede debajo */
.header-row .historial {
  display: flex;
  flex-direction: column;
}
.header-row .historial .transcript-log {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  overflow-y: auto;
}
.historial-actions {
  margin-top: 0.5rem;
}
.historial-actions .btn i[data-lucide] {
  width: 16px;
  height: 16px;
}

/* Historial accesible en tarjetas */
.story-grid {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: normal;
}
.story-grid .story-body {
  padding-bottom: 0.1rem;
}
.story-cell {
  display: block;
  overflow-wrap: anywhere;
}
.story-header,
.story-row {
  display: grid;
  grid-template-columns: 5.75rem 1fr;
  gap: 0.4rem;
  align-items: center;
  padding: 0.14rem 0.3rem;
}
.story-header {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.story-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.story-row {
  cursor: pointer;
  border-top: 1px solid var(--line);
  font-size: 0.7rem;
}
.story-row:hover {
  background-color: var(--accent-dim);
}
.story-cell.story-time {
  color: var(--muted);
  white-space: nowrap;
}

.transcript-log {
  font-family: "Monaco", "Menlo", monospace;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.85rem;
  overflow-y: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  height: 11.7rem;
}

/* Contenedor base de las vistas: los visores (Eventos/Ejecuciones/Archivos)
   y Configuración IA usan .content-wrap; Telefonía, Conectores y Dashboard
   usan .operator-panel. Comparten el mismo gutter / padding horizontal de
   20px acordado en la Fase 02; cada uno agrega sólo lo que difiere —
   .operator-panel el width:100%, .dashboard-panel el padding vertical y el
   scroll propio (ver index-dashboard.css). */
.content-wrap,
.operator-panel {
  margin-top: 8px;
  padding-left: 20px;
  padding-right: 20px;
}

/* Ancho fijo centrado para contenido de tabla ancha (patrón definido en PhosFlow fase 49). */
.content-wrap {
  max-width: 1060px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* .operator-panel extiende la base: ancla al 100% del ancho disponible. */
.operator-panel {
  width: 100%;
}

/* Iconos en toasts */
.toast .lucide {
  width: 16px;
  height: 16px;
}

/* Ficha cliente con tabs laterales */
.card-ficha-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-height: 0;
}

.card-ficha-tabs {
  display: inline-flex;
  gap: 0.35rem;
  padding-top: 0.2rem;
  padding-bottom: 0.35rem;
  border-top: 2px solid var(--line);
  border-bottom: none;
  justify-content: flex-end;
  width: 100%;
}

.card-ficha-tabs .nav-link {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: -3px;
}

.card-ficha-tabs .nav-link:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.card-ficha-tabs .nav-link.active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 25%, transparent);
}

.card-ficha-content {
  /* Alto fijo + scroll interno: el tab Ubicación (mapa + formulario) es más alto
     que el tab Cliente; sin esto estira la card al cambiar de tab. Así la card
     mantiene --h-ficha y el contenido scrollea dentro. */
  flex: 1 1 auto;
  height: 13.5rem;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.card-ficha-content .tab-pane {
  flex: 1 1 auto;
  display: none;
  flex-direction: column;
  min-height: 0;
}

.card-ficha-content .tab-pane.active,
.card-ficha-content .tab-pane.show {
  display: flex;
}

.card-ficha-body .tab-pane .row.g-2,
.card-ficha-body .tab-pane .row.g-3 {
  --bs-gutter-x: 0.5rem;
  --bs-gutter-y: 0.35rem;
}

.card-ficha-body .input-group-sm > .btn {
  /* Misma altura que el input de la ficha (34px canónicos del shell) para que
     los botones "Llamar / Obtener info del número" no queden más bajos. */
  height: 34px;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.card-ficha-body .btn.btn-outline-secondary {
  --bs-btn-padding-y: 0.2rem;
  --bs-btn-padding-x: 0.4rem;
  font-size: 0.75rem;
}

.card-ficha-body i[data-lucide] {
  width: 12px;
  height: 12px;
  display: inline-block;
  flex-shrink: 0;
}
.card-ficha-body .input-group-sm > .btn i[data-lucide],
.card-ficha-body .input-group-sm > .btn svg {
  width: 11px;
  height: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.card-ficha-location {
  gap: 0.35rem;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.card-ficha-location.show {
  display: flex;
  flex-direction: column;
}
.card-ficha-location-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 0.75rem;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
}
.card-ficha-location-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.card-ficha-location-map {
  min-width: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.card-ficha-location-actions {
  margin-top: 0.35rem;
  display: flex;
}
.card-ficha-location-actions .btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 28px;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}
.card-ficha-location-actions .btn i[data-lucide] {
  width: 16px;
  height: 16px;
}
.card-ficha-location-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.card-ficha-location-grid .location-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.card-ficha-location-grid .location-field {
  flex: 1 1 0;
  display: flex;
}
.card-ficha-location-grid .location-field > * {
  width: 100%;
}
.card-ficha-location-grid .location-row .location-field:only-child {
  flex-basis: 100%;
}
.card-ficha-location-grid input[readonly] {
  background-color: #f8f9fa;
}
.client-map-wrapper {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  flex: 1 1 auto;
  min-height: 180px;
}
.client-map {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: none;
}
.client-map.leaflet-container {
  display: block;
}
.client-map-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  text-align: center;
}

/* Breakpoint de tabs y layout Ficha -> ver index-responsive.css */
