/* ==========================================================================
   Sketchup Studio — Styles de l'application de composition
   ========================================================================== */

:root {
  --studio-header-h: 56px;
  --studio-sidebar-w: 320px;
  --studio-bg: #f3f4f6;
  --studio-border: var(--sk-ink, #212529);
}

[data-bs-theme="dark"] {
  --studio-bg: #111827;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.studio-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background-color: var(--studio-bg);
}

/* 1. Header du Studio */
.studio-header {
  height: var(--studio-header-h);
  border-bottom: 2px solid var(--studio-border);
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #212529);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 100;
  gap: 1rem;
  flex-shrink: 0;
}

.studio-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  color: inherit;
}

.studio-screen-input {
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px dashed transparent;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  width: 220px;
}
.studio-screen-input:hover,
.studio-screen-input:focus {
  border-color: var(--studio-border);
  background: var(--bs-tertiary-bg, #f8f9fa);
  outline: none;
}

/* 2. Corps du Studio (Sidebar + Canvas + Inspector) */
.studio-main {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--studio-header-h));
  overflow: hidden;
}

/* Sidebar gauche : Bibliothèque de composants */
.studio-sidebar {
  width: var(--studio-sidebar-w);
  border-right: 2px solid var(--studio-border);
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #212529);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  overflow: hidden;
}

.studio-sidebar-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.studio-search-blocks {
  width: 100%;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 6px;
}

.studio-palette {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.studio-category-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color, #6c757d);
  margin: 1rem 0 0.5rem;
}
.studio-category-title:first-child {
  margin-top: 0;
}

.studio-block-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 8px;
  background: var(--bs-tertiary-bg, #f8f9fa);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.studio-block-card:hover {
  background: var(--bs-body-bg, #fff);
  border-color: var(--studio-border);
  transform: translateY(-1px);
  box-shadow: 2px 2px 0 var(--studio-border);
}

.studio-block-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.studio-block-info i {
  font-size: 1.1rem;
  opacity: 0.7;
}

/* Zone centrale : Canvas */
.studio-canvas-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  background-image: radial-gradient(var(--bs-border-color, #cbd5e1) 1px, transparent 1px);
  background-size: 20px 20px;
}

.studio-canvas-wrapper {
  transition: max-width 0.25s ease, width 0.25s ease;
  width: 100%;
}

/* Modes de viewport */
.viewport-full .studio-canvas-wrapper {
  max-width: 100%;
}

.viewport-browser .studio-canvas-wrapper {
  max-width: 1100px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.viewport-phone .studio-canvas-wrapper {
  max-width: 420px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Canvas où les blocs vivent */
.studio-canvas {
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #212529);
  min-height: 80vh;
  border-radius: 8px;
  border: 2px solid var(--studio-border);
  padding: 1.5rem;
  position: relative;
}

.studio-canvas-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  color: var(--bs-secondary-color, #6c757d);
  text-align: center;
  border: 2px dashed var(--bs-border-color, #dee2e6);
  border-radius: 12px;
  padding: 2rem;
}

/* Blocs insérés dans le canvas */
.studio-canvas-block {
  position: relative;
  margin-bottom: 1.5rem;
  border: 1px dashed transparent;
  border-radius: 6px;
  transition: border-color 0.15s ease;
}

body.mode-compose .studio-canvas-block:hover {
  border-color: #3b82f6;
}

/* Barre d'outils du bloc au survol */
.studio-block-controls {
  position: absolute;
  top: -14px;
  right: 12px;
  display: none;
  background: #1e293b;
  color: #fff;
  border-radius: 6px;
  padding: 2px 4px;
  gap: 2px;
  z-index: 40;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

body.mode-compose .studio-canvas-block:hover > .studio-block-controls {
  display: flex;
}

.studio-btn-ctrl {
  background: none;
  border: none;
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.studio-btn-ctrl:hover {
  background: rgba(255, 255, 255, 0.2);
}
.studio-btn-ctrl.danger:hover {
  background: #ef4444;
}

/* Élément en cours d'édition directe de texte */
[contenteditable="true"] {
  outline: 2px dashed #3b82f6 !important;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 4px;
}

/* ==========================================================================
   Drag & Drop Styles
   ========================================================================== */
.studio-block-card[draggable="true"] {
  user-select: none;
}

.studio-block-card.dragging {
  opacity: 0.4;
  border-style: dashed;
}

.studio-canvas-block.dragging {
  opacity: 0.35;
  border: 2px dashed #3b82f6 !important;
}

.studio-drag-handle {
  cursor: grab !important;
  color: #94a3b8;
}
.studio-drag-handle:active {
  cursor: grabbing !important;
}

/* Ligne indicatrice de drop dans le canvas */
.studio-drop-indicator {
  height: 4px;
  background: #2563eb;
  border-radius: 2px;
  margin: 0.5rem 0;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
  position: relative;
  pointer-events: none;
  animation: skPulse 1.2s infinite ease-in-out;
}

.studio-drop-indicator::before {
  content: "Déposer ici";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #2563eb;
  color: #fff;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

@keyframes skPulse {
  0%, 100% { opacity: 0.8; transform: scaleY(1); }
  50% { opacity: 1; transform: scaleY(1.4); }
}

.studio-canvas.drag-over-active {
  background-color: rgba(59, 130, 246, 0.03);
}

/* ==========================================================================
   Gestion des Pages & Sauvegarde
   ========================================================================== */
.studio-page-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.studio-save-status {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.studio-save-status.saved {
  color: #15803d;
  background: #dcfce7;
  border: 1px solid #86efac;
}

.studio-save-status.unsaved {
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
}

