/* Car with Driver — page-specific styles (reuses rent-card layout) */

.cwd-card__desc {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted, #64748b);
}

.cwd-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.cwd-card__status {
  font-size: 0.8rem;
  font-weight: 600;
  color: #15803d;
}

.cwd-avail-status {
  margin: 0.75rem 0;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

.cwd-avail-status--ok {
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.cwd-avail-status--no {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.cwd-price-box {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  background: rgba(11, 27, 43, 0.04);
  border-radius: 10px;
}

.cwd-price-box p {
  margin: 0.25rem 0;
}

.cwd-options-row {
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.cwd-calendar {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.cwd-calendar__title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.cwd-calendar__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.cwd-cal-leg::before {
  content: "";
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.cwd-cal-leg--ok::before {
  background: #86efac;
}

.cwd-cal-leg--no::before {
  background: #fca5a5;
}

.cwd-cal-leg--sel::before {
  background: #0b1b2b;
}

.cwd-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}

.cwd-cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.25rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f1f5f9;
  font: inherit;
  cursor: pointer;
}

.cwd-cal-day--ok {
  background: #dcfce7;
  color: #166534;
}

.cwd-cal-day--no,
.cwd-cal-day--past {
  background: #fee2e2;
  color: #7f1d1d;
  opacity: 0.75;
  cursor: not-allowed;
}

.cwd-cal-day--sel {
  outline: 2px solid #0b1b2b;
  outline-offset: 1px;
}

.cwd-cal-day__num {
  font-weight: 600;
  font-size: 0.85rem;
}

.cwd-detail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.cwd-detail-gallery img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
}

/* Native <dialog> modals — must stay hidden when not [open]
   (author .rent-modal { display:flex } otherwise overrides UA closed state). */
dialog.cwd-modal {
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
}

dialog.cwd-modal:not([open]) {
  display: none !important;
  pointer-events: none;
}

dialog.cwd-modal[open] {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  overflow: hidden;
}

dialog.cwd-modal::backdrop {
  background: rgba(11, 27, 43, 0.62);
}

.cwd-modal__panel {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: min(440px, calc(100% - 32px));
  max-width: 100%;
  max-height: calc(100dvh - 32px);
  max-height: calc(100vh - 32px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.35rem 1.25rem 1.25rem;
  padding-top: 3rem;
  border-radius: 12px;
  background: var(--surface, #fff);
  color: var(--text, #0b1b2b);
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 24px 64px rgba(11, 27, 43, 0.28);
}

.cwd-modal__panel h2 {
  margin: 0 2.5rem 0.75rem 0;
  font-size: 1.2rem;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.cwd-modal__panel p {
  margin: 0 0 0.75rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.cwd-modal__close {
  position: absolute;
  top: max(0.35rem, env(safe-area-inset-top, 0px));
  right: max(0.35rem, env(safe-area-inset-right, 0px));
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(11, 27, 43, 0.08);
  color: var(--text, #0b1b2b);
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  white-space: nowrap;
  overflow: hidden;
}

.cwd-modal__close:hover,
.cwd-modal__close:focus-visible {
  background: rgba(11, 27, 43, 0.14);
  outline: 2px solid #0b1b2b;
  outline-offset: 2px;
}

.cwd-modal__close-icon {
  display: block;
  line-height: 1;
  pointer-events: none;
}

/* Dynamically mounted auth gate (created only when a protected action needs login) */
.cwd-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: rgba(11, 27, 43, 0.62);
  overflow: hidden;
}

.cwd-auth-dialog {
  position: relative;
  box-sizing: border-box;
  width: min(440px, calc(100% - 32px));
  max-width: 100%;
  max-height: calc(100dvh - 32px);
  max-height: calc(100vh - 32px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.35rem 1.25rem 1.25rem;
  padding-top: 3rem;
  border-radius: 12px;
  background: var(--surface, #fff);
  color: var(--text, #0b1b2b);
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 24px 64px rgba(11, 27, 43, 0.28);
}

.cwd-auth-dialog h2 {
  margin: 0 2.5rem 0.75rem 0;
  font-size: 1.2rem;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.cwd-auth-dialog p {
  margin: 0 0 0.75rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.cwd-auth-dialog__close {
  position: absolute;
  top: max(0.35rem, env(safe-area-inset-top, 0px));
  right: max(0.35rem, env(safe-area-inset-right, 0px));
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(11, 27, 43, 0.08);
  color: var(--text, #0b1b2b);
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  white-space: nowrap;
  overflow: hidden;
}

.cwd-auth-dialog__close:hover,
.cwd-auth-dialog__close:focus-visible {
  background: rgba(11, 27, 43, 0.14);
  outline: 2px solid #0b1b2b;
  outline-offset: 2px;
}

.cwd-auth-dialog__actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1rem;
}

.cwd-auth-dialog__actions .btn {
  width: 100%;
  justify-content: center;
  text-align: center;
  white-space: normal;
}

body.cwd-modal-open,
body.cwd-auth-open {
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 640px) {
  .cwd-calendar__grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.25rem;
  }

  .cwd-cal-day {
    min-height: 2.15rem;
    padding: 0.15rem;
  }

  .cwd-card__actions {
    flex-direction: column;
  }

  .cwd-card__actions .btn {
    width: 100%;
  }

  dialog.cwd-modal[open],
  .cwd-auth-overlay {
    align-items: flex-end;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }

  .cwd-modal__panel,
  .cwd-auth-dialog {
    width: calc(100% - 32px);
    max-height: calc(100dvh - 32px - env(safe-area-inset-bottom, 0px));
  }
}
