/* Evitar recortes del contenido del select de estado */
.ts .value.dropdown-select {
  position: relative;
  overflow: visible;
}

/* Popup “Marcar como resuelto” */
#resolved-datetime-status-section {
  position: relative;
  overflow: visible;
  z-index: 1000;
  max-width: calc(100vw - 40px);
}

/* Datepicker: anchura y nivel de apilado */
.datepicker {
  max-width: calc(100vw - 40px);
  width: auto;
  z-index: 9999;
  transition: opacity .3s ease, transform .3s ease, left 0s .3s;
}

/* NUEVO: forzar reflow para que no desborde hacia la derecha */
#resolved-datetime-status-section.param.calendar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* NUEVO: label arriba como primer elemento y en su propia fila */
#resolved-datetime-status-section.param.calendar > label {
  order: 0;
  flex: 1 0 100%;
  margin: 0 0 6px 0;
}

/* Ordenar el resto para que quede limpio en una o varias filas */
#resolved-datetime-status-section.param.calendar .calendar--button { order: 1; }
#resolved-datetime-status-section.param.calendar .calendar--value  { order: 2; }
#resolved-datetime-status-section.param.calendar .form-group       { order: 3; }
#resolved-datetime-status-section.param.calendar > div:last-child  { order: 4; }
#resolved-datetime-status-section .calendar--button,
#resolved-datetime-status-section .calendar--value {
  flex: 0 0 auto; /* icono y valor, compactos */
}

#resolved-datetime-status-section .form-group,
#resolved-datetime-status-section > div:last-child {
  flex: 1 0 100%; /* hora y fila de botones a una nueva línea */
}

#resolved-datetime-status-section input[type="time"] {
  max-width: 160px;
}

/* Overlay móvil para enfoque del datepicker */
.datepicker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
  display: none;
}
.datepicker-overlay.active { display: block; }

/* Bloquear scroll del body cuando el datepicker está abierto */
body.datepicker-open { overflow: hidden; }

/* Ajustes móviles */
@media (max-width: 900px) {
  /* Centrar el datepicker como modal */
  .datepicker {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: calc(100vw - 40px) !important;
    max-width: 360px !important;
  }

  /* Botones del panel a ancho completo en móvil */
  #resolved-datetime-status-section .btn {
    width: 100%;
    margin-top: 8px;
  }
}

@media (max-width: 480px) {
  .datepicker {
    width: calc(100vw - 20px) !important;
    max-width: 320px !important;
    font-size: 12px;
  }
}

@media screen and (max-width: 400px) {
    #resolved-datetime-status-section .datepicker {
        width: calc(100vw - 20px) !important;
        max-width: 280px !important;
        font-size: 12px !important;
    }
}

/* NUEVO: Forzar el selector de estado a una nueva línea */
.sidebar .row:first-child {
    flex-wrap: wrap;
}
.sidebar .row:first-child .title,
.sidebar .row:first-child .value {
    flex: 1 0 100%;
}
.sidebar .row:first-child .value {
    padding-left: 0;
    padding-top: 5px;
}

/* Mostrar select de estado debajo del ":" solo cuando Resuelto esté activo */
#ticket-status-div.resolved-open {
  flex-wrap: wrap;
}
#ticket-status-div.resolved-open .title {
  display: none !important;
}
#ticket-status-div.resolved-open .value {
  padding-left: 0;
  padding-top: 8px;
}

/* Subir el label del select y hacerlo ancho completo */
#ticket-status-div.resolved-open .value.dropdown-select {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  position: relative; /* ancla de la dropdown-list */
}
#ticket-status-div.resolved-open .value.dropdown-select .label {
  order: -1 !important;        /* SUBIRLO POR ENCIMA DEL FORM */
  width: 100%;
  margin: 0 0 8px 0;
  float: none;
  position: relative;
}
#ticket-status-div.resolved-open .value.dropdown-select form {
  order: 0 !important;
  width: 100%;
}

/* La lista cae debajo del label, alineada a la izquierda */
#ticket-status-div.resolved-open .value.dropdown-select .dropdown-list {
  left: 0 !important;
  right: auto !important;
  transform: none !important;
  width: auto;
  min-width: 240px;
  max-width: 100%;
  z-index: 1001;
}

/* Asegurar que los labels del panel Resuelto se muestren */
#resolved-datetime-status-section > label,
#resolved-datetime-status-section .form-group > label,
#resolved-datetime-section > label,
#resolved-datetime-section .form-group > label {
  display: inline-block !important;
  visibility: visible !important;
}
/* Si el tema usa la clase .open en el contenedor, no ocultes el título */
#ticket-status-div.open .title {
  display: block !important;
}
/* Centrar el contenido del panel Resuelto (status y reply) */
#resolved-datetime-status-section.param.calendar,
#resolved-datetime-section.param.calendar {
  justify-content: center;
  text-align: center;
}
/* Ocultar el label placeholder (":") en la fila de calendario */
#resolved-datetime-status-section.param.calendar > label,
#resolved-datetime-section.param.calendar > label {
    display: none !important;
}

