/* ──────────────────────────────────────────────────────────────────
   Button Designer — 58mm
   ────────────────────────────────────────────────────────────────── */

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

:root {
  --bg:          #1a1a2e;
  --surface:     #16213e;
  --surface2:    #0f3460;
  --accent:      #e94560;
  --accent2:     #533483;
  --text:        #f0f0f0;
  --text-muted:  #a8b2c8;
  --border:      #2a3a5e;

  --bleed-color: rgba(255, 80,  80,  0.55);
  --cut-color:   rgba(255, 220, 50,  0.85);
  --safe-color:  rgba(80,  200, 120, 0.55);

  --sidebar-w: 260px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; font-size: 14px; }

/* ── Layout ────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#home-btn {
  min-height: 36px;
}

#sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  padding-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.75;
  letter-spacing: 0.3px;
  text-align: center;
}

#canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ── Logo ──────────────────────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.logo-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0%, var(--accent2) 60%, var(--surface2) 100%);
  flex-shrink: 0;
}

/* ── Panels ────────────────────────────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 12px;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.panel h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  min-height: 44px;       /* touch-vriendelijk op iPad */
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }

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

.btn-export   { background: var(--accent2); color: #fff; width: 100%; white-space: normal; line-height: 1.35; }
.btn-export:hover { opacity: .85; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); color: var(--text); }

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

input[type="file"] { display: none; }

/* ── Range slider ──────────────────────────────────────────────── */
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Legend ────────────────────────────────────────────────────── */
.legend { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid transparent;
  flex-shrink: 0;
}
.dot-bleed { border-color: rgb(255, 80, 80); }
.dot-cut   { border-color: rgb(255, 220, 50); }
.dot-safe  { border-color: rgb(80, 200, 120); }

.hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ── Drop overlay ──────────────────────────────────────────────── */
#drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
  transition: opacity .2s;
}
#drop-overlay.hidden { opacity: 0; }

.drop-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
}
.drop-message svg {
  width: 64px; height: 64px;
  opacity: 0.4;
}
.drop-message p {
  text-align: center;
  line-height: 1.6;
  opacity: 0.6;
}
.drop-text-mobile  { display: none; }
@media (max-width: 768px) {
  .drop-text-desktop { display: none; }
  .drop-text-mobile  { display: block; }
}

/* ── Canvas stage ──────────────────────────────────────────────── */
#stage-container {
  touch-action: none;  /* voorkom browser scroll/zoom op canvas bij touch */
}
#stage-container canvas {
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--border), 0 8px 40px rgba(0,0,0,.5);
}

/* ── Canvas legend ─────────────────────────────────────────────── */
#canvas-legend {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(18, 18, 28, 0.80);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 28px;
  padding: 10px 24px;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}
.cl-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-right: 16px;
  border-right: 1px solid rgba(255,255,255,0.12);
}
.cl-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
}
.cl-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid transparent;
  flex-shrink: 0;
}
.cl-bleed { border-color: rgb(255, 80, 80); }
.cl-cut   { border-color: rgb(255, 220, 50); }
.cl-safe  { border-color: rgb(80, 200, 120); }

/* ── Format toggle ─────────────────────────────────────────────── */
.format-toggle {
  display: flex;
  gap: 0;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.format-btn {
  flex: 1;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.format-btn:hover { background: var(--border); color: var(--text); }
.format-btn.active { background: var(--surface2); color: var(--text); }
.format-btn:not(:last-child) { border-right: 1px solid var(--border); }

/* ── Checkbox labels ───────────────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  display: block;
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Inlogscherm ───────────────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
}
#login-screen.hidden { display: none; }

.auth-error {
  color: var(--accent);
  font-size: 13px;
  text-align: center;
  padding: 6px 0;
}

/* ── Startscherm ───────────────────────────────────────────────── */
#start-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}
#start-screen.hidden { display: none; }

.start-inner {
  width: min(460px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.start-logo {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 4px;
}
.start-title  { font-size: 24px; font-weight: 700; color: var(--text); }
.start-subtitle { font-size: 15px; color: var(--text-muted); margin-top: 3px; }

.start-section-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
#start-projects-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
}
.start-project-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  gap: 12px;
  transition: background .15s, border-color .15s;
}
.start-project-card:hover { background: var(--surface2); border-color: var(--accent2); }
.start-project-card-name { font-size: 16px; font-weight: 600; color: var(--text); }
.start-project-card-meta { font-size: 14px; color: var(--text-muted); margin-top: 3px; }

/* ── Text input ────────────────────────────────────────────────── */
.text-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
  min-height: 36px;
}
.text-input::placeholder { color: var(--text-muted); opacity: 0.7; }
.text-input:focus { outline: none; border-color: var(--accent); }
textarea.text-input { min-height: unset; padding: 6px 10px; font-family: inherit; }
select.text-input { cursor: pointer; }

.btn-sm { padding: 0 12px; min-height: 36px; font-size: 12px; }

/* ── Layer list ────────────────────────────────────────────────── */
#layers-list { display: flex; flex-direction: column; gap: 2px; }

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s;
}
.layer-item:hover    { background: rgba(255,255,255,0.04); }
.layer-item.selected { background: rgba(255,255,255,0.07); border-color: var(--border); }

