/* Delivery Details Flow CSS - Adapted from Figma */
/* Updated for Detached Toggle & Pickup View */

/* Wrapper */
.delivery-container {
  background: #ffffff;
  border-radius: 20px;
  padding: 0;
  margin-bottom: 30px;
  position: relative;
  font-family: "DM Sans", sans-serif;
}

/* --- Header Section --- */
.delivery-header-container {
  background: #e6f8ff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px; /* Space between header and toggle */
}

.delivery-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0px; /* Detached toggle implies no margin needed inside */
}

.delivery-title {
  font-weight: 500;
  font-size: 20px;
  line-height: 26px;
  color: #000000;
}

.btn-enable-location {
  background: #ffffff;
  border: 1px solid #00a5f1;
  border-radius: 35px;
  width: 114px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 12px;
  color: #00a5f1;
  cursor: pointer;
}

/* --- Toggle Switch (Detached) --- */
.delivery-toggle-wrapper {
  /* Previously background: #E6F8FF; */
  border-radius: 25px;
  display: flex;
  justify-content: center;
  position: relative;
  max-width: 100%;
}

.delivery-toggle-wrapper.detached {
  background: transparent;
  margin-bottom: 30px;
  padding: 0 10px;
}

/* The pill background */
.delivery-toggle-pill {
  background: #e6f8ff; /* Light blue bg for the pill itself */
  border-radius: 25px;
  display: flex;
  position: relative;
  width: 100%;
  height: 45px;
  align-items: center;
}

.delivery-toggle-option {
  flex: 1;
  text-align: center;
  z-index: 2;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  line-height: 18px;
  color: #303030;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 25px;
  transition: all 0.3s ease;
}

.delivery-toggle-option.active {
  background: #303030;
  color: #ffffff;
}

/* Free Badge */
.badge-pickup-free {
  background: #00b04f;
  border-radius: 34px;
  padding: 2px 8px;
  font-weight: 700;
  font-size: 10px;
  color: #ffffff;
  margin-left: 5px;
  vertical-align: middle;
}

/* --- Address Section --- */
.delivery-address-section {
  padding: 0 10px;
}

.delivery-subtitle {
  font-weight: 700;
  font-size: 16px;
  line-height: 21px;
  color: #303030;
  margin-bottom: 20px;
}

/* Address Card */
.address-card {
  background: #ffffff;
  border: 1px solid #e7eef1;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}

.address-card.selected {
  background: #e6f8ff;
  border: 1px solid #00a5f1;
}

.address-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.address-name {
  font-weight: 500;
  font-size: 14px;
  color: #303030;
}

.address-actions {
  display: flex;
  gap: 15px;
  align-items: center;
}

.address-change-btn,
.address-delete-btn {
  font-weight: 700;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.address-change-btn {
  color: #00a5f1;
}

.address-delete-btn {
  color: #ff3b30;
}

.address-text {
  font-weight: 500;
  font-size: 14px;
  color: #303030;
  line-height: 1.4;
  white-space: normal;
}

/* Add New Address */
.btn-add-address {
  background: transparent;
  border-radius: 10px;
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  padding-left: 20px;
  cursor: pointer;
  margin-bottom: 30px;
  border: none;
  text-align: left;
}
.btn-add-address span {
  font-weight: 700;
  font-size: 14px;
  color: #00a5f1;
}

#address-list-container {
  border-bottom: 1px solid #e7eef1;
}

/* --- New Address Form --- */
.form-label-small {
  font-weight: 500;
  font-size: 10px;
  line-height: 13px;
  color: #95a1a7;
  margin-bottom: 5px;
  text-transform: uppercase;
  display: block;
}

.form-input-line {
  border: none;
  border-bottom: 1px solid #e7eef1;
  width: 100%;
  font-weight: 500;
  font-size: 14px;
  line-height: 18px;
  color: #303030;
  padding: 5px 0;
  margin-bottom: 5px; /* Adjust spacing */
  outline: none;
}
.form-input-line:focus {
  border-bottom-color: #00a5f1;
}

/* --- Address Live Preview --- */
.address-preview-box {
  background: #f8f9fa;
  border: 1px dashed #00a5f1;
  border-radius: 12px;
  padding: 15px;
}

.address-preview-box .preview-label {
  font-size: 10px;
  font-weight: 700;
  color: #00a5f1;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.address-preview-box .preview-content {
  font-size: 13px;
  color: #303030;
  font-weight: 500;
  line-height: 1.4;
}

.btn-add-landmark {
  font-weight: 700;
  font-size: 12px;
  color: #00a5f1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
}

/* Save & Continue */
.btn-save-continue {
  background: linear-gradient(180deg, #21b9ff 0%, #00a5f1 100%);
  border-radius: 200px;
  width: 300px;
  height: 45px;
  border: none;
  font-weight: 500;
  font-size: 16px;
  color: #ffffff;
  cursor: pointer;
  display: block;
  margin-top: 20px;
}
.btn-save-continue:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- Pickup Mode Specific --- */
.pickup-form-section {
  padding: 10px;
}

/* Map Button */
.btn-map-view {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border: 1px solid #00a5f1;
  color: #00a5f1;
  font-size: 10px;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 768px) {
  .btn-save-continue {
    width: 100%;
  }
}

/* White Overlay Loader */
#white-overlay-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  z-index: 10010; /* Higher than delivery wrapper and sticky footer */
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  backdrop-filter: blur(2px);
}

#white-overlay-loader .spinner-border {
  width: 3rem;
  height: 3rem;
  color: #00a5f1;
}

