:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg-body: #f3f4f6;
  --bg-panel: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-light: #6b7280;
  --grid-col-bg: rgba(255, 0, 80, 0.06);
  --grid-line: rgba(255, 0, 80, 0.15);
  --success: #10b981;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-body);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- UI COMPONENTS --- */
.btn {
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.full { width: 100%; }

/* --- LAYOUT --- */
.app { display: flex; flex-direction: column; height: 100%; }

.top-nav {
  height: 60px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 50;
}
.logo { font-weight: 700; font-size: 1.1rem; }

.device-toggles {
  background: #f3f4f6;
  padding: 4px;
  border-radius: 8px;
  display: flex;
  gap: 4px;
}
.device-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-light);
}
.device-btn.active { background: white; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.main-layout { flex: 1; display: flex; overflow: hidden; }

.toolbox {
  width: 280px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.components-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.component {
  background: white; border: 1px solid var(--border);
  padding: 12px; border-radius: 6px; text-align: center;
  font-size: 0.85rem; cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.component:hover { border-color: var(--primary); transform: translateY(-2px); }

/* --- WORKSPACE & GRID --- */
.workspace { flex: 1; background: #e5e5e5; position: relative; overflow: hidden; }
.canvas-scroller { width: 100%; height: 100%; overflow: auto; padding: 40px; display: flex; justify-content: center; }
.canvas-container {
  background: white;
  box-shadow: 0 20px 50px -12px rgba(0,0,0,0.25);
  position: relative;
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  min-height: 1200px;
  margin-bottom: 100px;
}
.canvas-info {
  position: absolute; bottom: -30px; left: 0; width: 100%;
  text-align: center; font-size: 0.8rem; color: #666;
}

.grid-overlay { position: absolute; inset: 0; display: flex; pointer-events: none; z-index: 1; }
.grid-col { flex: 1; background: var(--grid-col-bg); border-left: 1px dashed var(--grid-line); border-right: 1px dashed var(--grid-line); height: 100%; }
.drop-zone { position: absolute; inset: 0; z-index: 5; }

/* --- BLOCKS --- */
.block {
  position: absolute;
  background: white;
  border: 2px solid #3b82f6;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: var(--primary);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  user-select: none; cursor: grab;
  overflow: visible; z-index: 10;
  transition: border-color 0.2s;
}

/* Nouveau : État sélectionné */
.block.selected {
  border-color: #f59e0b; /* Orange quand sélectionné */
  z-index: 20;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

.block.is-modified { border-color: #10b981; background-color: #ecfdf5; }

.resize-handle {
  position: absolute; width: 20px; height: 20px;
  background: white; border: 2px solid var(--primary);
  border-radius: 50%; bottom: -8px; right: -8px;
  cursor: nwse-resize; z-index: 101;
}

.status-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; background-color: #10b981;
  border-radius: 50%; display: none;
}
.block.is-modified .status-dot { display: block; }

/* --- NOUVEAU : TOAST NOTIFICATIONS --- */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: #10b981; color: white;
  padding: 12px 20px; border-radius: 8px;
  font-weight: 500; font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  animation: slideIn 0.3s ease-out;
  display: flex; align-items: center; gap: 8px;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- NOUVEAU : INSPECTEUR --- */
.inspector-box {
  background: #f8fafc;
  border: 2px solid var(--primary);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 10px;
  animation: fadeIn 0.3s;
}
.inspector-content p {
  font-size: 0.85rem; margin-bottom: 8px;
  display: flex; justify-content: space-between;
}
.inspector-content span { font-weight: 600; color: var(--text); }
.saved-views-list { margin: 12px 0; padding-top: 12px; border-top: 1px solid #e2e8f0; }
.tags-container { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.view-tag {
  font-size: 0.7rem; padding: 2px 6px; border-radius: 4px;
  background: #e0e7ff; color: var(--primary); font-weight: 600;
}

/* UTILS */
.hidden { display: none !important; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 999; display: flex; justify-content: center; align-items: center; }
.modal-box { background: white; width: 600px; padding: 24px; border-radius: 12px; }
textarea { width: 100%; height: 300px; background: #1f2937; color: #a5f3fc; padding: 16px; border-radius: 8px; border: none; resize: none; }
