/* ═══════════════════════════════════════════════════════
   Paint 11 — Dark Mode UI
   Windows 11 Fluent Design System
═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ─── Tokens ─── */
:root {
  --bg-base:       #1c1c1e;
  --bg-ribbon:     #2b2b2f;
  --bg-surface:    #232326;
  --bg-hover:      rgba(255,255,255,0.07);
  --bg-active:     rgba(0,120,212,0.25);
  --bg-pressed:    rgba(0,120,212,0.35);
  --border-subtle: rgba(255,255,255,0.08);
  --border-focus:  #0078d4;
  --accent:        #0078d4;
  --accent-light:  #60cdff;
  --text-primary:  #e0e0e0;
  --text-secondary:#9e9e9e;
  --text-dim:      #666;
  --canvas-bg:     #3a3a3e;
  --sep-color:     rgba(255,255,255,0.1);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --shadow-md: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);

  --ribbon-h: 90px;
  --statusbar-top-h: 28px;
  --statusbar-bot-h: 30px;
  --titlebar-h: 38px;

  --font: 'Inter', 'Segoe UI', sans-serif;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  user-select: none;
}
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
svg { display: block; }

/* ══════════════════════════════════════════
   TITLE BAR
══════════════════════════════════════════ */
.titlebar {
  height: var(--titlebar-h);
  background: var(--bg-ribbon);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 0 0 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}
.titlebar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}
.app-icon { width: 18px; height: 18px; }
.app-title { font-weight: 600; font-size: 13px; color: var(--text-primary); }

.titlebar-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex: 1;
  padding-left: 12px;
  height: 100%;
}
.tab {
  padding: 6px 18px 6px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  position: relative;
  top: 1px;
  border: 1px solid transparent;
  border-bottom: none;
}
.tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.tab:not(.active):hover { background: var(--bg-hover); color: var(--text-primary); }
.tab[contenteditable="true"] {
  outline: none;
  min-width: 80px;
  text-align: center;
}
.tab[contenteditable="true"]:focus {
  background: var(--bg-pressed);
}
.tab-action {
  padding: 6px 10px;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all 0.15s;
  margin-right: 4px;
}
.tab-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.tab-add {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text-dim);
  transition: color 0.15s, background 0.15s;
  align-self: center;
}
.tab-add:hover { color: var(--text-primary); background: var(--bg-hover); }

.titlebar-controls {
  display: flex;
  height: 100%;
}
.titlebar-controls .wc {
  width: 46px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
  border-radius: 0;
}
.titlebar-controls .wc:hover { background: var(--bg-hover); color: var(--text-primary); }
.titlebar-controls .wc.close:hover { background: #c42b1c; color: white; }

/* ══════════════════════════════════════════
   RIBBON
══════════════════════════════════════════ */
.ribbon {
  height: var(--ribbon-h);
  background: var(--bg-ribbon);
  display: flex;
  align-items: stretch;
  padding: 4px 4px 0;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  position: relative;
  overflow: visible;
  z-index: 100;
}

/* ── Group ── */
.ribbon-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 6px 18px;
  position: relative;
  flex-shrink: 0;
  min-height: 0;
  overflow: visible;
}
.ribbon-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  padding: 0 2px;
  overflow: visible;
}
.ribbon-group-label {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* ── Separator ── */
.ribbon-sep {
  width: 1px;
  background: var(--sep-color);
  margin: 8px 4px 8px;
  align-self: stretch;
  flex-shrink: 0;
}

/* ── Base Button ── */
.rb-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  border-radius: var(--radius-md);
  transition: background 0.12s, box-shadow 0.12s;
  position: relative;
  color: var(--text-primary);
  gap: 2px;
  min-width: 40px;
}
.rb-btn:hover { background: var(--bg-hover); }
.rb-btn.active {
  background: var(--bg-active);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.rb-btn:active { background: var(--bg-pressed); }

.rb-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rb-icon svg { width: 18px; height: 18px; }
.rb-label {
  font-size: 10px;
  white-space: nowrap;
  color: var(--text-secondary);
  line-height: 1;
}
.rb-btn.active .rb-label { color: var(--accent-light); }
.rb-arrow {
  font-size: 9px;
  position: absolute;
  right: 3px;
  bottom: 3px;
  color: var(--text-dim);
  line-height: 1;
}
.rb-btn.wide { min-width: 56px; }

/* Tall button */
.rb-btn.tall {
  min-width: 44px;
  padding: 5px 8px;
}
.rb-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rb-btn.sm {
  min-width: 52px;
  padding: 3px 6px;
  flex-direction: row;
  gap: 4px;
}
.rb-btn.sm .rb-icon { width: 16px; height: 16px; }
.rb-btn.sm .rb-icon svg { width: 14px; height: 14px; }

/* ── Tools Grid ── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.rb-btn.grid-tool {
  min-width: 38px;
  padding: 4px 6px;
  flex-direction: column;
}

/* ── Shapes ── */
.shapes-row {
  display: flex;
  gap: 6px;
  align-items: center;
  height: 100%;
}
.shapes-grid {
  display: grid;
  grid-template-columns: repeat(8, 26px);
  grid-template-rows: repeat(2, 26px);
  gap: 2px;
  align-items: center;
}
.rb-btn.shape-btn {
  min-width: 26px;
  width: 26px;
  height: 26px;
  padding: 4px;
  flex-direction: row;
}
.rb-btn.shape-btn svg { width: 18px; height: 18px; }

/* Shape options */
.shape-opts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 6px;
  border-left: 1px solid var(--sep-color);
}
.shape-opt-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.opt-label {
  font-size: 9px;
  color: var(--text-dim);
  width: 36px;
  flex-shrink: 0;
  line-height: 1.2;
}
.opt-btn {
  width: 24px;
  height: 24px;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: background 0.12s, border-color 0.12s;
}
.opt-btn svg { width: 16px; height: 16px; }
.opt-btn:hover { background: var(--bg-hover); }
.opt-btn.active {
  background: var(--bg-active);
  border-color: var(--accent);
}

