/* Persian / Jalali Date Picker Component Styles
   Supports Desktop (Dropdown / Floating) & Mobile (Bottom-sheet modal).
   Seamlessly adapts to Light and Dark modes using theme variables.
*/

.date-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.date-input-wrap input.date-input-field {
  width: 100%;
  padding-inline-start: 12px;
  padding-inline-end: 40px;
  font-family: var(--font);
  direction: ltr;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 38px;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.date-input-wrap input.date-input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.date-input-wrap input.date-input-field:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--surface, var(--page));
}

.date-input-btn {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 6px;
  min-height: auto;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.date-input-btn:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-wash);
}

.date-input-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.date-input-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ================= Mobile Backdrop ================= */
.dp-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 100000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: dpFadeIn 0.2s ease-out;
}

@keyframes dpFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ================= Date Picker Popup ================= */
.date-picker-popup {
  position: fixed;
  z-index: 100000;
  width: 300px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
  direction: rtl;
  user-select: none;
  font-family: var(--font);
  animation: dpScaleIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

@keyframes dpScaleIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 12px;
}

.dp-nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dp-nav-btn:hover {
  background: var(--accent-wash);
  color: var(--accent);
  border-color: var(--border);
}

.dp-nav-btn svg {
  width: 16px;
  height: 16px;
}

.dp-selectors {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.dp-selectors select {
  font-size: 13.5px;
  font-weight: 600;
  padding: 4px 8px;
  min-height: 32px;
  border-radius: 8px;
  background: var(--surface, var(--card));
  color: var(--ink);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font);
}

.dp-selectors select:hover {
  border-color: var(--accent);
}

/* Weekday column headers */
.dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 6px;
}

.dp-weekday {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 0;
}

.dp-weekday.is-holiday {
  color: var(--bad);
}

/* Day cells grid */
.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.dp-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: all 0.12s ease;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}

.dp-cell:hover:not(.is-empty):not(.is-selected) {
  background: var(--accent-wash);
  color: var(--accent);
  font-weight: 600;
}

.dp-cell.is-empty {
  cursor: default;
  pointer-events: none;
}

.dp-cell.is-holiday {
  color: var(--bad);
}

.dp-cell.is-today {
  border-color: var(--accent);
  font-weight: 700;
}

.dp-cell.is-today::after {
  content: "";
  position: absolute;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.dp-cell.is-selected {
  background: var(--accent) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 3px 8px rgba(42, 120, 214, 0.35);
}

.dp-cell.is-selected::after {
  background: #ffffff;
}

/* Footer / Quick Shortcuts */
.dp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.dp-quick-btn {
  font-size: 12px;
  padding: 4px 10px;
  min-height: 28px;
  border-radius: 6px;
  background: var(--accent-wash);
  color: var(--accent);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: var(--font);
}

.dp-quick-btn:hover {
  background: var(--accent);
  color: #ffffff;
}

.dp-clear-btn {
  font-size: 12px;
  padding: 4px 8px;
  min-height: 28px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  border: none;
  cursor: pointer;
  font-family: var(--font);
}

.dp-clear-btn:hover {
  color: var(--bad);
  background: rgba(180, 35, 24, 0.08);
}

/* ================= Mobile Responsiveness (Bottom Sheet) ================= */
@media (max-width: 560px) {
  .date-picker-popup {
    position: relative;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100%;
    max-width: 420px;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
    padding: 20px 18px 24px;
    border-bottom: none;
    animation: dpSlideUp 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes dpSlideUp {
    from {
      transform: translateY(100%);
      opacity: 0.5;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .dp-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    margin: -8px auto 16px;
  }

  .dp-cell {
    font-size: 15px;
    border-radius: 12px;
  }

  .dp-selectors select {
    font-size: 14.5px;
    padding: 6px 10px;
    min-height: 36px;
  }

  .dp-nav-btn {
    width: 36px;
    height: 36px;
    min-height: 36px;
  }
}
