/* Base Variables & Reset */
:root {
  --bg-dark: #0a0a0c;
  --bg-card: rgba(20, 20, 25, 0.6);
  --border-light: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --primary: #6366f1; /* Neon Violet */
  --primary-glow: rgba(99, 102, 241, 0.5);
  --success: #10b981; /* Emerald */
  --success-glow: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b; /* Amber */
  --warning-glow: rgba(245, 158, 11, 0.3);
  --danger: #ef4444; /* Rose */
  --danger-glow: rgba(239, 68, 68, 0.3);
  
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  outline: none;
}

button, a, .tool-btn, .tab-btn, .mode-btn, .scale-btn, .toggle-toolbar-btn, .toggle-header-btn {
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Background Radial Glows */
.blur-glow-1 {
  position: absolute;
  top: -10%;
  left: -10%;
  width: 50%;
  height: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  z-index: 0;
  pointer-events: none;
}

.blur-glow-2 {
  position: absolute;
  bottom: -10%;
  right: -10%;
  width: 60%;
  height: 60%;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.12) 0%, transparent 70%);
  z-index: 0;
  pointer-events: none;
}

#app {
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

/* Screen Transitions */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */
#login-screen.active {
  display: block !important; /* Override .screen flex to allow normal block scrolling */
  overflow-y: auto;
  padding: 40px 20px;
}

.login-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 460px;
  min-height: 100%;
  gap: 20px;
  margin: 0 auto;
}

