* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.1);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

.content {
  padding: 40px;
}

.section {
  margin-bottom: 40px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.section-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  font-size: 18px;
  font-weight: 600;
}

.section-content {
  padding: 20px;
}

.subsection {
  margin-bottom: 30px;
  border-left: 4px solid #667eea;
  padding-left: 20px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  transition: all 0.3s ease;
}

.subsection:hover {
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.1);
  transform: translateY(-2px);
}

.subsection h4 {
  color: #2c3e50;
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid #667eea;
  padding-bottom: 8px;
  display: inline-block;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #2c3e50;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.3s;
  font-family: inherit;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: #667eea;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 15px 0;
}

/* Desktop: 2 columns for checkbox groups */
@media (min-width: 768px) {
  .checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
  }
}

/* Large desktop: 3 columns for checkbox groups */
@media (min-width: 1024px) {
  .checkbox-group {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Checkbox item container to handle conditional fields */
.checkbox-item-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px; /* Prevent layout shifts */
  transition: all 0.3s ease;
}

.checkbox-item-container:hover {
  transform: translateY(-1px);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #fafafa;
  transition: all 0.3s ease;
  cursor: pointer;
  user-select: none;
  min-height: 40px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.checkbox-item:hover {
  background: #f0f4ff;
  border-color: #667eea;
}

.checkbox-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
  transition: left 0.5s ease;
}

.checkbox-item:hover::before {
  left: 100%;
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #667eea;
  cursor: pointer;
}

.checkbox-item label {
  cursor: pointer;
  font-weight: 500;
  color: #2c3e50;
  user-select: none;
}

.image-upload {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  background: #fafafa;
  transition: all 0.3s;
  cursor: pointer;
}

.image-upload:hover {
  border-color: #667eea;
  background: #f0f4ff;
}

.image-upload input[type="file"]:not(.overlay-input) {
  display: none;
}

/* Image preview styles */
.image-preview-container {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.image-preview {
  position: relative;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  max-width: 150px;
}

.image-preview.uploading {
  border-color: #007bff;
  background: #e7f3ff;
}

.image-preview.uploaded {
  border-color: #28a745;
  background: #f8fff8;
}

.image-preview.upload-failed {
  border-color: #dc3545;
  background: #fff5f5;
}

.image-preview img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.image-info {
  padding: 8px;
  background: #f8f9fa;
  font-size: 12px;
  position: relative;
}

.image-preview.uploading .image-info {
  background: #e7f3ff;
}

.image-preview.uploaded .image-info {
  background: #f8fff8;
}

.image-preview.upload-failed .image-info {
  background: #fff5f5;
}

.image-name {
  display: block;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.image-size, .image-status {
  display: block;
  color: #666;
  margin-top: 2px;
}

.upload-progress {
  margin-top: 5px;
  background: #e9ecef;
  border-radius: 3px;
  height: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #007bff, #0056b3);
  border-radius: 3px;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% {
    width: 0%;
    margin-left: 0%;
  }
  50% {
    width: 40%;
    margin-left: 30%;
  }
  100% {
    width: 0%;
    margin-left: 100%;
  }
}

.remove-image-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(255, 0, 0, 0.8);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-image-btn:hover {
  background: rgba(255, 0, 0, 1);
}

.image-upload.has-files {
  border-color: #28a745;
  background: #f8fff8;
}

/* Drag and drop styles */
.image-preview {
  cursor: move;
  transition: all 0.3s ease;
}

.image-preview.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
  z-index: 1000;
}

.image-preview.drag-over-before {
  border-left: 3px solid #667eea;
  transform: translateX(5px);
}

.image-preview.drag-over-after {
  border-right: 3px solid #667eea;
  transform: translateX(-5px);
}

.drag-handle {
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 10px;
  line-height: 1;
  cursor: grab;
  user-select: none;
  z-index: 10;
}

.drag-handle:active {
  cursor: grabbing;
}

.image-preview:hover .drag-handle {
  background: rgba(102, 126, 234, 0.9);
}

.room-item, .elevation-item {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  background: #f8f9fa;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #dee2e6;
}

.remove-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.3s;
}

.remove-btn:hover {
  background: #c82333;
}

.add-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin: 10px 0;
  transition: background-color 0.3s;
}

.add-btn:hover {
  background: #218838;
}

.btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 30px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
}

.conditional {
  display: none;
}

.conditional.show {
  display: block;
}

.hidden { 
  display: none !important; 
}

.conditional-fields {
  display: none;
  margin-top: 20px;
}

.conditional-fields.show {
  display: block;
}

/* Conditional Field Styles */
.conditional-field {
  margin-left: 0;
  margin-top: 0;
  padding: 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-left: 4px solid #667eea;
  border-radius: 6px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: top;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
  max-height: 0;
  opacity: 0;
  transform: scaleY(0);
}

.conditional-field[style*="display: block"] {
  padding: 12px;
  margin-top: 8px;
  max-height: 200px;
  opacity: 1;
  transform: scaleY(1);
}

.conditional-field label {
  display: block;
  font-size: 13px;
  color: #495057;
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.conditional-field input[type="number"] {
  width: 120px;
  padding: 8px 12px;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  background: white;
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.conditional-field input[type="number"]:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  transform: translateY(-1px);
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: white;
  padding: 20px 25px;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header.warning {
  background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.modal-header.success {
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}

.modal-header.info {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.modal-icon {
  font-size: 24px;
}

.modal-content {
  padding: 25px;
}

.modal-message {
  font-size: 16px;
  line-height: 1.5;
  color: #2c3e50;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 80px;
}

.modal-btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.modal-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.modal-btn-secondary {
  background: #ecf0f1;
  color: #2c3e50;
  border: 1px solid #bdc3c7;
}

.modal-btn-secondary:hover {
  background: #d5dbdb;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .modal {
    margin: 20px;
    width: calc(100% - 40px);
  }
  
  .modal-content {
    padding: 20px;
  }
  
  .modal-header {
    padding: 15px 20px;
  }
  
  .modal-actions {
    flex-direction: column;
  }
  
  .modal-btn {
    width: 100%;
  }
}

/* Image Gallery Styles */
.image-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
  max-height: 400px;
  overflow-y: auto;
  margin: 20px 0;
  padding: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.gallery-image-item {
  position: relative;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  background: #f9f9f9;
}

.gallery-image-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.gallery-image-item img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}

.selection-indicator {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.reuse-images-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  z-index: 10;
  transition: background-color 0.3s ease;
}

.reuse-images-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}

.image-preview.reused-image {
  border-left: 4px solid #2196F3;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.image-preview.reused-image .image-status {
  color: #2196F3;
  font-weight: 600;
}

.image-preview.reused {
  border-color: #6f42c1;
  background: #f8f4ff;
}

.image-preview.reused .image-status {
  color: #6f42c1;
  font-weight: 600;
}

/* Enhanced image upload area styles */
.image-upload {
  position: relative;
}

.image-upload.has-files {
  background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
  border-color: #4CAF50;
}

/* Loading states */
.conditional-field.loading {
  background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
  opacity: 0.7;
}

.conditional-field.loading input {
  pointer-events: none;
}

/* Improve form responsiveness */
@media (max-width: 768px) {
  .checkbox-group {
    grid-template-columns: 1fr !important;
  }
  
  .checkbox-item-container {
    min-height: auto;
  }
  
  .conditional-field {
    margin-left: 0;
    margin-top: 10px;
  }
}

/* Focus states for accessibility */
.checkbox-item input[type="checkbox"]:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

.conditional-field input[type="number"]:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