/* Asegurar que la parte de calendario ocupe el ancho sin el label */
#resolved-datetime-status-section.param.calendar > .value,
#resolved-datetime-section.param.calendar > .value {
    flex: 1 1 100%;
    max-width: 100%;
}
#resolved-datetime-status-section .calendar--value,
#resolved-datetime-section .calendar--value {
  text-align: center;
  margin: 0 auto;
}
#resolved-datetime-status-section .form-group,
#resolved-datetime-section .form-group {
  display: flex;
  justify-content: center;
}
#resolved-datetime-status-section > div:last-child,
#resolved-datetime-section > div:last-child {
  display: flex;
  justify-content: center;
  gap: 8px;
}
/* Mantener el ancho del datepicker dentro del contenedor (y no desbordar) */
#resolved-datetime-status-section .datepicker,
#resolved-datetime-section .datepicker {
  width: min(368px, 100%) !important; /* respeta ~368px sin pasarse del contenedor */
  max-width: 100% !important;
  min-width: 0 !important;            /* anula min-width heredado que provocaba overflow */
  box-sizing: border-box;
}

/* 7 columnas flexibles que no desbordan y centradas */
.datepicker .datepicker--days-names {
  display: grid !important;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  justify-items: center !important;
  column-gap: 6px;
}
.datepicker .datepicker--days-names .datepicker--day-name {
  width: auto !important;
  margin: 0 !important;
  text-align: center;
}

.datepicker .datepicker--cells:not(.datepicker--cells-months):not(.datepicker--cells-years) {
  display: grid !important;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  gap: 6px !important;
  justify-items: center; /* centra cada día dentro de su celda */
}
.datepicker .datepicker--cells:not(.datepicker--cells-months):not(.datepicker--cells-years) .datepicker--cell {
  width: auto !important;   /* ocupa su fracción de grid */
  height: 40px !important;  /* alto consistente sin forzar el ancho */
  margin: 0 !important;
  border-radius: 4px !important;
}
.datepicker .datepicker--cells:not(.datepicker--cells-months):not(.datepicker--cells-years) .datepicker--cell {
  width: 40px !important;
  height: 40px !important;
  margin: 0 !important;
}

/* Ajuste responsive sin perder 7 columnas */
@media (max-width: 480px) {
  .datepicker .datepicker--days-names {
    grid-template-columns: repeat(7, 36px) !important;
    column-gap: 4px;
  }
  .datepicker .datepicker--days-names .datepicker--day-name {
    width: 36px !important;
  }
  .datepicker .datepicker--cells:not(.datepicker--cells-months):not(.datepicker--cells-years) {
    grid-template-columns: repeat(7, 32px) !important;
    gap: 4px !important;
  }
  .datepicker .datepicker--cells:not(.datepicker--cells-months):not(.datepicker--cells-years) .datepicker--cell {
    width: 32px !important;
    height: 32px !important;
  }
}

/* Datepicker: invertir colores en hover/focus para mejor contraste */
#resolved-datetime-section input.datepicker:hover,
#resolved-datetime-section input.datepicker:focus,
#resolved-datetime-status-section input.datepicker:hover,
#resolved-datetime-status-section input.datepicker:focus,
input#resolved_date:hover,
input#resolved_date:focus,
input#resolved_date_status:hover,
input#resolved_date_status:focus {
    background-color: #0d6efd; /* azul contraste */
    color: #fff !important;
    border-color: #0d6efd;
    outline: none;
    caret-color: #fff;
}

/* Placeholder también en blanco durante hover/focus */
#resolved-datetime-section input.datepicker:hover::placeholder,
#resolved-datetime-section input.datepicker:focus::placeholder,
#resolved-datetime-status-section input.datepicker:hover::placeholder,
#resolved-datetime-status-section input.datepicker:focus::placeholder,
input#resolved_date:hover::placeholder,
input#resolved_date:focus::placeholder,
input#resolved_date_status:hover::placeholder,
input#resolved_date_status:focus::placeholder {
    color: #ffffffcc; /* blanco con ligera transparencia */
}

/* Opcional: si el sombreado externo sigue afectando la legibilidad, forzar inversión visual */
#resolved-datetime-section input.datepicker:hover,
#resolved-datetime-section input.datepicker:focus,
#resolved-datetime-status-section input.datepicker:hover,
#resolved-datetime-status-section input.datepicker:focus,
input#resolved_date:hover,
input#resolved_date:focus,
input#resolved_date_status:hover,
input#resolved_date_status:focus {
    /* Descomenta si quieres invertir todo el input en vez de usar colores fijos */
    /* filter: invert(1); */
}

/* Contraste para el valor de calendario (fecha) */
#resolved-datetime-section.param.calendar .calendar--value,
#resolved-datetime-section.param.calendar .calendar__value,
#resolved-datetime-status-section.param.calendar .calendar--value,
#resolved-datetime-status-section.param.calendar .calendar__value {
    color: #2C70A2;                       /* azul actual de la fecha */
    background-color: rgba(255, 255, 255, 0.92); /* pill blanco translúcido */
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    transition: color .2s ease, background-color .2s ease, filter .2s ease;
}