.login-logo-outer {
  font-size: 4rem;
  font-family: var(--font-title);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 30px var(--primary-glow);
  margin-bottom: 5px;
  letter-spacing: -0.03em;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  width: 100%;
  padding: 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 
              0 0 80px rgba(99, 102, 241, 0.05);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-card h2 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

/* Forms */
#auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Custom icon input groups */
.input-group-custom {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.25s ease;
  width: 100%;
}

.input-group-custom:focus-within {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.input-prefix {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: rgba(255, 255, 255, 0.01);
  border-right: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.input-prefix .prefix-icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.input-group-custom input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 12px 16px;
}

.form-label-custom {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 2px;
  text-transform: none;
}

/* Side-by-side buttons */
.login-actions {
  display: flex;
  gap: 16px;
  width: 100%;
  margin-top: 8px;
}

.login-btn {
  flex: 1;
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 13px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.join-btn {
  background: #c2410c; /* Orange-red */
}

.join-btn:hover {
  background: #ea580c;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
}

.create-btn {
  background: #065f46; /* Dark Green */
}

.create-btn:hover {
  background: #047857;
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.25);
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.primary-btn:active {
  transform: translateY(1px);
}

.outline-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.outline-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Recent Rooms */
.recent-rooms {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 20px;
}

.recent-rooms h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-tag {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.recent-tag:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.empty-recent {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}


/* ==========================================================================
   WHITEBOARD BOARD SCREEN & WORKSPACE
   ========================================================================== */
#whiteboard-screen {
  flex-direction: column;
  position: relative;
}

/* Header */
.app-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: rgba(10, 10, 12, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 10;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed Header State */
.app-header.collapsed {
  top: 12px;
  left: 12px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  padding: 0 !important;
  justify-content: center;
  background: rgba(18, 18, 22, 0.85);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* Header Content Wrapper */
.header-content {
  display: flex;
  flex: 1;
  justify-content: space-between;
  align-items: center;
  opacity: 1;
  transition: opacity 0.2s ease, width 0.2s ease;
}

.app-header.collapsed .header-content {
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Toggle Header Button styling */
.toggle-header-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin-right: 12px;
  flex-shrink: 0;
}

.toggle-header-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

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

.app-header.collapsed .toggle-header-btn {
  margin: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 11px;
}

/* Icons showing based on collapsed state */
.app-header .icon-expand {
  display: none;
}
.app-header .icon-collapse {
  display: block;
}

.app-header.collapsed .icon-expand {
  display: block;
}
.app-header.collapsed .icon-collapse {
  display: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px; /* Shorter gap to shift room indicator to the left */
}
.header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
}

.icon-btn-text {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.icon-btn-text svg {
  width: 18px;
  height: 18px;
}

.icon-btn-text:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.room-indicator {
  display: flex;
  flex-direction: column;
}

.room-indicator .label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.room-indicator .value {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

/* Badges */
.badge {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap; /* Prevent badge text wrapping */
}

.badge-icon {
  width: 14px;
  height: 14px;
}

/* Sync badges */
.sync-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.sync-badge.synced {
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.05);
}

.sync-badge.synced .status-dot {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
}

.sync-badge.waiting {
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.05);
}

.sync-badge.waiting .status-dot {
  background-color: var(--warning);
  animation: pulse 1.5s infinite;
}

.sync-badge.error {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.05);
}

.sync-badge.error .status-dot {
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger-glow);
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 10px var(--warning-glow); }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.users-counter {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.users-counter svg {
  width: 16px;
  height: 16px;
}

/* Mode toggles */
.mode-toggles {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 3px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* WORKSPACE */
.workspace {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background-color: #0c0c0e;
  position: relative;
  z-index: 1;
  overflow: hidden; /* Hide scrollbars to allow clean vector scaling fitting the viewport */
}

/* The iPad 4:3 Whiteboard Container */
.whiteboard-container {
  position: relative;
  /* width and height are dynamically managed via JS (resizeWhiteboard) to maintain strict 4:3 ratio and min-size */
  background-color: #16161a;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 
              0 0 50px rgba(99, 102, 241, 0.05);
  overflow: hidden;
  flex-shrink: 0;
}

#whiteboard-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  background: transparent;
}

/* Canvas Overlay for text blocks */
#canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let canvas capture draw interactions */
  z-index: 2;
}

/* Text Element Styling inside canvas */
.text-element-container {
  position: absolute;
  transform: translate(-50%, -50%); /* Center on coordinate */
  pointer-events: auto;
  cursor: move;
  user-select: none;
}

.text-element {
  background: rgba(20, 20, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-element .delete-btn {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  opacity: 0.5;
  transition: opacity 0.2s ease;
  padding: 2px;
  border-radius: 4px;
}

.text-element .delete-btn:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.15);
}

.text-element .delete-btn svg {
  width: 14px;
  height: 14px;
}

/* FLOATING TOOLBAR */
.toolbar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 18, 22, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  padding: 10px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 
              0 0 30px rgba(99, 102, 241, 0.08);
  z-index: 10;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.toolbar.hidden {
  bottom: -100px;
  opacity: 0;
}

/* Collapsed Toolbar State */
.toolbar.collapsed {
  bottom: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

/* Toolbar Content Wrapper */
.toolbar-content {
  display: flex;
  align-items: center;
  gap: 16px;
  opacity: 1;
  transition: opacity 0.2s ease, width 0.2s ease;
  overflow: hidden;
}

.toolbar.collapsed .toolbar-content {
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* Toggle Toolbar Button styling */
.toggle-toolbar-btn {
  position: absolute;
  bottom: -14px; /* project slightly below bottom border */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 18, 22, 0.95);
  border: 1px solid var(--border-light);
  border-top-color: transparent; /* starts flat top in maximized */
  border-radius: 0 0 8px 8px; /* rounded bottom corners */
  width: 48px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 15;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.35s ease,
              bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1), height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              border-radius 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-toolbar-btn:hover {
  color: var(--text-primary);
  height: 16px;
  bottom: -14px;
}

.toggle-toolbar-btn svg {
  width: 16px;
  height: 16px;
}

.toolbar.collapsed .toggle-toolbar-btn {
  bottom: 0;
  height: 14px;
  border-radius: 8px 8px 0 0;
  border-top-color: var(--border-light);
  border-bottom-color: transparent;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.toolbar.collapsed .toggle-toolbar-btn:hover {
  height: 16px;
  bottom: 0;
}

/* Icons showing based on collapsed state */
.toolbar .icon-expand {
  display: none;
}
.toolbar .icon-collapse {
  display: block;
}

.toolbar.collapsed .icon-expand {
  display: block;
}
.toolbar.collapsed .icon-collapse {
  display: none;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
}

.tool-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.tool-btn.disabled, .tool-btn[disabled] {
  opacity: 0.25;
  pointer-events: none;
  cursor: not-allowed;
}

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

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.tool-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 15px var(--primary-glow);
}

.tool-btn.danger:hover {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 15px var(--danger-glow);
}

/* Color palettes & sizes */
.color-palette {
  display: flex;
  gap: 6px;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.3);
}

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

.color-swatch.active {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

/* Range Slider */
.brush-size-container {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 6px;
}

.slider-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

#brush-size {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
}

#brush-size::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  cursor: pointer;
  transition: transform 0.1s;
}

#brush-size::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#brush-size-val {
  font-size: 0.8rem;
  color: var(--text-primary);
  min-width: 34px;
}


