/*
 * Project:        Trans-Allegheny Lunatic Asylum Information Systems (TIS)
 *
 * Copyright (c) 2010-present
 * Joseph Daniel DiFerio
 * All rights reserved.
 *
 * OWNERSHIP NOTICE
 * This source code, including all associated intellectual property, design,
 * architecture, and derivative works, is the exclusive property of
 * Joseph Daniel DiFerio (the "Author"). No ownership or authorship is
 * transferred by possession, use, or access to this source code.
 *
 * LICENSE NOTICE
 * Use, modification, and operation of this software are permitted only as
 * expressly authorized by the LICENSE.txt included with this project.
 * If the LICENSE.txt is missing or unavailable, you are not authorized to use,
 * copy, modify, or distribute this software.
 *
 * DATA & INFRASTRUCTURE OWNERSHIP
 * All data stored, processed, or generated by this software, and all hardware
 * and infrastructure on which it operates, are and shall remain the exclusive
 * property of Trans-Allegheny Lunatic Asylum (TALA). Ownership of data or
 * infrastructure does not imply ownership of this software.
 *
 * NO WORK-FOR-HIRE / INDEPENDENT AUTHOR
 * This software was not created as a work-for-hire. The Author is not an
 * employee, contractor, or agent of Trans-Allegheny Lunatic Asylum (TALA)
 * with respect to the creation of this software.
 *
 * RESTRICTIONS (SUMMARY)
 * No sublicensing, redistribution, publication, or transfer of successor
 * development rights is granted except as expressly permitted by LICENSE.txt.
 *
 * DO NOT REMOVE OR ALTER THIS NOTICE.
 */

/*
 * Date Selector UI styles
 * Aligned to TIS palette and button/input conventions.
 */

.tisDateSelector-form,
.tisDateSelector-container {
  display: flex;
  flex-direction: column;
}

.tisDateSelector-container {
  margin: 4px 0;
}

.tisDateSelector-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tisDateSelector-label {
  margin: 4px 0 0 0;
  color: #1a446c;
  font-size: 12px;
}

