/* Modal */
.datepicker-modal {
  max-width: 325px;
  min-width: 300px;
  max-height: none;
  overflow: visible;
}

.datepicker-container.modal-content {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: visible;
  background-color: var(--mm-surface-color, #ffffff);
  color: var(--mm-text-primary, rgba(0, 0, 0, 0.87));
}

.datepicker-controls {
  display: flex;
  justify-content: space-between;
  width: 280px;
  margin: 0 auto;
  overflow: visible;

  .selects-container {
    display: flex;
    overflow: visible;
  }

  .select-wrapper {
    position: relative;
    overflow: visible;

    input {
      &:focus {
        border-bottom: none;
      }
      border-bottom: none;
      text-align: center;
      margin: 0;
      cursor: pointer;
    }

    .caret {
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      cursor: pointer;
      width: 16px;
      height: 16px;
      fill: var(--mm-text-secondary, rgba(0, 0, 0, 0.54));
    }

    .dropdown-content {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      background-color: var(--mm-surface-color, white);
      box-shadow: 0 4px 20px var(--mm-shadow-color, rgba(0, 0, 0, 0.3));
      z-index: 20000;
      border: 1px solid var(--mm-border-color, #ddd);
      border-radius: 2px;
      display: block;
      opacity: 1;

      .dropdown-item {
        padding: 8px 16px;
        cursor: pointer;
        white-space: nowrap;
        transition: background-color 0.2s;

        &:hover {
          background-color: var(--mm-border-color, #f5f5f5);
        }

        &.selected {
          background-color: var(--mm-border-color, #f5f5f5);
        }
      }
    }
  }

  .select-year {
    input {
      width: 50px;
    }

    .dropdown-content {
      max-height: 60vh;
      overflow-y: auto;
    }
  }

  .select-month {
    input {
      width: 80px;
    }

    .dropdown-content {
      width: auto;
      min-width: 120px;
      left: auto;
      right: 0;
    }
  }
}

.month-prev, .month-next {
  margin-top: 4px;
  cursor: pointer;
  background-color: transparent;
  border: none;
}


/* Date Display */
.datepicker-date-display {
  flex: 1 auto;
  background-color: #26a69a;
  color: #fff;
  padding: 20px 22px;
  font-weight: 500;

  .year-text {
    display: block;
    font-size: 1.5rem;
    line-height: 25px;
    color: rgba(255, 255, 255, 0.7);
  }

  .date-text {
    display: block;
    font-size: 2.8rem;
    line-height: 47px;
    font-weight: 500;

    &.placeholder {
      font-size: 1.8rem;
      line-height: 30px;
      color: rgba(255, 255, 255, 0.7);
      font-weight: 400;
    }

    .range-separator {
      color: rgba(255, 255, 255, 0.8);
      font-size: 1.5rem;
      font-weight: 400;
    }

    .end-date.placeholder {
      color: rgba(255, 255, 255, 0.5);
      font-style: italic;
      font-size: 1.2rem;
      font-weight: 300;
    }
  }

  &.range-display {
    .date-text {
      font-size: 1.6rem;
      line-height: 28px;
      
      .start-date, .end-date {
        display: inline-block;
      }
    }
  }
}


/* Calendar */
.datepicker-calendar-container {
  flex: 2.5 auto;
}

.datepicker-table {
  width: 280px;
  font-size: 1rem;
  margin: 0 auto;
  
  &.with-week-numbers {
    width: 310px;
  }

  thead {
    border-bottom: none;
  }

  th {
    padding: 10px 5px;
    text-align: center;
    
    &.datepicker-week-header {
      color: var(--mm-text-hint, rgba(0, 0, 0, 0.38));
      font-size: 0.8rem;
      font-weight: 600;
      width: 30px;
      padding: 10px 2px;
    }
  }

  tr {
    border: none;
  }

  abbr {
    text-decoration: none;
    color: var(--mm-text-secondary, rgba(0, 0, 0, 0.54));
  }

  td {
    &.is-today {
      color: var(--mm-primary-color, #26a69a);
    }

    &.is-selected {
      background-color: var(--mm-primary-color, #26a69a);
      color: var(--mm-button-text, #fff);
    }

    // Range selection states
    &.is-range-start {
      background-color: var(--mm-primary-color, #26a69a);
      color: var(--mm-button-text, #fff);
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
    }

    &.is-range-end {
      background-color: var(--mm-primary-color, #26a69a);
      color: var(--mm-button-text, #fff);
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }

    &.is-in-range {
      background-color: var(--mm-primary-color-alpha-20, rgba(38, 166, 154, 0.2));
      color: var(--mm-text-primary, rgba(0, 0, 0, 0.87));
      border-radius: 0;
    }

    &.is-range-preview {
      background-color: var(--mm-primary-color-alpha-10, rgba(38, 166, 154, 0.1));
      color: var(--mm-text-primary, rgba(0, 0, 0, 0.87));
    }

    &.is-outside-current-month,
    &.is-disabled {
      color: var(--mm-text-disabled, rgba(0, 0, 0, 0.3));
      pointer-events: none;
    }

    &.datepicker-week-number {
      color: var(--mm-text-hint, rgba(0, 0, 0, 0.38));
      font-size: 0.8rem;
      font-weight: 600;
      text-align: center;
      vertical-align: middle;
      border-radius: 0;
      width: 30px;
      padding: 5px 2px;
      background-color: var(--mm-border-color, rgba(0, 0, 0, 0.02));
      border-right: 1px solid var(--mm-border-color, rgba(0, 0, 0, 0.05));
    }

    border-radius: 50%;
    padding: 0;
  }
}

.datepicker-day-button {
  // &:focus {
  //   background-color: #eee;
  // }

  background-color: transparent;
  border: none;
  line-height: 38px;
  display: block;
  width: 100%;
  border-radius: 50%;
  padding: 0 5px;
  cursor: pointer;
  color: inherit;
}


/* Footer */
.datepicker-footer {
  width: 280px;
  margin: 0 auto;
  padding-bottom: 5px;
  display: flex;
  justify-content: space-between;
}

.datepicker-cancel,
.datepicker-clear,
.datepicker-today,
.datepicker-done {
  color: #26a69a;
  padding: 0 1rem;
}

.datepicker-clear {
  color: #f44336;
}


/* Media Queries */
@media only screen and (min-width: 601px) {
  .datepicker-modal {
    max-width: 625px;
  }

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

  .datepicker-date-display {
    flex: 0 1 270px;
  }

  .datepicker-controls,
  .datepicker-table,
  .datepicker-footer {
    width: 320px;
  }
  
  .datepicker-table.with-week-numbers {
    width: 350px;
  }

  .datepicker-day-button {
    line-height: 44px;
  }
}
