/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text: #eee;
  --text-muted: #aaa;
  --border: #333;
  --radius: 6px;
  --panel-width: 280px;
}
html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ── Top Bar ────────────────────────────────────────────────── */
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  height: 48px; gap: 12px; flex-shrink: 0;
}
#topbar h1 { font-size: 16px; white-space: nowrap; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.dim-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
#product-selector {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  padding: 4px 8px; border-radius: var(--radius); font-size: 13px; max-width: 200px;
}
.side-tabs { display: flex; gap: 2px; }
.side-tab {
  padding: 4px 12px; font-size: 12px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-muted); cursor: pointer;
  border-radius: var(--radius); transition: all .15s;
}
.side-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────── */
button {
  padding: 5px 10px; border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); border-radius: var(--radius); cursor: pointer;
  font-size: 12px; transition: all .15s;
}
button:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-full { width: 100%; margin-bottom: 8px; padding: 8px; }
.btn-sm { padding: 2px 6px; font-size: 11px; }
.btn-row { display: flex; gap: 4px; margin: 6px 0; flex-wrap: wrap; }

/* ── Main Layout ────────────────────────────────────────────── */
#main { display: flex; height: calc(100vh - 48px); overflow: hidden; }

/* ── Tool Panel (Left sidebar) ──────────────────────────────── */
#toolpanel {
  width: var(--panel-width); min-width: var(--panel-width); background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  overflow: hidden;
}
#tool-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tool-tab {
  flex: 1; text-align: center; padding: 10px 0; border: none; border-radius: 0;
  background: transparent; color: var(--text-muted); font-size: 16px;
}
.tool-tab:hover { background: var(--surface2); color: var(--text); }
.tool-tab.active { background: var(--surface2); color: var(--accent); border-bottom: 2px solid var(--accent); }
#panel-container { flex: 1; overflow-y: auto; padding: 12px; }
.panel { display: none; }
.panel.active { display: block; }
.panel h3 { font-size: 14px; margin-bottom: 10px; color: var(--accent); }
.panel h4 { font-size: 12px; margin: 8px 0 4px; color: var(--text-muted); }

/* ── Property groups ────────────────────────────────────────── */
.prop-group { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.prop-group label {
  display: flex; flex-direction: column; font-size: 12px; color: var(--text-muted);
  margin-bottom: 8px; gap: 3px;
}
.prop-group input[type="number"],
.prop-group input[type="url"],
.prop-group select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 4px 8px; border-radius: var(--radius); font-size: 13px; width: 100%;
}
.prop-group input[type="color"] { width: 100%; height: 30px; border: 1px solid var(--border); cursor: pointer; }
.prop-group input[type="range"] { width: 100%; }
.prop-group input[type="file"] { font-size: 12px; padding: 4px; }

/* ── Asset Grid (cliparts, templates) ──────────────────────── */
.asset-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px;
}
.asset-grid .asset-item {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; cursor: pointer; text-align: center; transition: all .15s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60px;
}
.asset-item:hover { border-color: var(--accent); transform: scale(1.05); }
.asset-item img { max-width: 100%; max-height: 48px; }
.asset-item span { font-size: 10px; color: var(--text-muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }

/* ── Shape Buttons ──────────────────────────────────────────── */
.shape-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.shape-buttons button { width: 48px; height: 48px; font-size: 22px; }

/* ── Layers List ────────────────────────────────────────────── */
#layers-list { max-height: 300px; overflow-y: auto; }
.layer-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius); font-size: 12px;
  transition: all .1s;
}
.layer-item:hover { background: var(--surface2); }
.layer-item.selected { border-color: var(--accent); background: var(--surface2); }
.layer-item .layer-icon { font-size: 14px; width: 20px; text-align: center; }
.layer-item .layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Canvas Area ────────────────────────────────────────────── */
#canvas-wrapper {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #111; overflow: hidden; position: relative;
}
#canvas-container {
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}
.canvas-container { /* Fabric wraps canvas in this */ }

/* ── Admin Page ─────────────────────────────────────────────── */
.admin-container {
  max-width: 1000px; margin: 0 auto; padding: 24px;
}
.admin-container h1 { margin-bottom: 20px; }
.admin-section { margin-bottom: 32px; }
.admin-section h2 {
  font-size: 18px; color: var(--accent); border-bottom: 1px solid var(--border);
  padding-bottom: 6px; margin-bottom: 12px;
}
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.admin-table th, .admin-table td {
  padding: 8px 12px; border: 1px solid var(--border); text-align: left;
}
.admin-table th { background: var(--surface2); color: var(--text-muted); }
.admin-form {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 12px;
}
.admin-form label {
  display: flex; flex-direction: column; font-size: 12px; color: var(--text-muted); gap: 4px;
}
.admin-form input, .admin-form select, .admin-form textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: var(--radius); font-size: 13px;
}
.admin-form textarea { grid-column: 1 / -1; min-height: 60px; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  #topbar { flex-wrap: wrap; height: auto; padding: 8px; }
  #toolpanel { width: 220px; min-width: 220px; }
  .topbar-right { flex-wrap: wrap; }
}
