/* === KUCHYŇSKÝ NÁVRHÁŘ — Styly === */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --bg-sidebar: #12122a;
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --text-muted: #555;
  --accent: #e07a5f;
  --accent-hover: #c9694f;
  --blue: #5B8DBE;
  --green: #81B29A;
  --border: #2a2a4a;
  --radius: 8px;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* === LAYOUT === */
.app-container {
  display: flex;
  height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.sidebar-header p {
  font-size: 12px;
  color: var(--text-secondary);
}

/* === PROGRESS === */
.step-progress {
  display: flex;
  padding: 12px 20px;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.step-indicator {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.3s;
}

.step-indicator.done {
  background: var(--green);
}

.step-indicator.active {
  background: var(--accent);
}

/* === SEKCE === */
.sidebar-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.step-section {
  animation: fadeIn 0.2s ease;
}

.step-section.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-section h2 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.step-section h3 {
  font-size: 14px;
  margin: 16px 0 8px;
  color: var(--text-primary);
}

/* === FORMULÁŘE === */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-row {
  display: flex;
  gap: 8px;
  align-items: end;
}

.form-row .form-group {
  flex: 1;
}

input[type="number"],
select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

input[type="number"]:focus,
select:focus {
  border-color: var(--accent);
}

input[type="number"]::-webkit-inner-spin-button {
  opacity: 0.3;
}

/* === TLAČÍTKA === */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

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

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

.btn-small {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-danger {
  background: #c0392b;
  color: #fff;
}

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

.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* === NAVIGACE === */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.hidden {
  display: none !important;
}

/* === TVAR KUCHYNĚ === */
.shape-btn {
  width: 70px;
  height: 70px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.shape-btn span {
  font-size: 11px;
}

.shape-btn.active {
  border-color: var(--accent);
  background: rgba(224, 122, 95, 0.1);
}

.shape-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.shape-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* === SEZNAM PRVKŮ === */
.element-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 12px;
}

.muted {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

/* === LAYER CONTROLS === */
.layer-controls {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.layer-btn {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
}

.layer-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === SUMMARY === */
#cabinet-summary h3 {
  color: var(--accent);
  margin-top: 0;
}

#cabinet-summary h4 {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 12px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#cabinet-summary ul {
  list-style: none;
  padding: 0;
}

#cabinet-summary li {
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.summary-total {
  margin-top: 16px;
  padding: 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  font-size: 13px;
}

/* === WALL VISIBILITY (3D) === */
.wall-visibility {
  margin-bottom: 12px;
}

.wall-visibility h4 {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.wall-toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}

.wall-toggle-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}

.wall-toggle-grid input[type="checkbox"] {
  accent-color: var(--accent);
}

/* === PLACE BUTTONS (okna/dveře) === */
.place-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-place {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

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

.btn-place.active {
  border-color: var(--accent);
  background: rgba(224, 122, 95, 0.15);
  color: var(--accent);
}

.place-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(224, 122, 95, 0.1);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--accent);
  animation: fadeIn 0.2s ease;
}

/* === CABINET EDIT PANEL === */
.cabinet-edit-panel {
  margin-top: 16px;
  padding: 14px;
  background: rgba(224, 122, 95, 0.08);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}

.cabinet-edit-panel h3 {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 10px;
}

.edit-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.edit-cab-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.add-cabinet-section {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
}

.add-cabinet-section h3 {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

/* === CANVAS AREA === */
.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#kitchen-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* === TOOLTIP === */
#cabinet-tooltip {
  position: fixed;
  display: none;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

/* === ADDONS (přidej okno/dveře) === */
.add-section {
  background: var(--bg-tertiary);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.add-section h4 {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
}

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(224, 122, 95, 0.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a3a5a;
}

/* === WALL SELECTION INFO === */
.wall-info {
  padding: 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 3px solid var(--accent);
}

/* === DECOR GRID === */
.modal-wide {
  width: 1100px;
  max-width: 95vw;
}

.decor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  max-height: 68vh;
  overflow-y: auto;
  padding: 8px 4px;
}

.decor-item {
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s;
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
}

.decor-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(224, 122, 95, 0.3);
}

.decor-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}

.decor-item .decor-name {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* === PREVIEW MODAL === */
.preview-images {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.preview-image-box {
  flex: 1;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
}

.preview-image-box h4 {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
}

.preview-image-box img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 4px;
  display: block;
  background: #111;
}

.preview-prompt-box {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 12px;
}

.preview-prompt-box h4 {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
}

.preview-prompt-box pre {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.5;
  font-family: 'SF Mono', 'Fira Code', monospace;
  margin: 0;
}

/* === QUALITY PICKER === */
.preview-quality-box {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 12px;
}

.preview-quality-box h4 {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
}

.quality-options {
  display: flex;
  gap: 10px;
}

.quality-option {
  cursor: pointer;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  transition: all 0.2s;
}

.quality-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(224, 122, 95, 0.1);
}

.quality-option input {
  accent-color: var(--accent);
}

.quality-option em {
  font-style: normal;
  color: var(--text-muted);
  font-size: 11px;
  margin-left: auto;
}

/* === AI PHOTO BUTTON === */
.btn-accent {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-weight: 600;
  border: none;
  transition: all 0.3s;
}

.btn-accent:hover {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-accent:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  width: 900px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

/* Loading spinner */
.ai-loading {
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

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

.ai-loading p {
  color: var(--text-primary);
  margin-bottom: 4px;
}

/* Result image */
.ai-result {
  width: 100%;
  text-align: center;
}

.ai-result img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Cost info */
.ai-cost {
  margin-top: 12px;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.ai-cost .cost-total {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

.ai-cost .cost-detail {
  color: var(--text-muted);
  font-size: 11px;
}

/* Error */
.ai-error {
  text-align: center;
}

.ai-error p:first-child {
  font-size: 16px;
  color: #e74c3c;
  margin-bottom: 8px;
}

/* === SEZNAM POLOŽEK === */
.item-list {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.item-list h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text-primary);
}

#item-list-content {
  font-size: 13px;
  line-height: 1.6;
}

.item-category {
  margin-bottom: 12px;
}

.item-category h4 {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.item-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.item-row:last-child {
  border-bottom: none;
}

.item-name {
  color: var(--text-secondary);
}

.item-value {
  color: var(--text-primary);
  font-weight: 500;
}

.item-total {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--accent);
  font-weight: bold;
  display: flex;
  justify-content: space-between;
}

/* Version switch bar for comparison mode */
.version-switch {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(0,0,0,.12);
  box-shadow: 0 12px 35px rgba(0,0,0,.18);
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 13px;
}
.version-switch span {
  font-weight: 700;
  color: #1f2937;
  padding: 0 4px;
}
.version-switch .switch-btn {
  text-decoration: none;
  color: #374151;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
}
.version-switch .switch-btn.active {
  color: white;
  background: #2563eb;
  border-color: #2563eb;
}
@media (max-width: 720px) {
  .version-switch { left: 10px; right: 10px; justify-content: center; flex-wrap: wrap; }
}