/* ==========================================================================
   MODALS & DIALOGS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 5, 8, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background: #141418;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 36px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8);
  text-align: center;
  animation: modalEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalEnter {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-card.compact {
  max-width: 400px;
  padding: 28px;
  text-align: left;
}

.modal-card h2 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  margin: 0 auto 20px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.1);
}

.modal-icon svg {
  width: 32px;
  height: 32px;
}

.modal-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 8px;
}

.modal-time {
  font-size: 0.8rem;
  color: var(--primary);
  margin-bottom: 28px;
}

.modal-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-btn {
  text-align: left;
  padding: 14px 20px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-btn.primary {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.25);
  color: var(--text-primary);
}

.modal-btn.primary:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.modal-btn.outline {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}

.modal-btn.outline:hover {
  background: rgba(255, 255, 255, 0.06);
}

.modal-btn.danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--text-primary);
}

.modal-btn.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.modal-btn .btn-title {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.95rem;
}

.modal-btn.primary:hover .btn-subtitle,
.modal-btn.danger:hover .btn-subtitle {
  color: rgba(255, 255, 255, 0.8);
}

.modal-btn .btn-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Modal Actions for text */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

textarea#text-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 12px 16px;
  outline: none;
  transition: all 0.25s ease;
  resize: vertical;
  min-height: 80px;
}

textarea#text-input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.modal-actions button {
  padding: 10px 18px;
  font-size: 0.9rem;
}


/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(18, 18, 22, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-light);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(20px);
  opacity: 0;
  animation: toastEnter 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.3s ease;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.3);
}

.toast.success::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.toast.info {
  border-color: rgba(99, 102, 241, 0.3);
}

.toast.info::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 6px var(--primary);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.3);
}

.toast.error::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}

@keyframes toastEnter {
  to { transform: translateY(0); opacity: 1; }
}

/* Hide admin section when viewing only */
body.view-mode .admin-divider,
body.view-mode .admin-section,
body.view-mode .options-section,
body.view-mode .toolbar {
  display: none !important;
}

body.view-mode #whiteboard-canvas {
  cursor: default;
}

/* ==========================================================================
   ONLINE USERS TOOLTIP & UI SCALE DROPDOWN
   ========================================================================== */

/* Active Users Tooltip */
.users-counter {
  position: relative; /* relative anchor for absolute tooltip */
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.users-counter:hover {
  background: rgba(255, 255, 255, 0.05);
}

.users-tooltip {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: rgba(15, 15, 20, 0.95);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 150px;
  max-width: 250px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px);
  transition: all 0.2s ease;
  overflow-y: auto;
}

.users-counter:hover .users-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.user-row {
  font-size: 0.85rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.user-row::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--success-glow);
}

/* UI Scale Badge Button */
.scale-btn {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.2s ease;
  font-family: inherit;
  color: inherit;
}

.scale-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.scale-btn:active {
  transform: translateY(1px);
}

/* ==========================================================================
   UI SCALING OVERRIDES
   ========================================================================== */