.tisDatePicker-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.tisDateSelector-input {
  margin-top: 4px;
  min-height: 38px;
  box-sizing: border-box;
  border: 1px solid #7b8fa8;
  border-radius: 6px;
  background: transparent;
  color: #1a446c;
  padding: 7px 11px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.35px;
  width: 9.25em;
  max-width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.tisDateSelector-input:focus {
  outline: none;
  border-color: #1c60b1;
  background: rgba(212, 230, 244, 0.25);
  box-shadow:
    0 0 0 3px rgba(28, 96, 177, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.tisDateSelector-input.is-dirty {
  border-color: #c8b892;
  background: #eee4b9;
  color: #1a446c;
  box-shadow:
    0 0 0 3px rgba(200, 184, 146, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.tisDatePicker-toggle {
  min-height: 34px;
  padding: 6px 10px;
  background: #c5d2e2;
  color: #1c60b1;
  border: 1px solid #7b8fa8;
  border-radius: 8px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

.tisDatePicker-toggle:hover {
  background: #1a446c;
  color: #d4e6f4;
}

.tisDatePicker-popup {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3000;
  width: 360px;
  max-width: calc(100vw - 24px);
  background: #f8f3e5;
  border: 1px solid #1a446c;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  padding: 8px;
  box-sizing: border-box;
}

.tisDatePicker-popup.has-presets {
  width: 470px;
  max-width: calc(100vw - 24px);
}

.tisDatePicker-popup.has-weeknumbers {
  width: 420px;
}

.tisDatePicker-popup.has-presets.has-weeknumbers {
  width: 530px;
}

.tisDatePicker-popup.is-compact {
  width: 250px;
  max-width: min(250px, calc(100vw - 24px));
}

.tisDatePicker-body {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.tisDatePicker-main {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.tisDatePicker-presets {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 108px;
}

.tisDatePicker-preset {
  width: 100%;
  min-height: 28px;
  padding: 6px 8px;
  border: 1px solid #7b8fa8;
  background: #c5d2e2;
  color: #1c60b1;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: bold;
  text-align: left;
}

.tisDatePicker-preset:hover {
  background: #1a446c;
  color: #d4e6f4;
}

.tisDatePicker-preset.is-disabled,
.tisDatePicker-preset:disabled {
  background: #efefef;
  color: #9a9a9a;
  border-color: #d2d2d2;
  cursor: not-allowed;
}

.tisDatePicker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.tisDatePicker-title {
  font-weight: bold;
  color: #1a446c;
  font-size: 13px;
}

.tisDatePicker-titleText {
  display: inline-block;
  min-width: 3ch;
  margin: 0 3px;
  vertical-align: middle;
}

.tisDatePicker-nav {
  width: 28px;
  height: 28px;
  border: 1px solid #7b8fa8;
  background: #c5d2e2;
  color: #1c60b1;
  border-radius: 6px;
  cursor: pointer;
}

.tisDatePicker-nav:hover {
  background: #1a446c;
  color: #d4e6f4;
}

.tisDateSelector-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
}

.tisDateSelector-action-spacer {
  display: block;
  flex: 1 1 auto;
  min-width: 20px;
}

.tisDatePicker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: 100%;
  color: #1a446c;
  font-size: 11px;
  margin-bottom: 6px;
  text-align: center;
  letter-spacing: 0.2px;
}

.tisDatePicker-popup.has-weeknumbers .tisDatePicker-weekdays,
.tisDatePicker-popup.has-weeknumbers .tisDatePicker-grid {
  grid-template-columns: 32px repeat(7, 1fr);
}

.tisDatePicker-weeknum-head,
.tisDatePicker-weeknum-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: #8d0d19;
  font-size: 12px;
  font-weight: 700;
}

.tisDatePicker-weekday {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.tisDatePicker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: 100%;
}

.tisDatePicker-empty {
  height: 28px;
  min-width: 0;
  box-sizing: border-box;
}

.tisDatePicker-day {
  width: 100%;
  height: 28px;
  box-sizing: border-box;
  min-width: 0;
  padding: 0;
  border: 1px solid #b9a87d;
  border-radius: 6px;
  background: #fffdf7;
  color: #1a446c;
  font-size: 12px;
  cursor: pointer;
}

.tisDatePicker-day:hover {
  background: #d4e6f4;
  border-color: #1c60b1;
}

.tisDatePicker-day.is-selected {
  background: #1a446c;
  border-color: #1a446c;
  color: #d4e6f4;
}

.tisDatePicker-day.is-disabled,
.tisDatePicker-day:disabled {
  background: #efefef;
  color: #9a9a9a;
  border-color: #d2d2d2;
  cursor: not-allowed;
}

.tisDateSelector-quick-btn {
  min-width: 84px;
  min-height: 28px;
  padding: 6px 10px;
  font-size: 11px;
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  .tisDateSelector-form,
  .tisDateSelector-container,
  .tisDateSelector-range-row,
  .tisDatePicker-wrap {
    width: 100%;
  }

  .tisDateSelector-range-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .tisDateSelector-label {
    margin-top: 6px;
  }

  .tisDateSelector-input {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 16px;
  }

  .tisDatePicker-popup {
    width: 100%;
    max-width: min(28rem, calc(100vw - 24px));
  }

  .tisDatePicker-popup.is-compact {
    width: 100%;
    max-width: min(28rem, calc(100vw - 24px));
  }

  .tisDateSelector-actions {
    justify-content: space-between;
  }

  .tisDateSelector-action-spacer {
    display: block;
    flex: 1 1 auto;
  }

  .tisDateSelector-quick-btn {
    flex: 1 1 0;
    min-width: 0;
    width: 100%;
  }

  .tisDatePicker-body {
    flex-direction: column;
  }

  .tisDatePicker-presets {
    min-width: 0;
    width: 100%;
  }

  .tisDatePicker-preset {
    min-height: 36px;
    font-size: 12px;
    text-align: center;
  }

  .tisDatePicker-nav,
  .tisDatePicker-day {
    min-width: 36px;
    height: 36px;
  }

  .tisDatePicker-select {
    min-height: 36px;
    font-size: 14px;
  }

  .tisDateSelector-quick-btn {
    min-height: 36px;
    font-size: 12px;
  }
}