/* Invertir colores en hover/focus para mantener legibilidad cuando el panel se tiñe de azul */
#resolved-datetime-section.param.calendar:hover .calendar--value,
#resolved-datetime-section.param.calendar:focus-within .calendar--value,
#resolved-datetime-section.param.calendar:hover .calendar__value,
#resolved-datetime-section.param.calendar:focus-within .calendar__value,
#resolved-datetime-status-section.param.calendar:hover .calendar--value,
#resolved-datetime-status-section.param.calendar:focus-within .calendar--value,
#resolved-datetime-status-section.param.calendar:hover .calendar__value,
#resolved-datetime-status-section.param.calendar:focus-within .calendar__value {
    color: #fff;
    background-color: #2C70A2;
}

/* Acompañar la “X” de limpiar para que no se pierda visualmente */
#resolved-datetime-section.param.calendar .calendar__clear,
#resolved-datetime-section.param.calendar .calendar--clear,
#resolved-datetime-status-section.param.calendar .calendar__clear,
#resolved-datetime-status-section.param.calendar .calendar--clear {
    filter: none;
    transition: filter .2s ease;
}

#resolved-datetime-section.param.calendar:hover .calendar__clear,
#resolved-datetime-section.param.calendar:focus-within .calendar__clear,
#resolved-datetime-section.param.calendar:hover .calendar--clear,
#resolved-datetime-section.param.calendar:focus-within .calendar--clear,
#resolved-datetime-status-section.param.calendar:hover .calendar__clear,
#resolved-datetime-status-section.param.calendar:focus-within .calendar__clear,
#resolved-datetime-status-section.param.calendar:hover .calendar--clear,
#resolved-datetime-status-section.param.calendar:focus-within .calendar--clear {
    filter: invert(1);
}
/* X de limpiar fecha: SVG con círculo blanco y color controlado por CSS */
#resolved-datetime-section.param.calendar svg.icon.icon-close,
#resolved-datetime-status-section.param.calendar svg.icon.icon-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.95);
  color: #2C70A2;
  border: 1px solid rgba(44, 112, 162, 0.35);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease, transform .1s ease;
}

/* Asegurar que las figuras del SVG hereden el color */
#resolved-datetime-section.param.calendar svg.icon.icon-close *,
#resolved-datetime-status-section.param.calendar svg.icon.icon-close * {
  fill: currentColor !important;
  stroke: currentColor !important;
}

/* Hover/focus dentro del bloque: invertir colores */
#resolved-datetime-section.param.calendar:hover svg.icon.icon-close,
#resolved-datetime-section.param.calendar:focus-within svg.icon.icon-close,
#resolved-datetime-status-section.param.calendar:hover svg.icon.icon-close,
#resolved-datetime-status-section.param.calendar:focus-within svg.icon.icon-close {
  background-color: #2C70A2;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(44, 112, 162, 0.35);
}

/* Estado del panel Resuelto teñido (clase "resolve" en #ticket-status-div) */
#ticket-status-div.resolve .param.calendar svg.icon.icon-close {
  background-color: #2C70A2;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(44, 112, 162, 0.35);
}

/* Accesibilidad: foco teclado notorio y leve “pop” */
#resolved-datetime-section.param.calendar svg.icon.icon-close:focus-visible,
#resolved-datetime-status-section.param.calendar svg.icon.icon-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  transform: scale(1.05);
}
input#resolved_date:hover,
input#resolved_date:focus,
input#resolved_date_status:hover,
input#resolved_date_status:focus {
    background-color: #0d6efd; /* azul contraste */
    color: #fff !important;
    border-color: #0d6efd;
    outline: none;
    caret-color: #fff;
}

/* Placeholder también en blanco durante hover/focus */
#resolved-datetime-section input.datepicker:hover::placeholder,
#resolved-datetime-section input.datepicker:focus::placeholder,
#resolved-datetime-status-section input.datepicker:hover::placeholder,
#resolved-datetime-status-section input.datepicker:focus::placeholder,
input#resolved_date:hover::placeholder,
input#resolved_date:focus::placeholder,
input#resolved_date_status:hover::placeholder,
input#resolved_date_status:focus::placeholder {
    color: #ffffffcc; /* blanco con ligera transparencia */
}

/* Opcional: si el sombreado externo sigue afectando la legibilidad, forzar inversión visual */
#resolved-datetime-section input.datepicker:hover,
#resolved-datetime-section input.datepicker:focus,
#resolved-datetime-status-section input.datepicker:hover,
#resolved-datetime-status-section input.datepicker:focus,
input#resolved_date:hover,
input#resolved_date:focus,
input#resolved_date_status:hover,
input#resolved_date_status:focus {
    /* Descomenta si quieres invertir todo el input en vez de usar colores fijos */
    /* filter: invert(1); */
}
