/* ========================================
   Cantinho — Estilos
   ======================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
}

.hidden {
  display: none !important;
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  user-select: none;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-title {
  font-weight: 600;
  font-size: 15px;
  color: #475569;
  letter-spacing: -0.02em;
  padding: 0 8px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-separator {
  width: 1px;
  height: 28px;
  background: #e2e8f0;
  margin: 0 8px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #475569;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.tool-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.tool-btn:active {
  background: #e2e8f0;
}

.tool-btn .material-symbols-rounded {
  font-size: 20px;
}

.tool-label {
  font-size: 12px;
  font-weight: 500;
}

.tool-btn-danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

.save-indicator {
  font-size: 12px;
  color: #94a3b8;
  padding: 4px 10px;
  border-radius: 4px;
  background: #f8fafc;
}

.save-indicator.saving {
  color: #f59e0b;
}

.save-indicator.saved {
  color: #22c55e;
}

.save-indicator.error {
  color: #ef4444;
}

/* ---------- Format Bar ---------- */
.format-bar {
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  height: 44px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 6px;
  z-index: 9999;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  user-select: none;
}

.format-select {
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #334155;
  cursor: pointer;
  outline: none;
  min-width: 140px;
}

.format-select:focus {
  border-color: #3b82f6;
}

.format-input {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  text-align: center;
  color: #334155;
  outline: none;
}

.format-input:focus {
  border-color: #3b82f6;
}

.format-color {
  width: 32px;
  height: 32px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  background: #fff;
}

.format-separator {
  width: 1px;
  height: 24px;
  background: #e2e8f0;
  margin: 0 4px;
}

.format-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  margin-right: 4px;
}

.format-range {
  width: 120px;
  accent-color: #3b82f6;
}

.format-value {
  font-size: 12px;
  color: #64748b;
  min-width: 36px;
}

.fmt-btn {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
  font-family: inherit;
}

.fmt-btn:hover {
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.fmt-btn.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #3b82f6;
}

/* ---------- Canvas ---------- */
.canvas {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  background: #ffffff;
}

.canvas.edit-mode {
  top: 52px;
  background-image:
    radial-gradient(circle, #d4d4d8 0.8px, transparent 0.8px);
  background-size: 24px 24px;
  background-color: #fafafa;
}

.canvas.edit-mode.has-format-bar {
  top: 96px;
}

/* ---------- Elements ---------- */
.element {
  position: absolute;
  cursor: default;
  user-select: none;
  transition: box-shadow 0.15s;
}

.element.edit-mode-element {
  cursor: grab;
}

.element.edit-mode-element:active {
  cursor: grabbing;
}

.element.selected {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.element.dragging {
  opacity: 0.9;
  z-index: 99999 !important;
}

/* -- Text Element -- */
.element-text .text-content {
  min-width: 60px;
  min-height: 24px;
  padding: 8px 12px;
  outline: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.5;
}

.element-text.editing {
  cursor: text;
}

.element-text.editing .text-content {
  cursor: text;
}

/* -- Image Element -- */
.element-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* -- Button Element -- */
.element-button .button-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: filter 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.element-button .button-content:hover {
  filter: brightness(1.08);
}

.element-button.edit-mode-element .button-content {
  pointer-events: none;
}

/* -- Hotspot Element -- */
.element-hotspot {
  background: transparent;
}

.element-hotspot.edit-mode-element {
  background: rgba(59, 130, 246, 0.08);
  border: 2px dashed #3b82f6;
  border-radius: 4px;
}

.element-hotspot.edit-mode-element::after {
  content: 'Hotspot';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  color: #3b82f6;
  font-weight: 500;
  pointer-events: none;
  opacity: 0.7;
}

.element-hotspot .hotspot-link {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ---------- Resize Handles ---------- */
.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 2px solid #3b82f6;
  border-radius: 2px;
  z-index: 10;
  pointer-events: auto;
}

.resize-handle.handle-nw {
  top: -5px;
  left: -5px;
  cursor: nw-resize;
}

.resize-handle.handle-ne {
  top: -5px;
  right: -5px;
  cursor: ne-resize;
}

.resize-handle.handle-sw {
  bottom: -5px;
  left: -5px;
  cursor: sw-resize;
}

.resize-handle.handle-se {
  bottom: -5px;
  right: -5px;
  cursor: se-resize;
}

/* ---------- Rotation Handle ---------- */
.rotate-handle {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  background: #ffffff;
  border: 2px solid #3b82f6;
  border-radius: 50%;
  cursor: grab;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rotate-handle::after {
  content: '';
  position: absolute;
  bottom: -14px;
  width: 1px;
  height: 12px;
  background: #3b82f6;
}

.rotate-handle .material-symbols-rounded {
  font-size: 12px;
  color: #3b82f6;
}

/* ---------- Dialogs ---------- */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
}

.dialog {
  background: #ffffff;
  border-radius: 12px;
  padding: 28px 32px;
  min-width: 380px;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.dialog h3 {
  font-size: 17px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 20px;
}

.dialog-field {
  margin-bottom: 14px;
}

.dialog-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 5px;
}

.dialog-field input[type="text"],
.dialog-field input[type="url"],
.dialog-field input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: #334155;
  outline: none;
  transition: border-color 0.15s;
}

.dialog-field input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.dialog-field input[type="color"] {
  width: 48px;
  height: 36px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 3px;
  cursor: pointer;
}

.dialog-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.dialog-row .dialog-field {
  flex: 1;
  margin-bottom: 0;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.dialog-btn {
  padding: 8px 20px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  background: #ffffff;
  color: #475569;
  transition: background 0.12s;
}

.dialog-btn:hover {
  background: #f8fafc;
}

.dialog-btn-primary {
  background: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
}

.dialog-btn-primary:hover {
  background: #2563eb;
}

/* ---------- Scrollbar ---------- */
.canvas::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.canvas::-webkit-scrollbar-track {
  background: transparent;
}

.canvas::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.canvas::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ---------- Context Menu ---------- */
.context-menu {
  position: fixed;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 4px;
  min-width: 180px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  z-index: 20000;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font-family: inherit;
  color: #334155;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.context-menu-item:hover {
  background: #f1f5f9;
}

.context-menu-item.danger {
  color: #dc2626;
}

.context-menu-item.danger:hover {
  background: #fef2f2;
}

.context-menu-item .material-symbols-rounded {
  font-size: 18px;
}

.context-menu-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 4px 8px;
}

/* ---------- No Firebase Warning ---------- */
.no-firebase-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #92400e;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 10001;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  white-space: nowrap;
}
