/**
 * Zimaro Offer Popup
 * Modül baz alınarak entegre edildi.
 */

:root {
  --rental-primary: #0f8c41;
  --rental-primary-hover: #16b254;
  --rental-text-color: #ffffff;
  --rental-border-color: rgba(255, 255, 255, 0.1);
}

.rental-form-overlay,
.rental-form-overlay * {
  box-sizing: border-box;
}

.rental-form-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.rental-form-overlay.active {
  opacity: 1;
  visibility: visible;
}

.rental-form-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  max-width: 1280px;
  width: 90%;
  max-height: 85vh;
  background: #0f1b25;
  border-radius: 20px;
  overflow: visible; /* close button sits outside */
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  position: relative;
}

.rental-form-overlay.active .rental-form-modal {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.rental-form-close {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #6c727d;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1003;
  transition: background 0.25s ease, transform 0.25s ease;
  padding: 0;
  color: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.rental-form-close:hover {
  background: var(--rental-primary);
  transform: translateX(-50%) translateY(-50%) rotate(-180deg);
}

.rental-form-close svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
}

.rental-form-trigger {
  position: fixed;
  /* bk-tools ile aynı bottom matematiği (scroll-to-top çakışmasın) */
  bottom: calc(32px + 56px + 20px + env(safe-area-inset-bottom, 0px));
  left: 20px;
  width: 64px;
  height: 64px;
  background: #0f8c41;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px #16b2544d;
  transition: bottom 0.3s ease, all 0.3s ease;
  color: white;
}

.rental-form-trigger:hover {
  transform: scale(1.05);
}

.rental-form-trigger svg {
  width: 32px;
  height: 32px;
  stroke: currentColor;
  fill: none;
}

.rental-form-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ffffff;
  color: var(--rental-primary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.rental-form-trigger .rental-form-tooltip {
  position: absolute;
  background: linear-gradient(135deg, #0f8c41, #16b254);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1;
  padding: 10px 15px;
  border-radius: 20px;
  top: 50%;
  transform: translateY(-50%);
  left: calc(100% + 10px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.rental-form-trigger:hover .rental-form-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(15px);
}

.rental-form-list-wrapper {
  background: #0f8c41;
  padding: 60px 40px 40px;
  overflow-y: auto;
  max-height: 85vh;
  border-radius: 20px 0 0 20px;
  display: flex;
  flex-direction: column;
  scrollbar-gutter: stable; /* destekleyen tarayıcılarda scrollbar alanı stabil */
}

.rental-form-list-title,
.rental-form-title {
  color: var(--rental-text-color);
  font-size: 28px;
  font-weight: 600;
}

.rental-form-list-header {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 10px 14px;
  margin: 0 0 10px;
  cursor: pointer;
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(15, 140, 65, 0.98);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
}

.rental-form-list-header:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.30);
  outline-offset: 2px;
}

.rental-form-list-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.92);
}

.rental-form-list-count {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.rental-form-list-chevron {
  width: 20px;
  height: 20px;
  color: rgba(255, 255, 255, 0.9);
  transition: transform 220ms ease;
}

.rental-form-list-wrapper.is-collapsed .rental-form-list-chevron {
  transform: rotate(-180deg);
}

.rental-form-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Ürün listesi uzun olduğunda "devam var" hissi ver */
.rental-form-list-wrapper::after {
  content: "";
  position: sticky;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 22px;
  background: linear-gradient(180deg, rgba(15, 140, 65, 0) 0%, rgba(15, 140, 65, 0.95) 100%);
  pointer-events: none;
  z-index: 2;
}

.rental-form-list-wrapper.is-collapsed {
  overflow: hidden;
}

.rental-form-list-wrapper.is-collapsed .rental-form-list {
  display: none;
}

.rental-form-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--rental-border-color);
  border-radius: 12px;
  padding: 15px;
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 15px;
  align-items: center;
}

.rental-form-item img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  padding: 6px;
  max-width: 100%;
}

.rental-form-item-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.rental-form-item span {
  color: var(--rental-text-color);
  font-size: 16px;
  font-weight: 600;
}

.rental-form-item input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--rental-border-color);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--rental-text-color);
}

.rental-form-remove {
  background: #16b2541a;
  border: 1px solid #16b25452;
  color: #ffd8ca;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.rental-form-remove svg {
  width: 18px;
  height: 18px;
}

/* Mobilde ürün satırını daralt (çöp butonu her zaman görünsün) */
@media (max-width: 768px) {
  .rental-form-item {
    grid-template-columns: 64px minmax(0, 1fr) 36px;
    gap: 10px;
    padding: 12px;
  }

  .rental-form-item img {
    width: 64px;
    height: 64px;
    padding: 4px;
  }

  .rental-form-remove {
    width: 36px;
    height: 36px;
    justify-self: end;
  }
}

.rental-form-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 22px 16px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.06);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 14px;
}

.rental-form-empty svg {
  width: 56px;
  height: 56px;
  margin: 0;
  opacity: 0.55;
}