/* ── Colors Section ── */
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1; /* Forca ocupar altura correta */
  padding: 4px 0;
}
.active-colors {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.active-color-box {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  position: absolute;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.c2-box { bottom: 0; right: 0; z-index: 1; }
.c1-box {
  top: 0; left: 0; z-index: 2;
  border-color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--accent);
}
.active-color-box:hover { transform: scale(1.08); }

.color-palette {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.palette-row {
  display: flex;
  gap: 3px;
}
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  border: 1.5px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.swatch:hover {
  transform: scale(1.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  border-color: rgba(255,255,255,0.3);
  z-index: 5;
  position: relative;
}
.swatch.selected-c1 {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 3.5px rgba(0,0,0,0.6);
}

.edit-colors-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: background 0.12s;
  flex-shrink: 0;
}
.edit-colors-btn:hover { background: var(--bg-hover); }
.color-wheel {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: block;
  background: conic-gradient(
    hsl(0,100%,50%),
    hsl(30,100%,50%),
    hsl(60,100%,50%),
    hsl(90,100%,50%),
    hsl(120,100%,50%),
    hsl(150,100%,50%),
    hsl(180,100%,50%),
    hsl(210,100%,50%),
    hsl(240,100%,50%),
    hsl(270,100%,50%),
    hsl(300,100%,50%),
    hsl(330,100%,50%),
    hsl(360,100%,50%)
  );
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.edit-colors-label {
  font-size: 9.5px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

/* ── Active color slot indicator ── */
.active-color-box.active-slot {
  box-shadow: 0 0 0 2px var(--accent), 0 0 8px rgba(0,120,212,0.7);
  transform: scale(1.1);
}

/* ── Eraser Size Dropdown ── */
.eraser-size-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 4px;
}
.eraser-sz {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  transition: background 0.12s, color 0.12s;
}
.eraser-sz:hover { background: var(--bg-hover); color: var(--text-primary); }
.eraser-sz.active { background: var(--bg-active); color: var(--accent-light); }
.esz-dot {
  display: inline-block;
  background: currentColor;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Copilot (kept for CSS completeness, hidden UI) ── */
.copilot-btn { gap: 4px; }

/* ══════════════════════════════════════════
   DROPDOWNS
══════════════════════════════════════════ */
.dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  background: #2d2d31;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 100;
  animation: fadeSlideDown 0.12s ease;
}
.dropdown.open { display: block; }
.dd-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
}
.dd-overlay.active { display: block; }

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-primary);
  text-align: left;
  transition: background 0.1s;
}
.dd-item:hover { background: var(--bg-hover); }
.dd-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }
.dd-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}
.dd-title {
  padding: 4px 10px 2px;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.brush-item { justify-content: flex-start; }
.size-picker {
  display: flex;
  gap: 8px;
  padding: 4px 10px;
  align-items: center;
}
.size-opt {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: background 0.1s;
  border: 1px solid transparent;
}
.size-opt:hover { background: var(--bg-hover); }
.size-opt.active { background: var(--bg-active); border-color: var(--accent); }

/* ══════════════════════════════════════════
   STATUS BAR TOP
══════════════════════════════════════════ */
.statusbar-top {
  height: var(--statusbar-top-h);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sb-sep {
  width: 1px;
  height: 12px;
  background: var(--sep-color);
}

/* ══════════════════════════════════════════
   WORKSPACE
══════════════════════════════════════════ */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--canvas-bg);
  position: relative;
}

