/* public/css/style.css */

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

:root {
  --bg:         #1a1a2e;
  --surface:    #16213e;
  --surface2:   #0f3460;
  --accent:     #e94560;
  --accent2:    #f5a623;
  --text:       #e0e0e0;
  --text-dim:   #9a9ab0;
  --border:     #2a2a4a;
  --success:    #4caf50;
  --warning:    #ff9800;
  --radius:     8px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Layout ────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

#header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

#header .logo span { color: var(--accent); }

.header-stats {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.stat-item strong { color: var(--text); }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
}

#user-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

#user-badge strong { color: var(--accent2); }

/* ── Main ────────────────────────────────────*/
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Canvas Viewport ─────────────────────── */
#canvas-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: crosshair;
  background:
    repeating-conic-gradient(#1e1e3a 0% 25%, #1a1a35 0% 50%)
    0 0 / 20px 20px;
}

#canvas-wrapper {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Crosshair overlay ───────────────────── */
#crosshair {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
  display: none;
}

/* ── Sidebar ─────────────────────────────── */
#sidebar {
  width: 220px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 50;
}

.panel {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
  font-weight: 600;
}

/* ── Color Palette ───────────────────────── */
#palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
  outline: none;
}

.color-swatch:hover {
  transform: scale(1.15);
  border-color: rgba(255,255,255,0.5);
}

.color-swatch.selected {
  border-color: #fff;
  transform: scale(1.2);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
}

/* ── Cooldown / Place ────────────────────── */
#place-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#selected-color-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

#color-preview-box {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}

#color-preview-label { color: var(--text-dim); font-size: 0.78rem; }

#btn-place {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

#btn-place:hover:not(:disabled) { background: #c73652; }
#btn-place:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cooldown bar ────────────────────────── */
#cooldown-bar-wrap {
  display: none;
}

#cooldown-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

#cooldown-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

#cooldown-bar-fill {
  height: 100%;
  background: var(--accent2);
  border-radius: 3px;
  transition: width 0.1s linear;
  width: 100%;
}

/* ── Coordinates ─────────────────────────── */
#coords-display {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: monospace;
}

#coords-display span { color: var(--text); }

/* ── Zoom controls ───────────────────────── */
.zoom-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.zoom-btn {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.zoom-btn:hover { background: var(--border); }

#zoom-level {
  font-size: 0.78rem;
  color: var(--text-dim);
  min-width: 36px;
  text-align: center;
}

/* ── Activity log ────────────────────────── */
#activity-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
}

.activity-item {
  font-size: 0.72rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  animation: fadeIn 0.3s ease;
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }

/* ── Toast notifications ─────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease forwards;
  white-space: nowrap;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--accent);  color: var(--accent);  }
.toast.warning { border-color: var(--warning); color: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Connection status ───────────────────── */
#connection-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.status-dot.disconnected { background: var(--accent); }
.status-dot.connecting   { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100%{ opacity:1; } 50%{ opacity:0.4; } }

/* ── Mobile toolbar (bottom) ─────────────── */
#mobile-toolbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px env(safe-area-inset-bottom);
  z-index: 200;
  flex-direction: column;
  gap: 10px;
}

#mobile-palette {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
#mobile-palette::-webkit-scrollbar { display: none; }

.mobile-swatch {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
}
.mobile-swatch.selected {
  border-color: #fff;
  transform: scale(1.15);
}

#mobile-bottom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#btn-place-mobile {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
#btn-place-mobile:disabled { opacity: 0.5; cursor: not-allowed; }

#mobile-coords {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: monospace;
  white-space: nowrap;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 768px) {
  #sidebar { display: none; }
  #mobile-toolbar { display: flex; }
  #canvas-viewport { padding-bottom: 110px; }
  .header-stats { display: none; }
}

@media (max-width: 480px) {
  #header .logo { font-size: 1rem; }
  #header { height: 46px; }
}

/* ── Scrollbars ──────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