.rental-form-empty p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

@media (max-width: 768px) {
  .rental-form-empty {
    gap: 10px;
    padding: 16px 12px;
  }

  .rental-form-empty svg {
    width: 46px;
    height: 46px;
  }

  .rental-form-empty p {
    font-size: 13px;
  }
}

.rental-form-wrapper {
  background: #2c2f36;
  padding: 50px 50px 35px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 85vh;
  border-radius: 0 20px 20px 0;
  scrollbar-gutter: stable;
}

.rental-form-subtitle {
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  margin-bottom: 30px;
}

.rental-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.rental-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

.rental-form-group {
  position: relative;
}

.rental-form-group label {
  position: absolute;
  left: 15px;
  top: 0;
  transform: translateY(-50%);
  background: #2c2f36;
  padding: 0 15px;
  color: #fff;
  font-size: 14px;
  pointer-events: none;
}

.rental-form-group input,
.rental-form-group select {
  width: 100%;
  height: 65px;
  padding: 0 25px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: white;
  font-size: 15px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  outline: none;
}

.rental-form-group textarea {
  width: 100%;
  min-height: 120px;
  padding: 18px 25px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: white;
  font-size: 15px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  outline: none;
  resize: vertical;
}

.rental-form-group textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.rental-form-group input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.rental-form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 20px center;
  padding-right: 50px;
}

.rental-form-group select option {
  background: #2c2f36;
  color: #fff;
}

.rental-form-group input:focus,
.rental-form-group select:focus {
  box-shadow: 0 0 0 2px var(--rental-primary);
}

.rental-form-checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 15px 0;
}

.rental-form-checkbox-container {
  position: relative;
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
}

.rental-form-checkbox {
  position: absolute;
  inset: 0;
  opacity: 0;
  z-index: 10;
  margin: 0;
  cursor: pointer;
}

.rental-form-checkbox-box {
  width: 35px;
  height: 35px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
  position: relative;
}

.rental-form-checkbox-box::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 40%;
  height: 40%;
  border-radius: 5px;
  background: var(--rental-primary);
  opacity: 0;
  transition: all 0.35s ease;
}

.rental-form-checkbox:checked ~ .rental-form-checkbox-box::before {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.rental-form-checkbox-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  flex: 1 1 240px;
  min-width: 0;
  line-height: 1.4;
}

.rental-form-checkbox-label a {
  color: var(--rental-primary);
  text-decoration: none;
  font-weight: 600;
}

.rental-form-button-field {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.rental-form-submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 58px;
  width: 100%;
  max-width: 280px;
  padding: 0 60px;
  background: var(--rental-primary);
  border: none;
  border-radius: 50px;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.35s ease;
}

.rental-form-submit-circle {
  position: absolute;
  top: var(--ripple-y, 50%);
  left: var(--ripple-x, 50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.45s ease;
  pointer-events: none;
}

.rental-form-submit:hover .rental-form-submit-circle {
  transform: translate(-50%, -50%) scale(90);
}

.rental-form-response-output {
  display: none;
  margin: 15px 0;
}

.rental-form-message {
  padding: 15px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.rental-form-message.success {
  background: rgba(46, 213, 115, 0.15);
  color: #2ed573;
  border: 1px solid rgba(46, 213, 115, 0.3);
}

.rental-form-message.error {
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.rental-form-error {
  display: none;
  color: #ff6b6b;
  font-size: 12px;
  margin-top: 5px;
}

.rental-form-group input.error,
.rental-form-group select.error,
.rental-form-group textarea.error {
  box-shadow: 0 0 0 1px #ff6b6b !important;
}

.rental-form-contact-info {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid var(--rental-border-color);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* Tablet: Telefon ve E-posta yan yana */
@media (max-width: 1024px) {
  .rental-form-contact-info {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
}

.rental-form-contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.7);
}

.rental-form-contact-icon {
  width: 40px;
  height: 40px;
  background: #16b25436;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rental-form-contact-icon svg {
  width: 18px;
  height: 18px;
  stroke: var(--rental-primary);
}

.rental-form-contact-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rental-form-contact-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.rental-form-contact-number {
  font-size: 14px;
  font-weight: 500;
}

.rental-form-kvkk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1002;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  padding: 20px;
}

.rental-form-kvkk-overlay.active {
  opacity: 1;
  visibility: visible;
}

.rental-form-kvkk-modal {
  position: relative;
  background: var(--rental-text-color);
  border-radius: 20px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.rental-form-kvkk-close {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #6c727d;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  color: #fff;
}

.rental-form-kvkk-close svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
}

.rental-form-kvkk-content {
  padding: 90px 60px 60px;
  overflow-y: auto;
  color: white;
  background: #0f1b25;
  line-height: 1.8;
  border-radius: 20px;
}

/* Scrollbar styling (Popup + KVKK) */
.rental-form-list-wrapper,
.rental-form-wrapper,
.rental-form-kvkk-content {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(255, 255, 255, 0.45) rgba(255, 255, 255, 0.12); /* thumb track */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; /* iOS: daha akıcı scroll */
}

/* WebKit (Chrome, Edge, Safari) */
.rental-form-list-wrapper::-webkit-scrollbar,
.rental-form-wrapper::-webkit-scrollbar,
.rental-form-kvkk-content::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.rental-form-list-wrapper::-webkit-scrollbar-track,
.rental-form-wrapper::-webkit-scrollbar-track,
.rental-form-kvkk-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  margin: 6px;
}

.rental-form-list-wrapper::-webkit-scrollbar-thumb,
.rental-form-wrapper::-webkit-scrollbar-thumb,
.rental-form-kvkk-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0); /* creates padding */
  background-clip: padding-box;
}

.rental-form-list-wrapper::-webkit-scrollbar-thumb:hover,
.rental-form-wrapper::-webkit-scrollbar-thumb:hover,
.rental-form-kvkk-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.58);
}

.rental-form-list-wrapper::-webkit-scrollbar-corner,
.rental-form-wrapper::-webkit-scrollbar-corner,
.rental-form-kvkk-content::-webkit-scrollbar-corner {
  background: transparent;
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  color: #fff;
  padding: 15px 25px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  font-weight: 600;
  animation: slideInToast 0.3s ease;
  cursor: pointer;
}

.toast-success {
  background: #10b981;
}

.toast-warning {
  background: #f59e0b;
}

@keyframes slideInToast {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutToast {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

@media (max-width: 1024px) {
  .rental-form-modal {
    max-width: 90%;
    grid-template-columns: 1fr;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: visible; /* close button dışarı taşabilsin */
  }

  .rental-form-list-wrapper {
    flex: 0 0 auto;
    /* Dinamik yükseklik: ürün arttıkça büyüsün (sınır var) */
    --rf-count: 0;
    /* Maksimum 3 ürün görünsün: 1 üründe taban, 2. ve 3. ürün için 2 adım büyüme */
    --rf-steps: min(max(calc(var(--rf-count) - 1), 0), 2);
    max-height: clamp(220px, calc(220px + (var(--rf-steps) * 132px)), 44vh);
    border-radius: 20px 20px 0 0;
    padding: 18px 18px 16px;
  }

  .rental-form-wrapper {
    flex: 1 1 auto;
    min-height: 0; /* internal scroll */
    max-height: none;
    padding: 40px 30px 30px;
    border-radius: 0 0 20px 20px;
  }

  /* Tablet/Mobil: kapatma butonu üst orta, yarısı dışarıda */
  .rental-form-close {
    top: 0;
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(-50%);
    width: 42px;
    height: 42px;
  }

  .rental-form-close:hover {
    transform: translateX(-50%) translateY(-50%) rotate(-180deg);
  }

  .rental-form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .rental-form-modal {
    max-width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
  }

  /* Mobil: başlıklar biraz daha küçük */
  .rental-form-list-title,
  .rental-form-title {
    font-size: 22px;
    line-height: 1.15;
  }

  .rental-form-trigger {
    left: 20px;
    bottom: calc(24px + 52px + 16px + env(safe-area-inset-bottom, 0px));
    width: 50px;
    height: 50px;
  }

  .rental-form-trigger svg {
    width: 26px;
    height: 26px;
  }

  .rental-form-badge {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }

  .rental-form-list-wrapper {
    flex: 0 0 auto;
    /* Dinamik yükseklik: 1 üründe daha kısa, ürün arttıkça büyüsün (sınır var) */
    --rf-count: 0;
    /* Maksimum 3 ürün görünsün */
    --rf-steps: min(max(calc(var(--rf-count) - 1), 0), 2);
    max-height: clamp(240px, calc(240px + (var(--rf-steps) * 140px)), 54vh);
    padding: 14px 14px 12px;
    border-radius: 0;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  }

  .rental-form-list-wrapper.is-collapsed {
    max-height: 78px; /* sadece başlık kalsın */
  }

  .rental-form-list-header {
    border-radius: 12px;
  }

  .rental-form-wrapper {
    flex: 1 1 auto;
    min-height: 0; /* allow internal scroll */
    max-height: none;
    padding: 26px 18px 18px;
  }

  .rental-form-group input,
  .rental-form-group select {
    height: 55px;
  }

  .rental-form-group textarea {
    min-height: 120px;
  }

  .rental-form-submit {
    height: 50px;
    max-width: 100%;
    padding: 0 28px;
  }

  .rental-form-tooltip {
    display: none;
  }

  /* Mobil: Telefon ve E-posta alt alta */
  .rental-form-contact-info {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

@media (max-width: 1023px) {
  .rental-form-trigger {
    bottom: calc(24px + 52px + 18px + env(safe-area-inset-bottom, 0px));
    width: 54px;
    height: 54px;
  }

  .rental-form-trigger svg {
    width: 28px;
    height: 28px;
  }
}