/* ── Canvas Container ── */
.canvas-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  position: relative;
}
/* Custom scrollbars */
.canvas-container::-webkit-scrollbar { width: 8px; height: 8px; }
.canvas-container::-webkit-scrollbar-track { background: var(--canvas-bg); }
.canvas-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.canvas-container::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

.canvas-container {
  position: relative;
}
#mainCanvas, #overlayCanvas {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  image-rendering: pixelated;
  cursor: crosshair;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3), var(--shadow-md);
}
#mainCanvas { background: #ffffff; }
#overlayCanvas { background: transparent; }

/* ── Side Panel (Layers) ── */
.side-panel {
  width: 220px;
  background: var(--bg-ribbon);
  border-left: 1px solid var(--border-subtle);
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  animation: slideFromRight 0.18s ease;
}
.side-panel.open { display: flex; }

@keyframes slideFromRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
  font-size: 13px;
}
.panel-close {
  font-size: 13px;
  color: var(--text-dim);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.panel-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.panel-body { flex: 1; padding: 8px; overflow-y: auto; }
.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: background 0.1s;
  cursor: pointer;
}
.layer-item:hover { background: var(--bg-hover); }
.layer-item.active { background: var(--bg-active); }
.layer-thumb {
  width: 36px;
  height: 26px;
  border-radius: 3px;
  background: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.layer-name { flex: 1; font-size: 12px; }
.layer-vis { font-size: 14px; padding: 2px; border-radius: 3px; }
.layer-vis:hover { background: var(--bg-hover); }

.panel-footer {
  padding: 8px;
  display: flex;
  gap: 4px;
  border-top: 1px solid var(--border-subtle);
}
.layer-action {
  flex: 1;
  padding: 6px;
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: background 0.1s;
  color: var(--text-primary);
  text-align: center;
}
.layer-action:hover { background: var(--bg-hover); }

/* ══════════════════════════════════════════
   STATUS BAR BOTTOM
══════════════════════════════════════════ */
.statusbar-bottom {
  height: var(--statusbar-bot-h);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
#status-zoom { min-width: 38px; text-align: right; }
.zoom-slider-wrap {
  width: 120px;
  display: flex;
  align-items: center;
}
#zoom-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ══════════════════════════════════════════
   MODAL
══════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #202022;
  border: 1px solid #45454a;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
  min-width: 320px;
  animation: slideUp 0.15s ease;
  overflow: hidden;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #2b2b2f;
  border-bottom: 1px solid #45454a;
  font-weight: 600;
  font-size: 14px;
}
.modal-header button {
  font-size: 14px;
  color: var(--text-dim);
  padding: 3px 7px;
  border-radius: 4px;
  transition: background 0.12s;
}
.modal-header button:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { 
  padding: 20px; 
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-ok {
  background: var(--accent);
  padding: 8px 24px;
  color: white;
  border-radius: 6px;
  font-weight: 600;
  transition: background 0.12s;
}
.modal-ok:hover { background: #005fa3; }

/* ══════════════════════════════════════════
   TOOLTIP
══════════════════════════════════════════ */
[title] { position: relative; }
[title]::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: #ddd;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s 0.4s;
  z-index: 999;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
[title]:hover::after { opacity: 1; }

/* ─ Scrollbar global ─ */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }
