/* ==========================================================================
   Google Material Thai Buddhist DatePicker CSS
   A modern, executive-styled Material Date Picker for Thai Buddhist Era (พ.ศ.)
   ========================================================================== */

:root {
  --tmdp-primary: #1e3a8a;          /* Executive Navy / Royal Blue */
  --tmdp-primary-hover: #1d4ed8;
  --tmdp-primary-light: #eff6ff;
  --tmdp-header-bg: #1e293b;        /* Slate / Deep Charcoal Navy */
  --tmdp-header-text: #ffffff;
  --tmdp-header-sub: rgba(255, 255, 255, 0.75);
  --tmdp-surface: #ffffff;
  --tmdp-surface-card: #ffffff;
  --tmdp-text-main: #0f172a;
  --tmdp-text-muted: #64748b;
  --tmdp-text-disabled: #cbd5e1;
  --tmdp-border: #e2e8f0;
  --tmdp-radius: 18px;
  --tmdp-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.18), 0 10px 10px -5px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Modal Overlay (Mobile / Dialog mode) */
.tmdp-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.2s;
}

.tmdp-backdrop.tmdp-show {
  opacity: 1;
  visibility: visible;
}

/* DatePicker Container */
.tmdp-dialog {
  font-family: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  position: fixed;
  background: var(--tmdp-surface);
  border-radius: var(--tmdp-radius);
  box-shadow: var(--tmdp-shadow);
  width: 328px;
  max-width: calc(100vw - 32px);
  z-index: 99999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  user-select: none;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96) translateY(-6px);
  transition: opacity 0.2s cubic-bezier(0, 0, 0.2, 1), transform 0.2s cubic-bezier(0, 0, 0.2, 1);
}

.tmdp-dialog.tmdp-show {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

/* Centered Mobile Modal Style */
.tmdp-dialog.tmdp-mode-modal {
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -46%) scale(0.95);
}

.tmdp-dialog.tmdp-mode-modal.tmdp-show {
  transform: translate(-50%, -50%) scale(1);
}

/* Desktop Anchored Popover Style */
.tmdp-dialog.tmdp-mode-popover {
  position: absolute;
}

/* 1. Header (Material Display) */
.tmdp-header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: var(--tmdp-header-text);
  padding: 16px 20px 18px 20px;
  cursor: default;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tmdp-header-year-btn {
  background: transparent;
  border: none;
  color: var(--tmdp-header-sub);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  padding: 0;
  margin: 0;
  cursor: pointer;
  width: fit-content;
  transition: color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tmdp-header-year-btn:hover,
.tmdp-header-year-btn.tmdp-active {
  color: #93c5fd;
}

.tmdp-header-date-title {
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.25;
  color: #ffffff;
  letter-spacing: -0.01em;
}

/* 2. Main Calendar Content Area */
.tmdp-body {
  padding: 12px 14px 8px 14px;
  background: var(--tmdp-surface);
  position: relative;
  min-height: 290px;
  display: flex;
  flex-direction: column;
}

/* Month Navigation Bar */
.tmdp-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 2px;
}

.tmdp-nav-pills {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tmdp-nav-pill-btn {
  background: transparent;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--tmdp-text-main);
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.tmdp-nav-pill-btn:hover {
  background-color: #f1f5f9;
  color: var(--tmdp-primary);
  border-color: #e2e8f0;
}

.tmdp-nav-pill-btn.tmdp-active {
  background-color: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}

.tmdp-nav-pill-btn svg {
  width: 13px;
  height: 13px;
  transition: transform 0.2s ease;
}

.tmdp-nav-pill-btn.tmdp-active svg {
  transform: rotate(180deg);
}

.tmdp-nav-arrows {
  display: flex;
  gap: 2px;
}

.tmdp-nav-btn {
  background: transparent;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--tmdp-text-muted);
  transition: all 0.15s ease;
}

.tmdp-nav-btn:hover {
  background-color: #f1f5f9;
  color: var(--tmdp-text-main);
}

.tmdp-nav-btn svg {
  width: 18px;
  height: 18px;
}

/* Weekday Grid */
.tmdp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
}

.tmdp-weekday {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tmdp-text-muted);
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Days Grid */
.tmdp-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 2px;
  margin-bottom: 4px;
}

.tmdp-day {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--tmdp-text-main);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0 auto;
  width: 38px;
}

.tmdp-day:hover:not(.tmdp-disabled):not(.tmdp-selected) {
  background-color: #f1f5f9;
  color: var(--tmdp-primary);
}

.tmdp-day.tmdp-today:not(.tmdp-selected) {
  border: 1.5px solid #2563eb;
  font-weight: 600;
  color: #2563eb;
}

.tmdp-day.tmdp-selected {
  background-color: #2563eb !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.tmdp-day.tmdp-other-month {
  color: var(--tmdp-text-disabled);
  opacity: 0.6;
}

.tmdp-day.tmdp-disabled {
  color: var(--tmdp-text-disabled);
  cursor: not-allowed;
  opacity: 0.35;
}

/* 3. Month Grid View (Overlay) */
.tmdp-month-view {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  bottom: 8px;
  background: var(--tmdp-surface);
  z-index: 10;
  display: none;
  flex-direction: column;
}

.tmdp-month-view.tmdp-active {
  display: flex;
}

.tmdp-month-list {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 8px;
  padding: 12px 4px;
  align-content: center;
}

.tmdp-month-item {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--tmdp-text-main);
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid #f1f5f9;
  background: #f8fafc;
  transition: all 0.15s ease;
}

.tmdp-month-item:hover {
  background-color: #eff6ff;
  color: var(--tmdp-primary);
  border-color: #bfdbfe;
}

.tmdp-month-item.tmdp-selected {
  background-color: #2563eb;
  color: #ffffff;
  font-weight: 600;
  border-color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* 4. Year Grid View (Scrollable Overlay) */
.tmdp-year-view {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  bottom: 8px;
  background: var(--tmdp-surface);
  z-index: 10;
  display: none;
  flex-direction: column;
}

.tmdp-year-view.tmdp-active {
  display: flex;
}

.tmdp-year-list {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 4px;
  max-height: 270px;
}

/* Custom Scrollbar for Year List */
.tmdp-year-list::-webkit-scrollbar {
  width: 5px;
}
.tmdp-year-list::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

.tmdp-year-item {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--tmdp-text-main);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tmdp-year-item:hover {
  background-color: #f1f5f9;
  color: var(--tmdp-primary);
}

.tmdp-year-item.tmdp-selected {
  background-color: #2563eb;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* 4. Footer Actions */
.tmdp-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 14px 16px;
  background: var(--tmdp-surface);
  border-top: 1px solid var(--tmdp-border);
}

.tmdp-btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.tmdp-btn-cancel {
  background: transparent;
  color: #64748b;
}

.tmdp-btn-cancel:hover {
  background-color: #f1f5f9;
  color: #334155;
}

.tmdp-btn-confirm {
  background-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.tmdp-btn-confirm:hover {
  background-color: #1d4ed8;
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* Date input styling helper */
.th-datepicker-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%232563eb' stroke-width='1.8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5m-9-6h.008v.008H12v-.008zM12 15h.008v.008H12V15zm0 2.25h.008v.008H12v-.008zM9.75 15h.008v.008H9.75V15zm0 2.25h.008v.008H9.75v-.008zM7.5 15h.008v.008H7.5V15zm0 2.25h.008v.008H7.5v-.008zm6.75-4.5h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V15zm0 2.25h.008v.008h-.008v-.008zm2.25-4.5h.008v.008H16.5v-.008zm0 2.25h.008v.008H16.5V15z' /%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 20px 20px !important;
  cursor: pointer;
}
