* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f3f4f7;
  color: #222;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Barra superior */
.top-bar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid #eee;
  gap: 12px;
}

.logo {
  font-weight: 600;
  font-size: 18px;
}

.login-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-form input {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

.login-form button {
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  background: #222;
  color: #fff;
  cursor: pointer;
}

.login-form button:hover {
  opacity: 0.9;
}

.current-user {
  margin-left: auto;
  font-size: 14px;
  color: #555;
}

.hidden {
  display: none;
}

.new-window-btn {
  margin-left: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background: #f2f2f2;
  cursor: pointer;
}

.new-window-btn:hover {
  background: #e3e3e3;
}

.logout-btn {
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  background: #f2f2f2;
  cursor: pointer;
  font-size: 13px;
}

.logout-btn:hover {
  background: #e3e3e3;
}

/* Área com scroll (viewport) */
.desktop {
  flex: 1;
  position: relative;
  overflow: auto;
  background: #f3f4f7;
}

/* Canvas interno grande */
.desktop-space {
  position: relative;
  width: 3000px;
  height: 2000px;
}

.hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #aaa;
}

.password-prompt {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #444;
}

.password-prompt form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.password-prompt input {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

.password-prompt button {
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  background: #222;
  color: #fff;
  cursor: pointer;
}

/* Janela */
.window {
  position: absolute;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tema alternativo */
.window.theme-blue {
  background: #f6fbff;
}

/* Barra superior (drag) */
.window-drag-area {
  height: 26px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
  user-select: none;
}

/* Título na barra */
.window-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #444;
  padding-right: 8px;
  overflow: hidden;
  white-space: nowrap;
  cursor: default;
  position: relative;
}

/* Título simples (janela não colapsada) */
.window-title-text {
  display: inline-block;
}

/* Botões circulares */
.window-buttons {
  display: flex;
  gap: 6px;
}

.window-button {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  padding: 0;
}

.window-button.settings {
  background: #c0c0c0;
}

.window-button.close {
  background: #e05a5a;
}

/* Área de conteúdo */
.window-content {
  flex: 1;
  padding: 12px 14px 16px 14px;
  overflow: auto;
  font-size: 14px;
  background: inherit;
  padding-right: 18px;
}

/* Corpo editável (hitbox) */
.window-body {
  min-height: 100%;
  border-radius: 10px;
  padding: 6px 8px;
  outline: none;
  border: none;
  transition: background 0.15s ease;
}

/* Hitbox visível só quando mouse está em cima do conteúdo */
.window-body:hover {
  background: rgba(0, 0, 0, 0.035);
}

/* Links para outras páginas/subpáginas, criados via <<pagina>> ou [[subpagina]] */
.page-link {
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
}

.page-link:hover {
  opacity: 0.8;
}

/* E quando está em edição (foco / classe editing) */
.window.editing .window-body,
.window-body:focus {
  background: rgba(0, 0, 0, 0.05);
}

/* Scrollbar interna */
.window-content::-webkit-scrollbar {
  width: 6px;
}

.window-content::-webkit-scrollbar-track {
  background: transparent;
}

.window-content::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #d0d0d0;
}

/* Handles de resize (cantos inferiores) */
.window-resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  bottom: 4px;
  cursor: se-resize;
}

.window-resize-handle.left {
  left: 4px;
  cursor: sw-resize;
}

.window-resize-handle.right {
  right: 4px;
}

/* Sem o "L" desenhado */
.window-resize-handle::after {
  content: none;
}

/* Mini janela (colapsada) */
.window-collapsed {
  height: 32px !important;
}

/* Some conteúdo, botões, handles na mini janela */
.window-collapsed .window-content {
  display: none;
}

.window-collapsed .window-resize-handle {
  display: none;
}

.window-collapsed .window-buttons {
  display: none;
}

/* Marquee estilo Spotify para o título colapsado */
.window-collapsed .window-title {
  overflow: hidden;
  white-space: nowrap;
}

.window-collapsed .marquee-viewport {
  width: 100%;
  overflow: hidden;
}

.window-collapsed .marquee-track {
  display: inline-flex;
  flex-direction: row;
  will-change: transform;
  animation: marquee-loop var(--marquee-duration, 8s) linear infinite;
}

.marquee-item {
  flex-shrink: 0;
  padding-right: 40px;
}

/* A distância em px é controlada via --marquee-distance pelo JS */
@keyframes marquee-loop {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(var(--marquee-distance, -100%));
  }
}

/* Modal de configuração */
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.settings-panel {
  background: #fff;
  padding: 16px 20px;
  border-radius: 12px;
  min-width: 280px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.settings-panel h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

.settings-panel label {
  display: block;
  margin-bottom: 10px;
}

.settings-panel input[type="text"],
.settings-panel select {
  width: 100%;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.settings-panel .settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.settings-panel button {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}

.settings-save {
  background: #222;
  color: #fff;
}

.settings-cancel {
  background: #f2f2f2;
}

/* Classe usada pra desabilitar seleção de texto durante drag/resize/pan */
.no-select {
  user-select: none !important;
}
