.cdp-container {
  position: relative;
  display: inline-block;
  width: 100%;
  font-family: inherit;
  box-sizing: border-box;
}

.cdp-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  background: var(--background-main);
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  min-height: 36px;
  transition: border-color 0.15s;
}

.cdp-display:hover {
  border-color: var(--primary-color);
}

.cdp-display:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

html.dark-theme .cdp-display {
  background: var(--background-main-dark-mode);
  border: none;
  color: var(--text-primary);
}

.cdp-display--placeholder .cdp-display-text {
  color: var(--text-secondary);
}

.cdp-display-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cdp-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

html.dark-theme .cdp-icon {
  filter: invert(70%) sepia(10%) saturate(300%) hue-rotate(185deg)
    brightness(95%);
}

/* ── Popup ── */
.cdp-popup {
  position: absolute;
  top: 100%;
  margin-top: 13px;
  left: 0;
  z-index: 1060;
  min-width: 260px;
  background: var(--background-color-main-light);
  border: 1px solid var(--border-light-mode);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  padding: 10px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    opacity 0.15s,
    transform 0.15s;
}

.cdp-container.cdp-open .cdp-popup {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  left: -14px;
}

html.dark-theme .cdp-popup {
  background: var(--background-main-dark-mode);
  border: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

html.dark-theme .cdp-nav {
  color: var(--text-primary);
}

html.dark-theme .cdp-day {
  color: var(--text-primary);
}

html.dark-theme .cdp-month,
html.dark-theme .cdp-year {
  color: var(--text-primary);
}

/* ── Header (mês + navegação) ── */
.cdp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.cdp-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition:
    background 0.15s,
    color 0.15s;
}

.cdp-nav:hover {
  background: var(--background-color-main);
  color: var(--primary-color);
}

.cdp-month-year {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.cdp-month-year:hover {
  background: var(--background-color-main);
}

/* ── Grid de semanas ── */
.cdp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.cdp-weekday {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  padding: 4px 0;
}

.cdp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cdp-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.cdp-day:hover:not(:disabled) {
  background: var(--background-color-main);
}

.cdp-day--outside {
  color: var(--text-secondary);
  opacity: 0.4;
}

.cdp-day--today {
  font-weight: 700;
  border: 2px solid var(--primary-color);
  background-color: color-mix(in srgb, var(--primary-color) 15%, transparent);
  border-radius: 50% 0 50% 50%;
  transform: scale(0.95);
}

.cdp-day--today:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--primary-color) 22%, transparent);
}

.cdp-day--selected,
.cdp-day--selected:hover {
  background: var(--primary-color);
  color: #fff;
  border-radius: 6px;
  border: none;
}

.cdp-day:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Grid de meses/anos (quando clica no título) ── */
.cdp-months,
.cdp-years {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px 0;
}

.cdp-month,
.cdp-year {
  padding: 10px 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.cdp-month:hover,
.cdp-year:hover {
  background: var(--background-color-main);
}

.cdp-month--selected,
.cdp-year--selected {
  background: var(--primary-color);
  color: #fff;
}

/* ── Footer ── */
.cdp-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light-mode);
}

html.dark-theme .cdp-footer {
  border-top: 1px solid var(--border-dark-mode);
}

.cdp-footer-btn {
  background: transparent;
  border: none;
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.cdp-footer-btn:hover {
  background: var(--background-color-main);
}
