/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2c3e50;
  --primary-light: #34495e;
  --accent: #e67e22;
  --accent-hover: #d35400;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #e0e0e0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* === Header === */
.header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  font-size: 1.2rem;
  font-weight: 600;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
}

.header-logo svg {
  width: 28px;
  height: 28px;
}

.header-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header-nav a {
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  transition: color 0.2s;
}

.header-nav a:hover {
  color: white;
}

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

/* === Search & Filters === */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
}

.filter-btn {
  padding: 10px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* === Door Cards Grid === */
.doors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.door-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.door-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.door-card-image {
  width: 100%;
  height: 320px;
  object-fit: cover;
  background: #eee;
}

.door-card-body {
  padding: 16px;
}

.door-card-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.door-card-category {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.door-card-price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.door-card-colors {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s;
}

.color-dot:hover,
.color-dot.active {
  transform: scale(1.2);
  border-color: var(--accent);
}

/* === Door Detail Page === */
.door-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-top: 20px;
}

.door-image-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #f0f0f0;
}

.door-main-image {
  width: 100%;
  height: auto;
  min-height: 400px;
  object-fit: cover;
}

.door-info {
  padding: 10px 0;
}

.door-name {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.door-category-tag {
  display: inline-block;
  background: var(--bg);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.door-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 20px;
}

.door-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  margin-top: 20px;
}

.door-description {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}

.door-material {
  font-size: 1rem;
  color: var(--text);
}

.door-sizes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.size-tag {
  padding: 6px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
}

.door-variants {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.variant-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.variant-btn:hover,
.variant-btn.active {
  border-color: var(--accent);
}

.variant-btn .color-dot {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--primary);
  color: white;
}

.btn-secondary:hover {
  background: var(--primary-light);
}

.btn-outline {
  background: white;
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
  margin-top: 24px;
}

/* === Interior Viewer === */
.interior-viewer {
  margin-top: 20px;
}

.interior-scene {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 24px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #f0f0f0;
}

.interior-controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 20px;
}

.room-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.room-btn {
  padding: 10px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.room-btn:hover,
.room-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

/* === Admin Panel === */
.admin-login {
  max-width: 400px;
  margin: 80px auto;
  padding: 40px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.admin-login h2 {
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-table {
  width: 100%;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table tr:hover {
  background: #f8f9fa;
}

.admin-table img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
}

.admin-actions {
  display: flex;
  gap: 6px;
}

.status-active {
  color: #27ae60;
  font-weight: 600;
}

.status-inactive {
  color: #e74c3c;
  font-weight: 600;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal h2 {
  margin-bottom: 20px;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px 8px;
}

/* Variant editor in admin */
.variant-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.variant-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.variant-item input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.variant-item .remove-variant {
  background: #e74c3c;
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-light);
}

.breadcrumb a {
  color: var(--text-light);
}

.breadcrumb a:hover {
  color: var(--accent);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: white;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 300;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  background: #e74c3c;
}

.toast.success {
  background: #27ae60;
}

/* Image upload preview */
.image-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  position: relative;
}

.image-upload:hover {
  border-color: var(--accent);
}

.image-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.image-upload img {
  max-height: 150px;
  margin: 0 auto 10px;
  border-radius: 6px;
}

.image-upload p {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Loading spinner */
.loading {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.back-link:hover {
  color: var(--accent);
}

/* === Admin Tabs === */
.admin-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.admin-tab {
  padding: 12px 24px;
  border: none;
  background: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.admin-tab:hover {
  color: var(--text);
}

.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
}

/* === Settings === */
.settings-block {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.settings-block h3 {
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.settings-hint {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.tag-remove {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
}

.tag-remove:hover {
  color: #c0392b;
}

.add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-sm {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  flex: 1;
  max-width: 300px;
  transition: border-color 0.2s;
}

.input-sm:focus {
  border-color: var(--accent);
}

.filter-group-block {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

.filter-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* === Catalog Filter Selects === */
.filter-select-group {
  flex-shrink: 0;
}

.filter-select {
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: white;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.filter-select:focus {
  border-color: var(--accent);
}

/* === Door Tags in Catalog Cards === */
.door-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.door-tag {
  display: inline-block;
  background: #eef2ff;
  color: #4a5568;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
  .header h1 {
    font-size: 1rem;
  }

  .container {
    padding: 12px;
  }

  .doors-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .door-card-image {
    height: 220px;
  }

  .door-card-body {
    padding: 10px;
  }

  .door-card-name {
    font-size: 0.95rem;
  }

  .door-card-price {
    font-size: 1rem;
  }

  .door-detail {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .door-name {
    font-size: 1.4rem;
  }

  .door-price {
    font-size: 1.5rem;
  }

  .filters {
    flex-direction: column;
  }

  .search-input {
    min-width: 100%;
  }

  .admin-table {
    font-size: 0.85rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 8px 10px;
  }

  .modal {
    padding: 20px;
    margin: 10px;
  }

  .interior-scene {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .doors-grid {
    grid-template-columns: 1fr;
  }

  .door-card-image {
    height: 280px;
  }

  .header-nav {
    gap: 10px;
  }
}