/* Small UI scale overrides */
body.ui-scale-small .app-header {
  height: 50px;
  padding: 0 12px;
}
body.ui-scale-small .app-header.collapsed {
  width: 36px;
  height: 36px;
  top: 8px;
  left: 8px;
}
body.ui-scale-small .toggle-header-btn {
  width: 28px;
  height: 28px;
  margin-right: 8px;
}
body.ui-scale-small .toggle-header-btn svg {
  width: 16px;
  height: 16px;
}
body.ui-scale-small .icon-btn-text {
  font-size: 0.8rem;
  padding: 6px 10px;
}
body.ui-scale-small .icon-btn-text svg {
  width: 14px;
  height: 14px;
}
body.ui-scale-small .room-indicator .value {
  font-size: 0.9rem;
}
body.ui-scale-small .badge {
  font-size: 0.7rem;
  padding: 4px 8px;
}
body.ui-scale-small .dropdown-trigger-btn {
  padding: 4px 8px;
}
body.ui-scale-small .badge-icon {
  width: 12px;
  height: 12px;
}
body.ui-scale-small .users-counter {
  font-size: 0.75rem;
}
body.ui-scale-small .users-counter svg {
  width: 14px;
  height: 14px;
}
body.ui-scale-small .mode-btn {
  font-size: 0.7rem;
  padding: 4px 8px;
}
body.ui-scale-small .toolbar {
  padding: 8px 12px;
  gap: 12px;
  bottom: 12px;
}
body.ui-scale-small .tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
body.ui-scale-small .tool-btn svg {
  width: 16px;
  height: 16px;
}
body.ui-scale-small .color-swatch {
  width: 18px;
  height: 18px;
}
body.ui-scale-small #brush-size {
  width: 70px;
}
body.ui-scale-small .slider-label {
  font-size: 0.65rem;
}
body.ui-scale-small #brush-size-val {
  font-size: 0.7rem;
}
body.ui-scale-small .toolbar.collapsed {
  bottom: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}
body.ui-scale-small .toggle-toolbar-btn {
  bottom: -12px;
  height: 12px;
  border-radius: 0 0 6px 6px;
}
body.ui-scale-small .toggle-toolbar-btn:hover {
  height: 14px;
  bottom: -12px;
}
body.ui-scale-small .toolbar.collapsed .toggle-toolbar-btn {
  bottom: 0;
  height: 12px;
  border-radius: 6px 6px 0 0;
  border-top-color: var(--border-light);
  border-bottom-color: transparent;
}
body.ui-scale-small .toolbar.collapsed .toggle-toolbar-btn:hover {
  height: 14px;
  bottom: 0;
}

/* Large UI scale overrides */
body.ui-scale-large .app-header {
  height: 75px;
  padding: 0 32px;
}
body.ui-scale-large .app-header.collapsed {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  top: 16px;
  left: 16px;
}
body.ui-scale-large .toggle-header-btn {
  width: 44px;
  height: 44px;
  margin-right: 16px;
}
body.ui-scale-large .toggle-header-btn svg {
  width: 24px;
  height: 24px;
}
body.ui-scale-large .icon-btn-text {
  font-size: 1rem;
  padding: 10px 16px;
}
body.ui-scale-large .icon-btn-text svg {
  width: 22px;
  height: 22px;
}
body.ui-scale-large .room-indicator .value {
  font-size: 1.3rem;
}
body.ui-scale-large .badge {
  font-size: 0.95rem;
  padding: 8px 16px;
}
body.ui-scale-large .dropdown-trigger-btn {
  padding: 8px 16px;
}
body.ui-scale-large .badge-icon {
  width: 18px;
  height: 18px;
}
body.ui-scale-large .users-counter {
  font-size: 1rem;
}
body.ui-scale-large .users-counter svg {
  width: 20px;
  height: 20px;
}
body.ui-scale-large .mode-btn {
  font-size: 0.9rem;
  padding: 8px 16px;
}
body.ui-scale-large .header-left {
  gap: 8px; /* Tighter gap in Large UI scale to shift room indicator left */
}
body.ui-scale-large .header-center,
body.ui-scale-large .header-right {
  gap: 12px;
}

body.ui-scale-large .toolbar {
  padding: 10px 14px;
  gap: 12px;
  bottom: 18px;
  border-radius: 24px;
}
body.ui-scale-large .tool-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}
body.ui-scale-large .tool-btn svg {
  width: 22px;
  height: 22px;
}
body.ui-scale-large .color-swatch {
  width: 24px;
  height: 24px;
}
body.ui-scale-large #brush-size {
  width: 80px;
}
body.ui-scale-large .slider-label {
  font-size: 0.85rem;
}
body.ui-scale-large #brush-size-val {
  font-size: 0.9rem;
}
body.ui-scale-large .toolbar.collapsed {
  bottom: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}
body.ui-scale-large .toggle-toolbar-btn {
  bottom: -18px;
  height: 18px;
  border-radius: 0 0 10px 10px;
}
body.ui-scale-large .toggle-toolbar-btn:hover {
  height: 20px;
  bottom: -18px;
}
body.ui-scale-large .toolbar.collapsed .toggle-toolbar-btn {
  bottom: 0;
  height: 18px;
  border-radius: 10px 10px 0 0;
  border-top-color: var(--border-light);
  border-bottom-color: transparent;
}
body.ui-scale-large .toolbar.collapsed .toggle-toolbar-btn:hover {
  height: 20px;
  bottom: 0;
}

