/* General Body Styling */
* {
  box-sizing: border-box; /* Prevents size overflow */
}

html, body {
  background-color: #f8f9fa;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #212529;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden; /* Stops horizontal scroll */
}

/* Header */
.header {
  margin-bottom: 20px;
  text-align: center;
}

/* Back Button Styling */
.back-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  background-color: #6c757d;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.back-btn:hover {
  background-color: #5a6268;
  transform: scale(1.05);
}

/* Page Wrapper: Two Columns on Desktop */
.page-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  max-width: 1200px;
  width: 100%;
  margin: 50px auto;
  padding: 0 20px;
}

/* Left Column: Form Section */
.container {
  position: relative;
  background: #ffffff;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 30px 40px;
}

/* Right Column: Estimate Summary */
.estimate-summary {
  max-width: 800px;
  background-color: #f1f3f5;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  padding: 25px 30px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.estimate-summary h2 {
  text-align: center;
  color: #007bff;
  font-size: 28px;
  margin-bottom: 20px;
}

.estimate-summary p {
  font-size: 16px;
  margin: 10px 0;
}

.estimate-summary .total-cost {
  font-size: 20px;
  font-weight: bold;
  color: #28a745;
}

#map {
  border-radius: 8px;
  margin-top: 15px;
  height: 300px;
  width: 100%; /* Prevent map from overflowing */
}

/* Headings */
h1 {
  text-align: center;
  color: #343a40;
  margin-bottom: 20px;
  font-size: 36px;
}

/* Labels */
label {
  font-weight: 600;
  display: block;
  margin-top: 20px;
  margin-bottom: 8px;
  color: #495057;
}

/* Input Fields */
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #ced4da;
  font-size: 15px;
  transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: #495057;
  outline: none;
}

/* Primary Buttons */
.primary-btn {
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: all 0.3s ease;
}

.primary-btn:hover {
  background: linear-gradient(135deg, #0056b3, #003d80);
  transform: translateY(-1px);
}

/* Quantity Buttons */
.qty-btn {
  background-color: #f1f3f5;
  color: #495057;
  border: 1px solid #ced4da;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.qty-btn:hover {
  background-color: #e2e6ea;
  transform: scale(1.05);
}

input#quantity {
  width: 60px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid #ced4da;
  font-size: 16px;
  padding: 8px;
  margin: 0 8px;
}

/* Add Item Container */
.add-item-container {
  display: flex;
  flex-wrap: wrap; /* Prevent overflow */
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

/* Search Results Dropdown */
.search-wrapper {
  position: relative;
}

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  margin-top: 4px;
  background: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  max-height: 250px;
  overflow-y: auto;
  z-index: 9999;
}

#search-results div {
  background: #f8f9fa;
  margin: 4px 6px;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 15px;
  color: #212529;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

#search-results div:hover {
  background-color: #e9ecef;
  transform: scale(1.02);
}

/* Items List Styling */
#items-list {
  list-style-type: none;
  padding: 0;
  margin: 15px 0;
  max-width: 100%;
  height: 250px; /* Fixed height */
  overflow-y: auto; /* Scrolls inside */
  overflow-x: hidden;
  border: 1px solid #ced4da;
  border-radius: 8px;
  background-color: #ffffff;
}


#items-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  word-break: break-word; /* Prevent overflow text */
}

#items-list li:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: scale(1.02);
}

/* Trash Button */
.trash-btn {
  background-color: #f8d7da;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  padding: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.trash-btn:hover {
  background-color: #dc3545;
  color: #fff;
  transform: scale(1.1);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #343a40;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 2000;
}

.toast.show {
  opacity: 1;
}

/* Modal Styling */
.modal {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: #fff;
  border-radius: 8px;
  padding: 20px 25px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
}

.modal-btn.cancel {
  background-color: #dee2e6;
  color: #495057;
}

.modal-btn.remove {
  background-color: #dc3545;
  color: #fff;
}

.modal-btn.remove:hover {
  background-color: #c82333;
}

/* Responsive Layout: Stack on Mobile */
@media (max-width: 900px) {
  .page-wrapper {
    grid-template-columns: 1fr;
  }
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  background-color: #f8f9fa;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  margin-bottom: 10px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.item-row:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: scale(1.02);
}

.item-name {
  flex-grow: 1;
  font-weight: 600;
  color: #343a40;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 120px;
}

.editable-qty {
  width: 50px;
  text-align: center;
  border: 1px solid #ced4da;
  border-radius: 6px;
  padding: 6px;
  font-size: 15px;
}