#white-overlay-loader .loader-text {
  margin-top: 15px;
  font-weight: 500;
  color: #303030;
  font-size: 16px;
}

#map-picker-wrapper,
.desktop-only-hint {
  display: none;
}

/* Mobile Full Screen Map */
@media (max-width: 768px) {
  #map-picker-wrapper,
  .desktop-only-hint {
    display: block;
  }

  body.map-fullscreen-active {
    overflow: hidden; /* Prevent scrolling body */
  }

  body.map-fullscreen-active #delivery-add-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: #fff;
    padding: 0 !important;
    overflow: hidden;
  }

  /* Hide form and other elements when map is active */
  body.map-fullscreen-active .delivery-subtitle,
  body.map-fullscreen-active .desktop-only-hint {
    display: none !important;
  }

  /* Bottom Sheet Form State */
  body.map-fullscreen-active #form-new-address.bottom-sheet-form {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background: #fff;
    z-index: 10001;
    border-radius: 25px 25px 0 0;
    padding: 0; /* Padding moved to body/footer */
    overflow: hidden;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateY(110%);
    transition: transform 0.3s ease-out;
  }

  .bottom-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px 20px;
    -webkit-overflow-scrolling: touch;
  }

  .form-address-preview-box {
    background: #e6f8ff;
    border-radius: 25px 25px 0 0;
    padding: 20px;
    margin: -25px -20px 16px -20px;
    position: sticky;
    top: -25px;
    z-index: 3;
    border-bottom: 1px solid #d8edf7;
  }

  .bottom-sheet-footer {
    padding: 5px 20px 25px 20px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.02);
  }
  body.map-fullscreen-active.sheet-active #form-new-address.bottom-sheet-form {
    transform: translateY(0);
  }

  /* The map mobile controls sit behind the sliding form, so we let them be visible instead of hiding them. They will be naturally covered by the active sheet. */
  /* Search Bar Desktop & Mobile */
  #map-search-container {
    position: absolute;
    top: 15px;
    left: 10px;
    right: 10px;
    z-index: 20;
    pointer-events: auto;
  }

  .search-input-wrapper {
    background: #fff;
    border-radius: 30px;
    padding: 10px 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
  }

  #map-search-input {
    border: none;
    width: 100%;
    font-size: 15px;
    font-weight: 500;
    outline: none;
    color: #303030;
  }

  #btn-search-back {
    color: #303030 !important;
    font-size: 18px;
    cursor: pointer;
  }

  /* Elevate Google Places Autocomplete above full-screen map */
  .pac-container {
    z-index: 99999 !important;
  }

  /* Make map full screen */
  body.map-fullscreen-active #map-picker-wrapper,
  body.map-fullscreen-active #map-picker {
    height: 100% !important;
    width: 100% !important;
    border: none;
    border-radius: 0;
    margin: 0;
    position: absolute;
    top: 0;
    left: 0;
  }

  /* Controls Bar (Minimized) */
  body.map-fullscreen-active #map-mobile-controls {
    display: block !important;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 10000;
    pointer-events: none;
  }

  .map-address-preview {
    background: #fff;
    padding: 24px 20px;
    border-radius: 25px 25px 0 0;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    animation: slideUp 0.3s ease-out;
  }

  .map-address-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }

  .map-address-title {
    font-family: "DM Sans", sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: #303030;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 15px;
  }

  .map-address-change-btn {
    background: transparent;
    border: none;
    color: #00a5f1;
    font-weight: 700;
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
    white-space: nowrap;
  }

  .map-address-text {
    font-family: "DM Sans", sans-serif;
    font-size: 12px;
    color: #303030;
    margin-bottom: 5px;
    font-weight: 500;
    line-height: 1.5;
    white-space: normal;
  }

  /* Confirm Button in Sheet */
  .sheet-confirm-wrapper {
    margin-bottom: 20px;
  }

  .mobile-only-block {
    display: none;
  }

  @media (max-width: 768px) {
    .mobile-only-block {
      display: block !important;
    }
  }

  /* Animations */
  @keyframes slideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  /* Summary Content Specifics */
  #selected-delivery-content .address-card {
    cursor: default;
    background: #fdfdfd;
  }

  #selected-delivery-content .address-actions {
    display: none;
  }
}
