* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden; /* Aucun scroll global */
  background: #f2f2f2;
  color: #222;
}

/* HEADER + FOOTER restent fixes, mais sans scroll */
header {
  background: #222;
  color: #fff;
  text-align: center;
  padding: 1.2rem;
  flex-shrink: 0;
}

header h1 {
  font-size: 1.6rem;
  margin-bottom: .3rem;
}

footer {
  background: #222;
  color: #ccc;
  text-align: center;
  font-size: .8rem;
  padding: .8rem;
  flex-shrink: 0;
}

/* --- LAYOUT PRINCIPAL --- */

#app {
  display: flex;
  height: calc(100vh - 150px); /* header + footer */
  overflow: hidden;
}

/* --- ÉDITEUR À GAUCHE --- */

#editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f2f2f2;
}

#uploader {
  text-align: center;
  padding: 1rem;
}

.upload-label {
  display: inline-block;
  background: #0077ff;
  color: white;
  padding: 0.8rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}
.upload-label:hover {
  background: #005fcc;
}
.upload-label input {
  display: none;
}

/* Zone Konva */
main {
  flex: 1;
  display: flex;
  flex-direction: row; /* side by side */
  gap: 1rem;
  overflow: hidden;
}

/* Zone qui centre l’A4 */
#preview-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: #e6e6e6;
}

/* Wrapper centré */
#page-area {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* VRAIE FEUILLE A4 À L’ÉCRAN — toujours visible sans scroll */
#page-a4 {
  width: 100%;
  max-width: 650px;      /* largeur max, adaptée à ton layout */
  aspect-ratio: 1 / 1.414; /* ratio A4 portrait */
  background: white;
  border: 1px solid #ccc;
  box-shadow: 0 0 10px #0002;
  position: relative;
  overflow: hidden; /* le canvas reste dedans */
}

/* Version paysage quand l’utilisateur sélectionne "landscape" */
#page-a4.landscape {
  aspect-ratio: 1.414 / 1; /* ratio A4 paysage */
}

/* --- PANNEAU DE CONTRÔLE À DROITE --- */

#controls-pane {
  width: 330px;
  background: white;
  border-left: 1px solid #ccc;
  padding: 12px;
  overflow-y: auto; /* scroll interne */
}

#controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.primary-controls {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.control {
  flex: 1;
  display: flex;
  flex-direction: column;
}

label {
  font-size: .9rem;
  color: #333;
}

select,
input[type="number"],
input[type="range"] {
  padding: 0.3rem;
  border: 1px solid #aaa;
  border-radius: 4px;
}

/* Advanced settings */
details {
  border-top: 1px solid #ddd;
  padding-top: 0.5rem;
}
details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.advanced-group {
  margin: .5rem 0;
  display: flex;
  flex-direction: column;
}

/* Bouton generate */
#generateBtn {
  background: #28a745;
  color: white;
  border: none;
  padding: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}
#generateBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
#generateBtn:not(:disabled):hover {
  background: #208738;
}
