/* Wallpaper Maker Classic CSS - Modern Dark/Light Design System */
:root {
  --bg-app: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #243248;
  --bg-hover: #334155;
  --bg-input: #0b1120;
  --border-color: #334155;
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-primary: #38bdf8;
  --accent-hover: #0284c7;
  --accent-pink: #ec4899;
  --accent-purple: #a855f7;
  --accent-amber: #f59e0b;
  --danger: #ef4444;
  --success: #10b981;
  
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-height: 56px;
  --footer-height: 40px;
  --sidebar-width: 320px;
  --right-panel-width: 300px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: #f8fafc;
  --bg-hover: #e2e8f0;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #0284c7;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --accent-primary: #0284c7;
  --accent-hover: #0369a1;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}

/* App Header */
.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  gap: 12px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* App Body Layout */
.app-body {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height) - var(--footer-height));
  position: relative;
  overflow: hidden;
  align-items: stretch;
}

/* Left Sidebar */
.left-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 50;
  flex-shrink: 0;
  transition: transform 0.25s ease;
  overflow: hidden;
}

.tab-nav {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 10px 6px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: var(--bg-surface);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: none;
}

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

/* Center Canvas Stage */
.canvas-stage {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  position: relative;
  background-color: #0b1120;
  background-image: 
    radial-gradient(#1e293b 1px, transparent 1px),
    radial-gradient(#1e293b 1px, #0b1120 1px);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 32px;
  box-sizing: border-box;
}

.canvas-viewport {
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.1);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  flex-shrink: 0;
  margin: auto;
  transform-origin: center center;
  transition: width 0.15s ease, height 0.15s ease;
}

#mainCanvas {
  display: block;
  background: #ffffff;
  border-radius: 6px;
  transition: width 0.15s ease, height 0.15s ease;
}

/* Overlay UI for Guides and Mockups */
.preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

/* Right Sidebar (Properties & Layers) */
.right-sidebar {
  width: var(--right-panel-width);
  height: 100%;
  max-height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 50;
  flex-shrink: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 16px;
  gap: 14px;
}

/* Layer Management */
.layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  min-height: 48px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px;
  background: var(--bg-input);
  flex-shrink: 0;
}

/* App Footer */
.app-footer {
  height: var(--footer-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-muted);
  z-index: 100;
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Reusable UI Components */
.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-main);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-label span.val {
  color: var(--accent-primary);
  font-family: monospace;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}

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

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #0b1120;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  padding: 6px;
  min-width: 32px;
  height: 32px;
}

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

/* Color Picker Row */
.color-picker-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.color-picker-row input[type="color"] {
  -webkit-appearance: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 32px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}
.color-picker-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-picker-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: var(--radius-sm);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.palette-chip {
  aspect-ratio: 1;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.2);
  transition: transform 0.1s, outline 0.1s;
}
.palette-chip:hover {
  transform: scale(1.15);
  outline: 2px solid var(--accent-primary);
}

/* Template Grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.template-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, transform 0.15s;
}
.template-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}
.template-preview {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 4px;
  margin-bottom: 6px;
  background-size: cover;
  background-position: center;
}
.template-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
}

/* Layer Management */
.layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px;
  background: var(--bg-input);
}
.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 4px;
  background: var(--bg-card);
  cursor: pointer;
  font-size: 12px;
  border: 1px solid transparent;
}
.layer-item:hover {
  background: var(--bg-hover);
}
.layer-item.active {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.1);
}
.layer-controls {
  display: flex;
  gap: 4px;
}
.layer-ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 2px;
}
.layer-ctrl-btn:hover {
  color: var(--text-main);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.active {
  visibility: visible;
  opacity: 1;
}
.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 280px;
    --right-panel-width: 260px;
  }
}

@media (max-width: 768px) {
  .app-body {
    flex-direction: column;
    height: auto;
    overflow: auto;
  }
  .left-sidebar, .right-sidebar {
    width: 100%;
    height: auto;
    border: none;
  }
  .canvas-stage {
    min-height: 50vh;
    padding: 20px 0;
  }
}