/* Conflict History List Styles */
.conflict-history-list {
  margin: 20px 0;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 16px;
  text-align: left;
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conflict-status-banner {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.conflict-status-banner strong {
  color: var(--text-primary);
}

.conflict-status-banner .danger-text {
  color: var(--danger);
}

.conflict-status-banner .warning-text {
  color: var(--warning);
}

.history-items-wrapper {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 12px;
}

/* Timeline vertical line */
.history-items-wrapper::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 17px;
  width: 2px;
  background: rgba(255, 255, 255, 0.08);
}

.history-item {
  display: flex;
  align-items: center;
  position: relative;
  padding: 10px 12px 10px 24px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  gap: 12px;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.history-item.latest {
  background: rgba(99, 102, 241, 0.05);
}

.history-item.user-current {
  background: rgba(16, 185, 129, 0.05);
}

.history-dot {
  position: absolute;
  left: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  border: 2px solid var(--bg-dark);
  z-index: 1;
}

.history-item.latest .history-dot {
  background: var(--primary);
  box-shadow: 0 0 6px var(--primary);
}

.history-item.user-current .history-dot {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.history-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-updater {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.history-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.history-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.history-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.history-badge.latest-badge {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.history-badge.user-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* MODAL OVERLAY */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform: translateY(0);
  transition: transform 0.3s ease;
}
.modal-overlay.hidden .modal-card {
  transform: translateY(20px);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin: 0;
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* COMPLIANCE FOOTER & MODAL */
.legal-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.8rem;
}
.legal-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}
.legal-footer a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* CONSENT BANNER */
.consent-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 650px;
  background: var(--surface-light);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10000;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.consent-banner.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
}

.consent-banner strong {
  color: var(--text-primary);
}

.consent-banner a {
  color: var(--accent);
  text-decoration: none;
}

.consent-banner a:hover {
  text-decoration: underline;
}

.consent-actions {
  display: flex;
  justify-content: flex-end;
}

.consent-actions button {
  padding: 8px 16px;
  font-size: 0.85rem;
  height: auto;
  border-radius: 6px;
}

/* LEGAL MODAL SPECIFICS */
.legal-text {
  text-align: left;
}

.legal-text h3 {
  color: var(--text-primary);
  margin-top: 24px;
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.legal-text h3:first-child {
  margin-top: 0;
}

.legal-text p, .legal-text ul {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 12px;
}

.legal-text ul {
  padding-left: 20px;
}

.legal-text li {
  margin-bottom: 8px;
}

/* Mobile Small Height Adjustments */
@media screen and (max-height: 750px) {
  #login-screen.active {
    padding: 15px 15px !important; 
    overflow: hidden !important;
  }
  .login-wrapper {
    gap: 12px;
  }
  .login-logo-outer {
    font-size: 2.8rem;
    margin-bottom: 0;
  }
  .login-card {
    padding: 20px 24px;
    gap: 12px;
  }
  .login-card h2 {
    font-size: 1.3rem;
  }
  .form-group {
    gap: 6px;
  }
  .input-field {
    padding: 10px 14px 10px 42px;
    height: 42px;
  }
  .input-icon {
    top: 12px;
  }
  .login-btn {
    height: 44px;
    font-size: 0.95rem;
  }
  .recent-rooms {
    padding-top: 12px;
    margin-top: 0;
  }
  .recent-rooms h3 {
    margin-bottom: 8px;
  }
  .recent-tag {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  .legal-footer {
    margin-top: 10px;
  }
}

@media screen and (max-height: 600px) {
  .login-logo-outer { font-size: 2.2rem; }
  .login-card { padding: 15px 20px; gap: 8px; }
  .input-field { height: 40px; padding: 8px 12px 8px 38px; font-size: 0.85rem; }
  .input-icon { top: 11px; }
  .login-btn { height: 40px; }
  .recent-rooms { padding-top: 8px; }
  .legal-footer { margin-top: 5px; font-size: 0.75rem; }
}