.qty-btn {
  background-color: #f1f3f5;
  color: #495057;
  border: 1px solid #ced4da;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.qty-btn:hover {
  background-color: #e2e6ea;
  transform: scale(1.05);
}

.trash-btn {
  background-color: #f8d7da;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  padding: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.trash-btn:hover {
  background-color: #dc3545;
  color: #fff;
  transform: scale(1.1);
}
/* Additional Options Styling */
.additional-options {
  margin-top: 20px;
  padding: 15px 0;
  border-top: 1px solid #dee2e6;
}

.additional-options label {
  display: block;
  margin-top: 10px;
  font-weight: 500;
  color: #495057;
}

.additional-options input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  margin-top: 6px;
  border-radius: 6px;
  border: 1px solid #ced4da;
  font-size: 15px;
}

/* Custom Item Styling */
.custom-item {
  margin-top: 20px;
  padding: 15px 0;
  border-top: 1px solid #dee2e6;
}

.custom-item label {
  font-weight: 600;
  display: block;
  margin-top: 10px;
  margin-bottom: 6px;
  color: #495057;
}

.custom-item input[type="text"],
.custom-item input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #ced4da;
  font-size: 15px;
  margin-bottom: 10px;
}
.modal-content label {
  text-align: left;
  display: block;
  margin: 12px 0 6px;
  font-weight: 600;
}

.modal-content input[type="text"],
.modal-content input[type="email"],
.modal-content input[type="tel"] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #ced4da;
  font-size: 15px;
  margin-bottom: 10px;
}
.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100vw;
  background: rgba(255, 255, 255, 0.6);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.spinner {
  border: 6px solid #f3f3f3;
  border-top: 6px solid #007bff;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.input-error {
  color: red;
  font-size: 0.8em;
  margin-top: 2px;
  display: block;
}

input.invalid {
  border: 1px solid red;
}


/* === PATCH: Prevent page from enlarging when items are added === */
#items-list {
  padding: 0;
  margin-top: 10px;
  list-style: none;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 8px 12px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 8px;
  width: 100%;
  box-sizing: border-box;
}

.item-row input,
.item-row button {
  max-width: 60px;
  flex-shrink: 0;
}

.item-name {
  flex-grow: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.fade-out {
   opacity: 1;
   transition: opacity 0.5s ease-in-out;
}
body.fade-out.fade {
    opacity: 0;
}
@media (max-width: 600px) {
  .page-wrapper {
    grid-template-columns: 1fr;
    padding: 10px;
    margin-top: 30px;
  }

  .container {
    padding: 20px;
    border-radius: 10px;
  }

  .estimate-summary {
    padding: 20px;
    margin-top: 20px;
  }

  .add-item-container {
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  }

  .add-item-container input[type="number"],
  .add-item-container .qty-btn,
  .add-item-container .primary-btn {
     flex: 1 1 auto;
     max-width: 60px;
   }

  .add-item-container .primary-btn {
    max-width: 150px;
    flex: 1 1 100%;
  }


  input#quantity {
    width: 100%;
    margin: 6px 0;
  }

  .qty-btn {
    width: 100%;
    padding: 10px;
    margin: 6px 0;
  }

  .primary-btn {
    width: 100%;
    margin-top: 10px;
    font-size: 16px;
  }

  .back-btn {
    position: relative;
    display: inline-block;
    margin: 10px 0;
    left: 0;
    top: 0;
  }

  #items-list li {
    flex-direction: column;
    align-items: flex-start;
  }

  .item-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .item-row input,
  .item-row button {
    flex: 1 1 30%;
    max-width: 100%;
  }

  .modal-content {
    padding: 15px;
    width: 95%;
  }

  .toast {
    right: 10px;
    left: 10px;
    bottom: 10px;
    text-align: center;
  }
}
@media (max-width: 600px) {
  .item-row {
    flex-wrap: wrap;
    flex-direction: row;
    gap: 8px;
    justify-content: flex-start;
    align-items: center;
  }

  .item-row .item-name {
    flex-basis: 100%;
    font-size: 16px;
  }

  .item-row .qty-btn,
  .item-row .editable-qty,
  .item-row .trash-btn {
    flex: 1 1 22%;
    max-width: 22%;
    min-width: 50px;
    text-align: center;
  }

  .item-row .editable-qty {
    padding: 6px;
  }

  .item-row input,
  .item-row button {
    width: 100%;
  }
}
.furniture-set {
  margin-bottom: 20px;
}

.furniture-set select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #ced4da;
  font-size: 15px;
}