/* ===== ESTILOS PARA DATETIME PICKER ===== */

/* Eliminar estilos nativos del navegador para inputs datetime-local */
input[type="datetime-local"].inp,
input[type="datetime-local"].datetime-picker-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Asegurar que el borde sea consistente con otros campos .inp */
  border: 2px solid var(--border-strong) !important;
  border-radius: 10px;
}

/* Modo oscuro: asegurar mismo borde que selects */
.dark input[type="datetime-local"].inp,
.dark input[type="datetime-local"].datetime-picker-input,
[data-theme="dark"] input[type="datetime-local"].inp,
[data-theme="dark"] input[type="datetime-local"].datetime-picker-input {
  border: 2px solid var(--border-strong) !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
}

@media (prefers-color-scheme: dark) {
  :root:not(.force-light) input[type="datetime-local"].inp,
  :root:not(.force-light) input[type="datetime-local"].datetime-picker-input {
    border: 2px solid var(--border-strong) !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
  }
}

/* Wrapper del datetime picker */
.datetime-picker-wrapper {
  position: relative;
  width: 100%;
}

/* Asegurar que el wrapper en filtros avanzados tenga el mismo tamaño que los selects de la toolbar */
.advanced-filters-panel .datetime-picker-wrapper,
.advanced-filters-content .datetime-picker-wrapper,
.filter-field .datetime-picker-wrapper {
  height: 28px;
  box-sizing: border-box;
}

/* Display del valor formateado */
.datetime-display-24h {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--fg);
  font-size: 0.95rem; /* Mismo tamaño que los selects de la toolbar */
  z-index: 2; /* Por encima del pseudo-elemento que cubre el input */
  line-height: normal;
}

/* Asegurar que el input tenga el mismo padding cuando tiene display */
.datetime-picker-wrapper input[type="datetime-local"] {
  padding-left: 12px;
  padding-right: 12px;
}

/* Cuando hay display, cubrir el input con un pseudo-elemento para ocultar el placeholder */
.datetime-picker-wrapper:has(.datetime-display-24h)::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  z-index: 0;
  pointer-events: none;
  border-radius: 10px;
}

/* Cuando hay display, ajustar padding para que no se superponga */
.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"] {
  padding-left: 12px;
  color: transparent !important; /* Ocultar el valor nativo del input */
  caret-color: transparent !important; /* Ocultar el cursor también */
  position: relative;
  z-index: 1; /* Por encima del fondo pero debajo del display */
}

/* Ocultar todos los elementos internos del input datetime-local cuando hay display */
.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit {
  display: none !important;
}

.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper {
  display: none !important;
}

.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit-text {
  display: none !important;
}

.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit-month-field {
  display: none !important;
}

.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit-day-field {
  display: none !important;
}

.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit-year-field {
  display: none !important;
}

.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit-hour-field {
  display: none !important;
}

.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit-minute-field {
  display: none !important;
}

.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit-second-field {
  display: none !important;
}

.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"]::-webkit-datetime-edit-ampm-field {
  display: none !important;
}

/* Para Firefox y otros navegadores - FORZAR ocultación completa */
.datetime-picker-wrapper:has(.datetime-display-24h) input[type="datetime-local"] {
  text-indent: -9999px !important;
  overflow: hidden !important;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
}

/* Cuando NO hay display, mostrar el input normalmente */
.datetime-picker-wrapper:not(:has(.datetime-display-24h)) input[type="datetime-local"] {
  color: var(--fg) !important;
  text-indent: 0 !important;
  caret-color: var(--fg) !important;
}

/* Estilos del picker flotante */
.datetime-picker {
  position: fixed;
  background: var(--card);
  border: 2px solid var(--border-strong) !important;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  min-width: 260px;
  max-width: 280px;
  padding: 10px;
}

/* Asegurar bordes en modo oscuro */
.dark .datetime-picker,
[data-theme="dark"] .datetime-picker {
  border: 2px solid var(--border-strong) !important;
}

@media (prefers-color-scheme: dark) {
  :root:not(.force-light) .datetime-picker {
    border: 2px solid var(--border-strong) !important;
  }
}

.datetime-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.datetime-picker__nav {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--fg);
  transition: all 0.15s;
  font-size: 0.85rem;
}

.datetime-picker__nav:hover {
  background: var(--gray-100);
  border-color: var(--brand-500);
}

.datetime-picker__title {
  display: flex;
  gap: 4px;
  align-items: center;
}

.datetime-picker__month,
.datetime-picker__year {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  font-size: 0.8rem;
}

.datetime-picker__calendar {
  margin-bottom: 8px;
}

.datetime-picker__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.datetime-picker__weekday {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  padding: 2px;
}

.datetime-picker__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.datetime-picker__day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s;
  color: var(--fg);
  min-height: 28px;
}

.datetime-picker__day:hover {
  background: var(--gray-100);
  border-color: var(--border);
}

.datetime-picker__day--selected {
  background: var(--brand-500);
  color: white;
  border-color: var(--brand-600);
  font-weight: 600;
}

.datetime-picker__day--today {
  border-color: var(--brand-500);
  font-weight: 600;
}

.datetime-picker__day--other {
  color: var(--muted);
  opacity: 0.5;
}

.datetime-picker__time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.datetime-picker__time-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.datetime-picker__time-group label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.datetime-picker__hour,
.datetime-picker__minute {
  width: 45px;
  padding: 5px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 45px;
}

.datetime-picker__hour:focus,
.datetime-picker__minute:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 2px rgba(255,122,0,.15);
}

.datetime-picker__time-separator {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  margin-top: 12px;
}

.datetime-picker__actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.datetime-picker__actions .btn {
  padding: 6px 12px;
  font-size: 0.85rem;
}
