/* =========================================================
   style.css — Collaborative Whiteboard
   ========================================================= */

/* ---- Reset / Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: sans-serif;
  background: #1a1a2e;
  color: #eee;
}

a {
  color: #4ecca3;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
}

/* =========================================================
   INDEX PAGE (board list / login)
   ========================================================= */

body.index-page {
  overflow: auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.index-header {
  width: 100%;
  background: #16213e;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #0f3460;
}

.index-header h1 {
  margin: 0;
  font-size: 1.4rem;
  color: #4ecca3;
  letter-spacing: 0.05em;
}

.index-main {
  width: 100%;
  max-width: 900px;
  padding: 32px 24px;
  flex: 1;
}

/* ---- Login section ---- */
.login-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 0;
}

.login-section p {
  margin: 0;
  color: #aaa;
  font-size: 0.95rem;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: #fff;
  color: #333;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: box-shadow 0.2s;
  border: none;
  text-decoration: none;
}

.btn-google:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  text-decoration: none;
}

.btn-google svg {
  width: 20px;
  height: 20px;
}

/* ---- Board list section ---- */
.boards-section {
  display: none; /* shown by JS after login check */
}

.boards-section.visible {
  display: block;
}

.boards-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.boards-toolbar h2 {
  margin: 0;
  font-size: 1.1rem;
  color: #eee;
}

.btn-new-board {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: #e94560;
  color: #fff;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}

.btn-new-board:hover {
  background: #c73652;
}

.btn-new-board:active {
  transform: scale(0.97);
}

/* ---- Board cards ---- */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.board-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.board-card:hover {
  border-color: #4ecca3;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.board-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-card-meta {
  font-size: 0.75rem;
  color: #888;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.board-empty {
  color: #666;
  font-size: 0.9rem;
  padding: 32px 0;
  text-align: center;
}

/* ---- User info bar ---- */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #aaa;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #0f3460;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #4ecca3;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-logout {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid #444;
  color: #aaa;
  border-radius: 6px;
  font-size: 0.8rem;
  transition: border-color 0.2s, color 0.2s;
}

.btn-logout:hover {
  border-color: #e94560;
  color: #e94560;
}

/* =========================================================
   BOARD PAGE layout
   ========================================================= */

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 50px;
  height: 100vh;
  background: #16213e;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  z-index: 10;
  border-right: 1px solid #0f3460;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ---- Canvas ---- */
#whiteboard {
  position: fixed;
  left: 50px;
  top: 0;
  touch-action: none;
  cursor: crosshair;
  display: block;
  background: #1a1a2e;
}

/* ---- Tool buttons ---- */
.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  border: 1px solid transparent;
}

.tool-btn:hover {
  background: #0f3460;
  color: #eee;
}

.tool-btn.active {
  background: #e94560;
  color: #fff;
  border-color: #e94560;
}

.tool-btn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* ---- Sidebar divider ---- */
.sidebar-divider {
  width: 30px;
  height: 1px;
  background: #0f3460;
  flex-shrink: 0;
}

/* ---- Color palette ---- */
.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.selected {
  border-color: #e94560;
}

/* ---- Width selector ---- */
.width-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  border: 1px solid transparent;
}

.width-btn:hover {
  background: #0f3460;
}

.width-btn.selected {
  background: #0f3460;
  border-color: #4ecca3;
}

.width-dot {
  background: #eee;
  border-radius: 50%;
}

/* ---- Gear / settings button at bottom ---- */
.sidebar-spacer {
  flex: 1;
}

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

#connection-status {
  position: fixed;
  top: 10px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: #aaa;
  z-index: 20;
  pointer-events: none;
  user-select: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

#connection-status.connected .status-dot    { background: #4ecca3; }
#connection-status.reconnecting .status-dot { background: #f9d923; }
#connection-status.offline .status-dot      { background: #e94560; }

#connection-status.connected .status-label    { color: #4ecca3; }
#connection-status.reconnecting .status-label { color: #f9d923; }
#connection-status.offline .status-label      { color: #e94560; }

/* =========================================================
   REMOTE CURSOR LABELS
   ========================================================= */

