/* ===========================
   Plant Detail Dialog
   =========================== */

dialog#plant-dialog {
  max-width: 36rem;
  width: min(36rem, 95vw);
  max-height: 90vh;
  overflow: hidden;
  border: none;
  border-radius: var(--radius, 0.5rem);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  padding: 0;
  margin: auto;
}

dialog#plant-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.dialog__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  padding: 1rem 1rem 0.75rem;
  background: var(--color-bg, #fff);
  border-bottom: 1px solid var(--color-border, #e0e0e0);
}

.dialog__close {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: var(--radius, 0.5rem);
  background: transparent;
  color: var(--color-text, #333);
  padding: 0;
  order: -1; /* Visually first (also first in DOM = first tab stop) */
}

.dialog__close:hover {
  background: var(--color-month-bg, #f0f0f0);
}

.dialog__close:focus-visible {
  outline: 3px solid #4a90d9;
  outline-offset: 2px;
}

.dialog__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog__body {
  padding: 1rem;
  overflow-y: auto;
  max-height: calc(90vh - 5rem);
  overscroll-behavior: contain;
}

.dialog__details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
}

.dialog__details dt {
  font-weight: 600;
  font-size: 0.82rem;
  color: #666;
  padding-top: 0.5rem;
  white-space: nowrap;
}

.dialog__details dt:first-child {
  padding-top: 0;
}

.dialog__details dd {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text, #333);
  padding-top: 0.5rem;
  word-break: break-word;
  overflow-wrap: break-word;
}

.dialog__details dd:first-of-type {
  padding-top: 0;
}

/* ===========================
   Complementary Plant Dialog
   (reuses all .dialog__* rules above; only dialog-id-specific overrides here)
   =========================== */
dialog#companion-dialog {
  max-width: 32rem;
  width: min(32rem, 95vw);
  max-height: 90vh;
  overflow: hidden;
  border: none;
  border-radius: var(--radius, 0.5rem);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  padding: 0;
  margin: auto;
}

dialog#companion-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

/* Companion links inside dialogs */
.dialog__details .companion-link {
  color: #1a5c2e;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: inherit;
}

.dialog__details .companion-link:hover {
  color: #0d3a1a;
}

.dialog__details .companion-link:focus-visible {
  outline: 3px solid #4a90d9;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ===========================
   Responsive — small screens
   =========================== */
@media (max-width: 480px) {
  dialog#companion-dialog {
    max-height: 80vh;
    margin: auto 0 0;
    border-radius: var(--radius, 0.5rem) var(--radius, 0.5rem) 0 0;
    width: 100%;
    max-width: 100%;
  }

  dialog#plant-dialog {
    max-height: 80vh;
    margin: auto 0 0; /* slide up from bottom on mobile */
    border-radius: var(--radius, 0.5rem) var(--radius, 0.5rem) 0 0;
    width: 100%;
    max-width: 100%;
  }

  .dialog__body {
    max-height: calc(80vh - 5rem);
  }

  .dialog__close {
    min-width: 48px;
    min-height: 48px;
    font-size: 1.5rem;
  }
}
