/* MR Türkçe date picker — ITER 291 (BS-paralel)
   ─────────────────────────────────────────────────────────────────
   Mobile-friendly date picker with TR locale.

   Markup:
     <div class="bs-datepicker">
       <input type="text" class="bs-datepicker-input" inputmode="numeric"
              placeholder="GG.AA.YYYY" data-format="date">
       <div class="bs-datepicker-popup" hidden>
         <div class="bs-datepicker-header">
           <button class="bs-datepicker-prev" aria-label="Önceki ay">‹</button>
           <span class="bs-datepicker-title">Ocak 2026</span>
           <button class="bs-datepicker-next" aria-label="Sonraki ay">›</button>
         </div>
         <div class="bs-datepicker-weekdays">
           <span>Pt</span><span>Sa</span><span>Ça</span><span>Pe</span>
           <span>Cu</span><span>Ct</span><span>Pz</span>
         </div>
         <div class="bs-datepicker-days"></div>
       </div>
     </div>

   Tokens read from CSS:
     --bs-dp-cell: 36px
     --bs-dp-fs: 13px
     --bs-dp-bg: rgba(20, 24, 32, 0.98)
     --bs-dp-active: var(--theme-accent, #d4af37)
*/

:root {
  --bs-dp-cell: 36px;
  --bs-dp-fs: 13px;
  --bs-dp-bg: rgba(20, 24, 32, 0.98);
  --bs-dp-border: rgba(255, 255, 255, 0.12);
  --bs-dp-text: var(--theme-text-primary, #fff);
  --bs-dp-muted: rgba(255, 255, 255, 0.45);
  --bs-dp-active: var(--theme-accent, #d4af37);
  --bs-dp-hover: rgba(212, 175, 55, 0.16);
  --bs-dp-radius: 10px;
}

.bs-datepicker {
  position: relative;
  display: inline-block;
}

.bs-datepicker-input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--bs-dp-border);
  border-radius: 8px;
  color: var(--bs-dp-text);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d4af37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='18' rx='2'/><line x1='16' y1='2' x2='16' y2='6'/><line x1='8' y1='2' x2='8' y2='6'/><line x1='3' y1='10' x2='21' y2='10'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px 18px;
  transition: border-color 180ms ease, background-color 180ms ease;
}
.bs-datepicker-input:focus-visible {
  border-color: rgba(212, 175, 55, 0.5);
  background-color: rgba(212, 175, 55, 0.04);
}

.bs-datepicker-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--bs-dp-bg);
  border: 1px solid var(--bs-dp-border);
  border-radius: var(--bs-dp-radius);
  padding: 12px;
  width: calc(var(--bs-dp-cell) * 7 + 24px);
  z-index: 9999;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  /* Animation */
  opacity: 0;
  transform: translate3d(0, -6px, 0) scale(0.97);
  transform-origin: top left;
  transition:
    opacity 180ms ease,
    transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.bs-datepicker-popup[hidden] {
  display: none;
}
.bs-datepicker.is-open .bs-datepicker-popup {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  pointer-events: auto;
}

/* Header (month nav) */
.bs-datepicker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 4px;
}
.bs-datepicker-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--bs-dp-text);
  user-select: none;
}
.bs-datepicker-prev,
.bs-datepicker-next {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--bs-dp-text);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 160ms ease, color 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.bs-datepicker-prev:hover,
.bs-datepicker-next:hover,
.bs-datepicker-prev:focus-visible,
.bs-datepicker-next:focus-visible {
  background: var(--bs-dp-hover);
  outline: none;
}

/* Weekday labels */
.bs-datepicker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, var(--bs-dp-cell));
  gap: 0;
  margin-bottom: 4px;
}
.bs-datepicker-weekdays > span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--bs-dp-muted);
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Day grid */
.bs-datepicker-days {
  display: grid;
  grid-template-columns: repeat(7, var(--bs-dp-cell));
  gap: 0;
}

.bs-datepicker-day {
  width: var(--bs-dp-cell);
  height: var(--bs-dp-cell);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--bs-dp-fs);
  font-weight: 500;
  color: var(--bs-dp-text);
  cursor: pointer;
  border-radius: 8px;
  background: transparent;
  border: 0;
  transition: background-color 160ms ease, color 160ms ease, transform 100ms ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.bs-datepicker-day:hover,
.bs-datepicker-day:focus-visible {
  background: var(--bs-dp-hover);
  outline: none;
}
.bs-datepicker-day.is-other-month {
  color: var(--bs-dp-muted);
  opacity: 0.5;
}
.bs-datepicker-day.is-today {
  font-weight: 700;
  color: var(--bs-dp-active);
}
.bs-datepicker-day.is-today::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--bs-dp-active);
  margin-top: 22px;
}
.bs-datepicker-day.is-selected {
  background: var(--bs-dp-active);
  color: #18120a;
  font-weight: 700;
}
.bs-datepicker-day.is-selected:hover {
  background: var(--bs-dp-active);
}
.bs-datepicker-day.is-disabled {
  color: var(--bs-dp-muted);
  opacity: 0.3;
  cursor: not-allowed;
}
.bs-datepicker-day.is-in-range {
  background: rgba(212, 175, 55, 0.18);
  border-radius: 0;
}
.bs-datepicker-day.is-range-start {
  border-radius: 8px 0 0 8px;
}
.bs-datepicker-day.is-range-end {
  border-radius: 0 8px 8px 0;
}

/* Footer (today + clear buttons) */
.bs-datepicker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--bs-dp-border);
}
.bs-datepicker-today,
.bs-datepicker-clear {
  background: transparent;
  border: 0;
  color: var(--bs-dp-active);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background-color 160ms ease;
}
.bs-datepicker-today:hover,
.bs-datepicker-clear:hover {
  background: var(--bs-dp-hover);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .bs-datepicker-popup,
  .bs-datepicker-day,
  .bs-datepicker-prev,
  .bs-datepicker-next {
    transition: none !important;
  }
}

/* Mobile — full-width popup, bottom-sheet */
@media (max-width: 480px) {
  .bs-datepicker-popup {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    top: auto;
    width: auto;
    --bs-dp-cell: 40px;
    transform: translate3d(0, 100%, 0);
  }
  .bs-datepicker.is-open .bs-datepicker-popup {
    transform: translate3d(0, 0, 0);
  }
}
