@use "sass:color";
@use "variables";

/* Enhanced TimePicker Styles */
.input-field.timepicker {
  input[disabled] {
    cursor: not-allowed;
  }
}

.timepicker-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;

  .btn-flat {
    padding: 2px 8px;
    min-width: auto;
    height: 24px;
    line-height: 20px;
    font-size: 11px;
    text-transform: none;

    i.material-icons {
      font-size: 14px;
      margin-right: 4px;
    }
  }
}

.inline-time-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 12px;
  background-color: var(--mm-border-color, #f5f5f5);
  border-radius: 4px;
  font-size: 14px;

  .time-controls-12h {
    display: flex;
    align-items: center;
    gap: 4px;

    input[type="number"] {
      width: 50px;
      text-align: center;
      padding: 4px;
      border: 1px solid var(--mm-border-color, #ccc);
      border-radius: 4px;
    }

    select {
      padding: 4px;
      border: 1px solid var(--mm-border-color, #ccc);
      border-radius: 4px;
      margin-left: 4px;
    }
  }

  input[type="time"] {
    font-size: 16px;
    padding: 4px 8px;
    border: 1px solid var(--mm-border-color, #ccc);
    border-radius: 4px;
    min-width: 120px;
  }

  .btn-flat {
    padding: 4px 8px;
    font-size: 11px;
    background-color: var(--mm-border-color, #e0e0e0);
    border-radius: 4px;
    min-width: auto;
  }
}

/* Timepicker Containers */
.timepicker-modal {
  max-width: 325px;
  max-height: none;
  overflow: hidden;
}

.timepicker-container.modal-content {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.text-primary {
	color: rgba(255, 255, 255, 1);
}


/* Clock Digital Display */
.timepicker-digital-display {
  flex: 1 auto;
  background-color: variables.$secondary-color;
  padding: 10px;
  font-weight: 300;
  min-width: 200px;
  position: relative;
}

.timepicker-text-container {
	font-size: 4rem;
	font-weight: bold;
	text-align: center;
	color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
	position: relative;
  user-select: none;
  min-width: 180px;
  width: 100%;
}

.timepicker-span-hours,
.timepicker-span-minutes,
.timepicker-span-am-pm div {
	cursor: pointer;
}

.timepicker-span-hours {
  margin-right: 3px;
  display: inline-block;
  min-width: 2ch;
  text-align: right;
}

.timepicker-span-minutes {
  margin-left: 3px;
  display: inline-block;
  min-width: 2ch;
  text-align: left;
}

.timepicker-display-am-pm {
  font-size: 1.3rem;
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  font-weight: 400;
}


/* Analog Clock Display */
.timepicker-analog-display {
  flex: 2.5 auto;
}

.timepicker-plate {
	background-color: variables.$timepicker-clock-plate-bg;
	border-radius: 50%;
	width: 270px;
	height: 270px;
	overflow: visible;
	position: relative;
  margin: auto;
  margin-top: 25px;
  margin-bottom: 5px;
	user-select: none;
}

.timepicker-canvas,
.timepicker-dial {
	position: absolute;
	left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.timepicker-dial {
  pointer-events: none;
}
.timepicker-minutes {
	visibility: hidden;
}

.timepicker-tick {
	border-radius: 50%;
	color: variables.$timepicker-clock-color;
	line-height: 40px;
	text-align: center;
	width: 40px;
	height: 40px;
	position: absolute;
	cursor: pointer;
  font-size: 15px;
  pointer-events: none;
}

.timepicker-tick.active,
.timepicker-tick:hover {
	background-color: color.scale(variables.$secondary-color, $alpha: -75%);
}
.timepicker-dial {
	transition: transform 350ms, opacity 350ms;
}
.timepicker-dial-out {
  &.timepicker-hours {
	  transform: scale(1.1, 1.1);
  }

  &.timepicker-minutes {
	  transform: scale(.8, .8);
  }

	opacity: 0;
}
.timepicker-canvas {
	transition: opacity 175ms;

  line {
	  stroke: variables.$secondary-color;
	  stroke-width: 4;
	  stroke-linecap: round;
  }
}
.timepicker-canvas-out {
	opacity: 0.25;
}
.timepicker-canvas-bearing {
	stroke: none;
	fill: variables.$secondary-color;
}
.timepicker-canvas-bg {
	stroke: none;
	fill: variables.$secondary-color;
}


/* Footer */
.timepicker-footer {
  margin: 0 auto;
  padding: 5px 1rem;
  display: flex;
  justify-content: space-between;
}

.timepicker-clear {
  color: variables.$error-color;
}

.timepicker-close {
  color: variables.$secondary-color;
}

.timepicker-clear,
.timepicker-close {
  padding: 0 20px;
}

/* Digital Clock Mode */
.timepicker-digital-mode {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 2.5 auto;
  overflow: hidden;
}

.timepicker-digital-clock {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  user-select: none;
  overflow: hidden;
}

.digital-clock-column {
  width: 80px;
  height: 240px;
  overflow-y: scroll;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  position: relative;

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
  }

  &::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
  }

  // Show scrollbar on hover
  &:hover {
    scrollbar-color: rgba(0, 0, 0, 0.3) transparent;

    &::-webkit-scrollbar-thumb {
      background: rgba(0, 0, 0, 0.3);

      &:hover {
        background: rgba(0, 0, 0, 0.5);
      }
    }
  }

  // Gradient fade at edges - theme aware
  background: linear-gradient(
    to bottom,
    var(--mm-background-color, #fafafa) 0%,
    transparent 20%,
    transparent 80%,
    var(--mm-background-color, #fafafa) 100%
  );

  &.ampm-column {
    width: 60px;
    scrollbar-width: none;

    &::-webkit-scrollbar {
      display: none;
    }
  }

  // Selection indicator lines
  &::before,
  &::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    pointer-events: none;
    z-index: 1;
    background-color: rgba(0, 0, 0, 0.1);
  }

  &::before {
    top: calc(50% - 24px);
  }

  &::after {
    top: calc(50% + 24px);
  }
}

.digital-clock-item {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 300;
  scroll-snap-align: center;
  cursor: pointer;
  color: rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;

  &:hover:not(.padding):not(.disabled) {
    background-color: rgba(0, 0, 0, 0.05);
  }

  &.selected {
    color: var(--mm-primary-color, variables.$secondary-color);
    font-weight: 500;
    font-size: 2rem;
  }

  &.disabled {
    color: rgba(0, 0, 0, 0.15);
    cursor: not-allowed;
    pointer-events: none;
  }

  &.padding {
    pointer-events: none;
    cursor: default;
  }
}

.digital-clock-separator {
  font-size: 2rem;
  font-weight: 300;
  margin: 0 4px;
  color: rgba(0, 0, 0, 0.6);
}

/* Time Range Picker Styles */
.timerange-display-vertical {
  flex: 1 auto;
  background-color: variables.$secondary-color;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 200px;
}

.timerange-time-section {
  color: rgba(255, 255, 255, 0.6);

  &.active {
    color: rgba(255, 255, 255, 1);
  }
}

.timerange-label {
  font-size: 0.9rem;
  font-weight: 300;
  margin-bottom: 8px;
  opacity: 0.8;
}

.timerange-time {
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  min-width: 200px; // Prevent width changes when time updates
  display: flex;
  align-items: baseline;
}

.timerange-hours {
  display: inline-block;
  min-width: 2ch;
  text-align: right;
}

.timerange-minutes {
  display: inline-block;
  min-width: 2ch;
  text-align: left;
}

.timerange-ampm {
  font-size: 1.5rem;
  margin-left: 8px;
}

/* Media Queries */
@media #{variables.$medium-and-up} {
  .timepicker-modal {
    max-width: 600px;
  }

  .timepicker-container.modal-content {
    flex-direction: row;
  }

  .timepicker-text-container {
		top: 32%;
	}

	.timepicker-display-am-pm {
	  position: relative;
	  right: auto;
	  bottom: auto;
	  text-align: center;
	  margin-top: 1.2rem;
	}
}
