* {
  box-sizing: border-box;
}

body {
  margin: 0;

  font-family: Arial, sans-serif;

  background: #222;

  color: white;
}

/* =========================
   TOOLBAR
   ========================= */

.toolbar {
  min-height: 60px;

  background: #333;

  display: flex;

  align-items: center;

  gap: 10px;

  padding: 10px;

  flex-wrap: wrap;
}

button,
.upload-button {
  background: #555;

  color: white;

  border: none;

  padding: 10px 15px;

  border-radius: 6px;

  cursor: pointer;

  font-size: 14px;
}

button:hover,
.upload-button:hover {
  background: #666;
}

.upload-button input {
  display: none;
}

/* =========================
   SETTINGS
   ========================= */

.settings {
  display: flex;

  align-items: center;

  gap: 10px;

  margin-left: 10px;

  flex-wrap: wrap;
}

.settings label {
  display: flex;

  align-items: center;

  gap: 5px;

  font-size: 14px;
}

.settings input[type="text"] {
  width: 160px;

  padding: 6px;
}

.settings input[type="number"] {
  width: 70px;

  padding: 6px;
}

.settings input[type="color"] {
  width: 40px;

  height: 30px;

  padding: 0;

  border: none;

  cursor: pointer;
}

.settings select {
  padding: 6px;
}

/* =========================
   WORKSPACE
   ========================= */

#workspace {
  width: 100%;

  padding: 30px;

  overflow: auto;
}

#canvas {
  position: relative;

  width: fit-content;

  margin: 0 auto;
}

#bracketImage {
  display: block;

  max-width: none;

  user-select: none;
}

/* =========================
   SLOTS
   ========================= */

.slot {
  position: absolute;

  cursor: move;

  user-select: none;

  padding: 4px 8px;

  font-size: 24px;

  font-weight: bold;

  color: white;

  background: rgba(0, 0, 0, 0.45);

  border: 2px dashed transparent;

  width: 200px;

  height: 50px;

  white-space: normal;

  overflow-wrap: break-word;

  word-wrap: break-word;

  overflow: hidden;

  line-height: 1.1;

  text-align: center;

  display: flex;

  align-items: center;

  justify-content: center;
}

.slot.selected {
  border-color: #00aaff;

  background: rgba(0, 100, 255, 0.25);
}

/* =========================
   LINK PANEL
   ========================= */

#linkPanel {
  position: fixed;

  right: 20px;

  top: 80px;

  width: 250px;

  padding: 15px;

  background: #333;

  border-radius: 8px;

  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);

  z-index: 1000;
}

#linkPanel strong {
  display: block;

  margin-bottom: 10px;

  font-size: 18px;
}

#linkPanel label {
  display: block;

  margin-top: 10px;
}

#linkTarget {
  width: 100%;

  margin-top: 5px;

  padding: 6px;
}

#linkPanel button {
  margin-top: 10px;

  width: 100%;
}

#currentLinks {
  margin-top: 15px;

  padding-top: 10px;

  border-top: 1px solid #555;

  font-size: 14px;
}

.link-item {
  display: flex;

  justify-content: space-between;

  align-items: center;

  margin-top: 6px;

  padding: 5px;

  background: #444;

  border-radius: 4px;
}

.link-item button {
  width: auto;

  margin: 0;

  padding: 3px 7px;

  font-size: 12px;
}

/* =========================
   ADVANCE MODE
   ========================= */

#advanceMode {
  display: none;

  position: fixed;

  left: 50%;

  bottom: 25px;

  transform: translateX(-50%);

  width: 350px;

  padding: 15px;

  background: #333;

  border: 2px solid #00aaff;

  border-radius: 8px;

  text-align: center;

  z-index: 2000;

  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#advanceMode strong {
  font-size: 18px;
}

#advanceMode p {
  margin: 10px 0;
}

#advanceMode button {
  width: 100%;
}

/* =========================
   ADVANCE DESTINATIONS
   ========================= */

.slot.advance-target {
  border-color: #00ff88;

  background: rgba(0, 255, 136, 0.25);

  cursor: pointer;

  animation: targetPulse 1s infinite alternate;
}

@keyframes targetPulse {
  from {
    box-shadow: 0 0 5px rgba(0, 255, 136, 0.3);
  }

  to {
    box-shadow: 0 0 18px rgba(0, 255, 136, 0.8);
  }
}

/* =========================
   LOCKED SLOTS
   ========================= */

.slot.locked {
  cursor: default;
}

/* =========================
   PUBLIC VIEWER
   ========================= */

#viewerWorkspace {
  width: 100vw;

  min-height: 100vh;

  overflow: auto;

  display: flex;

  justify-content: center;

  align-items: flex-start;

  padding: 30px;
}

#viewerCanvas {
  position: relative;

  width: fit-content;

  height: fit-content;
}

#viewerBracketImage {
  display: block;

  max-width: none;

  user-select: none;
}

.viewer-slot {
  position: absolute;

  padding: 4px 8px;

  font-weight: bold;

  white-space: normal;

  overflow-wrap: break-word;

  word-wrap: break-word;

  overflow: hidden;

  line-height: 1.1;

  display: flex;

  align-items: center;

  justify-content: center;

  background: transparent;

  border: none;

  cursor: default;

  user-select: none;
}

/* =========================
   LOGIN SCREEN
   ========================= */

#loginScreen {
  position: fixed;

  inset: 0;

  z-index: 99999;

  display: flex;

  justify-content: center;

  align-items: center;

  background: #1e1e1e;
}

#loginBox {
  width: 320px;

  padding: 30px;

  background: #2b2b2b;

  border-radius: 10px;

  text-align: center;

  box-sizing: border-box;
}

#loginBox h2 {
  margin-top: 0;

  color: white;
}

#loginBox input {
  width: 100%;

  box-sizing: border-box;

  margin-bottom: 12px;

  padding: 10px;

  border: none;

  border-radius: 5px;
}

#loginButton {
  width: 100%;

  padding: 10px;

  border: none;

  border-radius: 5px;

  cursor: pointer;
}

#loginMessage {
  color: #ff6b6b;

  min-height: 20px;
}

/* =========================
   PUBLISH STATUS
   ========================= */

#publishStatus {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
  font-size: 14px;
}

#publishStatusText {
  font-weight: bold;
}

#publishLastTime {
  font-size: 12px;
  opacity: 0.7;
}

#publishCountdown {
  font-size: 12px;
  opacity: 0.8;
}

/* =========================
   CONNECTION STATUS
   ========================= */

#connectionStatus {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 8px;
}

#connectionStatusDot {
  font-size: 10px;
}

#connectionStatusText {
  font-weight: 500;
}