.cursor-label {
  position: fixed;
  pointer-events: none;
  font-size: 0.7rem;
  color: #fff;
  background: rgba(0,0,0,0.65);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 15;
  transform: translate(10px, 10px);
}

/* =========================================================
   NICKNAME DIALOG (invite guest)
   ========================================================= */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.dialog-overlay.hidden {
  display: none;
}

.dialog-box {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 14px;
  padding: 32px 28px;
  min-width: 300px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

.dialog-box h2 {
  margin: 0;
  font-size: 1.1rem;
  color: #eee;
}

.dialog-box p {
  margin: 0;
  font-size: 0.85rem;
  color: #aaa;
}

.dialog-box input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 8px;
  color: #eee;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.dialog-box input[type="text"]:focus {
  border-color: #4ecca3;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-primary {
  padding: 9px 20px;
  background: #e94560;
  color: #fff;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #c73652;
}

.btn-secondary {
  padding: 9px 20px;
  background: transparent;
  color: #aaa;
  border: 1px solid #444;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s;
}

.btn-secondary:hover {
  border-color: #4ecca3;
  color: #4ecca3;
}

/* =========================================================
   MANAGEMENT PANEL (slide-in from right)
   ========================================================= */

#mgmt-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: #16213e;
  border-left: 1px solid #0f3460;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}

#mgmt-panel.open {
  transform: translateX(0);
}

.mgmt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #0f3460;
  position: sticky;
  top: 0;
  background: #16213e;
  z-index: 1;
}

.mgmt-header h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #eee;
}

.mgmt-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  color: #aaa;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.mgmt-close:hover {
  background: #e94560;
  color: #fff;
}

.mgmt-section {
  padding: 16px 18px;
  border-bottom: 1px solid #0f3460;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mgmt-section h4 {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
}

/* Invite list */
.invite-item {
  background: #0f3460;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.invite-item-url {
  font-size: 0.7rem;
  color: #aaa;
  word-break: break-all;
}

.invite-item-meta {
  font-size: 0.7rem;
  color: #666;
}

.invite-item-actions {
  display: flex;
  gap: 6px;
}

.btn-copy, .btn-revoke {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-copy {
  background: #4ecca3;
  color: #1a1a2e;
}

.btn-copy:hover {
  background: #3ab891;
}

.btn-revoke {
  background: transparent;
  border: 1px solid #e94560;
  color: #e94560;
}

.btn-revoke:hover {
  background: #e94560;
  color: #fff;
}

/* Generate invite row */
.invite-generate {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invite-generate select {
  flex: 1;
  padding: 7px 10px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 7px;
  color: #eee;
  font-size: 0.85rem;
  outline: none;
}

.invite-generate select:focus {
  border-color: #4ecca3;
}

/* Participant list */
.participant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f3460;
  border-radius: 8px;
  padding: 8px 12px;
}

.participant-name {
  font-size: 0.85rem;
  color: #eee;
}

.participant-role {
  font-size: 0.7rem;
  color: #666;
}

.btn-block {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid #e94560;
  color: #e94560;
  transition: background 0.15s;
}

.btn-block:hover {
  background: #e94560;
  color: #fff;
}

.participants-empty {
  font-size: 0.8rem;
  color: #555;
}

/* =========================================================
   TOAST NOTIFICATIONS
   ========================================================= */

#notification-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.notification {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #fff;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: toast-in 0.2s ease, toast-out 0.3s ease 2.7s forwards;
  pointer-events: auto;
}

.notification.error {
  background: #3d1a24;
  border-color: #e94560;
}

.notification.success {
  background: #0d3028;
  border-color: #4ecca3;
}

.notification.warning {
  background: #3d3110;
  border-color: #f9d923;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* =========================================================
   RESPONSIVE — tablet (thumb-reachable sidebar)
   ========================================================= */

@media (max-width: 768px) {
  .sidebar {
    width: 50px; /* keep same for now — thumb-reachable as-is */
    padding: 10px 0;
    gap: 6px;
  }

  .tool-btn, .width-btn {
    width: 38px;
    height: 38px;
  }

  #mgmt-panel {
    width: 280px;
  }
}

/* =========================================================
   LOADING SPINNER (used on index page while fetching)
   ========================================================= */

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #0f3460;
  border-top-color: #4ecca3;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 32px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