.layer-name    { flex: 1; font-size: 12px; color: var(--text); }
.layer-actions { display: flex; gap: 2px; }

.layer-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
}
.layer-btn:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,0.1); }
.layer-btn:disabled { opacity: 0.25; cursor: default; }
.layer-delete:hover:not(:disabled) { color: var(--accent); }

/* ── Project list ──────────────────────────────────────────────── */
#projects-list { display: flex; flex-direction: column; }

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.project-item:last-child { border-bottom: none; }

.project-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.project-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-date { font-size: 11px; color: var(--text-muted); }

.project-actions { display: flex; gap: 4px; flex-shrink: 0; }

.btn-danger:hover { background: rgba(220,60,60,0.18); color: var(--accent); border-color: var(--accent); }

/* ── Print Preview Modal ───────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(3px);
}
.modal-backdrop.hidden { display: none; }

.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  width: min(620px, 94vw);
  max-height: 90dvh;       /* dvh werkt beter op iPad met adresbalk */
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.btn-icon-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 5px;
  transition: background .15s;
}
.btn-icon-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  overflow: auto;
  -webkit-overflow-scrolling: touch;  /* iOS momentum scroll */
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.modal-body canvas {
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.08);
  display: block;
  max-width: 100%;
  height: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}
.modal-footer .btn-export { width: auto; padding: 8px 20px; }

/* ── Responsive — iPad staand en kleine tablets (≤ 820px) ─────── */
@media (max-width: 820px) {
  :root { --sidebar-w: 220px; }

  .logo { font-size: 13px; }

  .checkbox-label { font-size: 13px; min-height: 36px; }

  .format-btn { padding: 9px 0; }

  /* Modal vult bijna volledig scherm op kleine tablets */
  .modal-dialog { border-radius: 10px; }
  .modal-body   { padding: 12px; }
}

/* ── Mobiel toolbar (verborgen op desktop) ─────────────────────── */
#mobile-toolbar {
  display: none;
}

/* ── Mobiel — iPhone en smalle schermen (≤ 768px) ─────────────── */
@media (max-width: 768px) {
  #app {
    flex-direction: column;
    height: 100dvh;
  }

  /* Sidebar verborgen — panels verschijnen als overlay */
  #sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    max-height: 55dvh;
    z-index: 50;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-right: none;
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    padding: 16px 16px 24px;
    gap: 8px;
    transform: translateY(100%);
    transition: transform .25s ease;
    box-shadow: 0 -8px 40px rgba(0,0,0,.5);
  }
  #sidebar.mobile-open {
    transform: translateY(0);
  }

  /* Canvas neemt het volle scherm min toolbar */
  #canvas-area {
    flex: 1;
    width: 100%;
    /* Ruimte voor toolbar onderaan */
    padding-bottom: 56px;
  }

  /* Mobiele toolbar */
  #mobile-toolbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 4px 8px env(safe-area-inset-bottom, 4px);
    gap: 2px;
    justify-content: space-around;
  }
  .mob-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    min-width: 52px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
  }
  .mob-btn svg { width: 22px; height: 22px; }
  .mob-btn.active { color: var(--accent); }

  /* Verberg sidebar onderdelen die niet nodig zijn in overlay */
  .logo, #sidebar-footer, #home-btn { display: none; }

  /* Project naam + opslaan bovenaan sidebar overlay */
  #sidebar > div:first-of-type { padding-top: 0; }

  /* Panels beter leesbaar op mobiel */
  .panel { padding: 12px; font-size: 15px; }
  .panel h3 { font-size: 13px; }
  .field-label { font-size: 14px; }
  .checkbox-label { font-size: 14px; min-height: 40px; }
  .btn { font-size: 15px; min-height: 48px; }
  .btn-sm { font-size: 13px; min-height: 40px; }
  .text-input { font-size: 16px; min-height: 40px; }  /* 16px voorkomt iOS zoom */
  select.text-input { font-size: 16px; }
  input[type="range"] { height: 28px; }

  /* Canvas legend compact */
  #canvas-legend {
    bottom: 60px;
    padding: 6px 12px;
    gap: 8px;
  }
  .cl-title { display: none; }
  .cl-item { font-size: 11px; gap: 4px; }
  .cl-dot  { width: 10px; height: 10px; }

  .drop-message svg { width: 48px; height: 48px; }
  .drop-message p   { font-size: 14px; }

  /* Drop overlay klikbaar op mobiel */
  #drop-overlay { pointer-events: auto; cursor: pointer; }

  /* Backdrop achter sidebar overlay */
  #mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
  }
  #mobile-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ── Zeer smal — iPhone SE (≤ 400px) ──────────────────────────── */
@media (max-width: 400px) {
  #canvas-legend { display: none; }
}
