/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
  line-height: 1.6;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 40px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.title {
  font-size: 2.5rem;
  font-weight: 700;
  color: white;
  margin-bottom: 10px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.subtitle {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 400;
}

/* Main Content */
.main-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 25px;
  align-items: start;
}

/* Kitchen Preview */
.kitchen-preview {
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.kitchen-viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 16/10;
  border-radius: 15px;
  overflow: hidden;
  background: #f8f9fa;
}

.background-image,
.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.layer {
  pointer-events: none;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.loading-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e9ecef;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

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

/* Material Selectors */
.material-selectors {
  background: white;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
  max-height: 82vh;
  overflow-y: auto;
}

.material-section {
  margin-bottom: 22px;
}

.material-section:last-child {
  margin-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #2d3436;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 2px solid #f1f3f4;
}

.icon {
  font-size: 1.3rem;
}

/* Material Grid */
.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 12px;
}

.material-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid transparent;
  background: #f8f9fa;
}

.material-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.material-item.active {
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.material-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.material-item:hover img {
  transform: scale(1.05);
}

.material-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  padding: 12px 8px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.material-item:hover .material-label {
  opacity: 1;
}

/* Reset Controls */
.reset-controls {
  margin-top: 30px;
  text-align: center;
}

.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #ff7675, #fd79a8);
  color: white;
  border: none;
  padding: 15px 30px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 25px rgba(255, 118, 117, 0.3);
}

.reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(255, 118, 117, 0.4);
}

.reset-btn:active {
  transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .material-selectors {
    max-height: none;
  }

  .title {
    font-size: 2rem;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header {
    padding: 20px;
    margin-bottom: 25px;
  }

  .title {
    font-size: 1.8rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .kitchen-preview,
  .material-selectors {
    padding: 16px;
  }

  .material-grid {
    grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .material-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .reset-btn {
    padding: 12px 25px;
    font-size: 0.9rem;
  }
}

/* Smooth scrollbar for material selectors */
.material-selectors::-webkit-scrollbar {
  width: 6px;
}

.material-selectors::-webkit-scrollbar-track {
  background: #f1f3f4;
  border-radius: 3px;
}

.material-selectors::-webkit-scrollbar-thumb {
  background: #cfd8dc;
  border-radius: 3px;
}

.material-selectors::-webkit-scrollbar-thumb:hover {
  background: #b0bec5;
}

/* Animation for layer changes */
.layer.changing {
  opacity: 0.7;
}

/* Preload images to prevent loading delays */
.preload {
  position: absolute;
  top: -9999px;
  left: -9999px;
  visibility: hidden;
}
