/* ============================================================================
   Unified Collection Editor - Canvas-based layout
   ============================================================================ */

.collection-unified-editor {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px);
}

/* ============================================================================
   Main Layout
   ============================================================================ */

.editor-main-layout {
  display: flex;
  position: relative;
}

/* Override sidebar sticky positioning for unified editor */
.collection-unified-editor .canva-sidebar {
  position: relative;
  height: auto;
  min-height: 100%;
}

/* Subtler sidebar borders - override base canva-sidebar.css */
.collection-unified-editor .canva-sidebar-rail {
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.collection-unified-editor .canva-sidebar-panel {
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  background: transparent;
}

.collection-unified-editor .canva-rail-btn {
  border-radius: 0;
}

/* Login to Save button - normalize button element to match anchor styling */
.collection-unified-editor button.login-to-save-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  margin: 0;
  box-sizing: border-box;
}

/* ============================================================================
   Canvas Area
   ============================================================================ */

.collection-unified-editor .canvas-main-area {
  flex: 1;
  position: relative;
  background: transparent;
}

.collection-unified-editor .canvas-scroll-container {
  width: 100%;
  padding: 40px 40px 60px 40px;
  /* Center content horizontally */
  display: flex;
  justify-content: center;
}

.collection-unified-editor .canvas-wrapper {
  position: relative;
  flex-shrink: 0;
  /* Minimalist grid border style */
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  transform-origin: top center;
}

.collection-unified-editor .canvas {
  position: relative;
  /* Match portfolio page content width: max-width 1400px - 64px padding = 1336px */
  width: 1336px;
  height: 900px;
  min-height: 900px;
}

.collection-unified-editor .canvas-grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  opacity: 0.3;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 20px 20px;
}

.collection-unified-editor .canvas-empty-state {
  position: absolute;
  left: 50%;
  top: 80px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
  text-align: center;
}

.collection-unified-editor .canvas-empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.collection-unified-editor .canvas-empty-state p {
  font-size: 14px;
  margin: 0;
}

.collection-unified-editor .canvas.has-elements .canvas-empty-state {
  display: none;
}

/* ============================================================================
   Canvas Elements
   ============================================================================ */

.canvas-element {
  position: absolute;
  cursor: move;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.15s ease;
}

.canvas-element:hover {
  border-color: rgba(0, 168, 255, 0.3);
}

.canvas-element.selected {
  border-color: #00a8ff;
}

.canvas-element.dragging {
  opacity: 0.8;
  z-index: 1000;
  /* Allow mouse events to pass through to document during drag */
  pointer-events: none;
}

.canvas-element.dragging *,
.canvas-element.resizing * {
  /* Ensure all children also don't capture events during drag/resize */
  pointer-events: none !important;
}

.canvas-element.resizing {
  /* Allow mouse events to pass through to document during resize */
  pointer-events: none;
}

.canvas-element .element-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 2px;
}

/* Resize Handles */
.canvas-element .resize-handles {
  display: none;
}

.canvas-element.selected .resize-handles {
  display: block;
}

.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #00a8ff;
  border: 2px solid #fff;
  border-radius: 2px;
}

.resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle.n { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.e { top: 50%; right: -5px; transform: translateY(-50%); cursor: e-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.resize-handle.s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.w { top: 50%; left: -5px; transform: translateY(-50%); cursor: w-resize; }

/* ============================================================================
   Element Type Styles
   ============================================================================ */

/* Heading */
.canvas-element[data-type="heading"] .element-content {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: transparent;
}

.canvas-element[data-type="heading"] h1,
.canvas-element[data-type="heading"] h2,
.canvas-element[data-type="heading"] h3 {
  margin: 0;
  color: #fff;
  font-weight: 600;
}

.canvas-element[data-type="heading"] h1 { font-size: 28px; }
.canvas-element[data-type="heading"] h2 { font-size: 22px; }
.canvas-element[data-type="heading"] h3 { font-size: 18px; }

/* Text Box */
.canvas-element[data-type="text_box"] .element-content {
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  line-height: 1.5;
}

.canvas-element[data-type="text_box"] .element-content[contenteditable="true"] {
  outline: none;
  cursor: text;
}

/* Divider */
.canvas-element[data-type="divider"] .element-content {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}

.canvas-element[data-type="divider"] hr {
  width: 100%;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin: 0;
}

/* Spacer */
.canvas-element[data-type="spacer"] .element-content {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 5px,
    rgba(255, 255, 255, 0.03) 5px,
    rgba(255, 255, 255, 0.03) 10px
  );
}

/* Image */
.canvas-element[data-type="image"] .element-content {
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-element[data-type="image"] .element-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.canvas-element[data-type="image"] .element-content .image-placeholder {
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
}

/* Shape */
.canvas-element[data-type="shape"] .element-content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-element[data-type="shape"] .shape-rect {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

/* Post */
.canvas-element[data-type="post"] .element-content {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

/* ============================================================================
   Tweet Embeds
   ============================================================================ */

.canvas-element .tweet-container {
  padding: 0;
  min-height: 100px;
  border-radius: 8px;
  overflow: visible;
  width: 100%;
}

.canvas-element .tweet-container .twitter-tweet {
  margin: 0 !important;
  transform-origin: top left;
}

.canvas-element .tweet-container .twitter-tweet iframe {
  border-radius: 8px !important;
  /* Fix white corners on dark theme tweets */
  color-scheme: light !important;
}

.canvas-element .tweet-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.5);
  gap: 12px;
  height: 100%;
}

.canvas-element .tweet-loading .loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  animation: tweet-spin 0.8s linear infinite;
}

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

.canvas-element .tweet-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  height: 100%;
  gap: 8px;
}

.canvas-element .tweet-error svg {
  opacity: 0.5;
}

/* ============================================================================
   Toolbar Zoom
   ============================================================================ */

.canva-toolbar-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
}

.canva-toolbar-zoom-level {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  min-width: 45px;
  text-align: center;
}

/* ============================================================================
   Popup
   ============================================================================ */

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

.popup-window {
  background: var(--color-bg-base-darker, #2a2a3e);
  border-radius: 12px;
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.popup-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.popup-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.popup-close:hover {
  color: #fff;
}

.popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.popup-post-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.popup-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  padding: 40px;
}

.popup-post-item {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.popup-post-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.popup-post-item img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 8px;
}

.popup-post-item .post-title {
  font-size: 12px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================================
   Layout Mode Toggle
   ============================================================================ */

.canva-toolbar-mode-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 2px;
}

.canva-toolbar-mode-toggle .canva-toolbar-btn {
  padding: 6px 8px;
  border-radius: 4px;
}

.canva-toolbar-mode-toggle .canva-toolbar-btn.active {
  background: rgba(0, 168, 255, 0.2);
  color: #00a8ff;
}

/* ============================================================================
   Block Mode Layout
   ============================================================================ */

/* When canvas is in block mode, use flexbox with wrap for side-by-side elements */
/* Use responsive padding that scales with the wider canvas */
.collection-unified-editor .canvas.block-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 2rem 3rem;
  height: auto !important;
  min-height: 200px;
  /* Allow infinite vertical growth like a web page */
}

/* Block mode elements are positioned relatively, not absolutely */
/* Width is controlled per element type - full width by default */
.canvas.block-mode .canvas-element {
  position: relative;
  left: auto !important;
  top: auto !important;
  width: 100%;
  cursor: default;
}

/* Hide resize handles in block mode */
.canvas.block-mode .canvas-element .resize-handles {
  display: none !important;
}

/* Block element styling */
.canvas.block-mode .canvas-element {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
}

.canvas.block-mode .canvas-element:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

.canvas.block-mode .canvas-element.selected {
  border-color: #00a8ff;
  background: rgba(0, 168, 255, 0.05);
}

/* Block drag handle */
.canvas.block-mode .block-drag-handle {
  position: absolute;
  left: -32px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.15s ease;
  color: rgba(255, 255, 255, 0.4);
}

.canvas.block-mode .canvas-element:hover .block-drag-handle {
  opacity: 1;
}

.canvas.block-mode .block-drag-handle:active {
  cursor: grabbing;
}

/* Block mode element content adjustments */
.canvas.block-mode .canvas-element .element-content {
  min-height: 40px;
  height: auto;
}

/* Adjust specific element types for block mode */
.canvas.block-mode .canvas-element[data-type="heading"] .element-content {
  padding: 12px 16px;
}

.canvas.block-mode .canvas-element[data-type="text_box"] .element-content {
  padding: 16px;
  min-height: 60px;
}

.canvas.block-mode .canvas-element[data-type="divider"] {
  height: auto !important;
  padding: 8px 0;
}

.canvas.block-mode .canvas-element[data-type="spacer"] {
  height: 32px !important;
}

.canvas.block-mode .canvas-element[data-type="post"] .element-content {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Block mode drag states */
.canvas.block-mode .canvas-element {
  cursor: grab;
  position: relative;
}

.canvas.block-mode .canvas-element:active {
  cursor: grabbing;
}

/* Drop zone indicators - blue highlighted bars */
.canvas.block-mode .canvas-element.drag-over-above::before,
.canvas.block-mode .canvas-element.drag-over-below::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: #3b82f6;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.6), 0 0 16px rgba(59, 130, 246, 0.3);
  z-index: 10;
  animation: dropzone-pulse 1s ease-in-out infinite;
}

.canvas.block-mode .canvas-element.drag-over-above::before {
  top: -10px;
}

.canvas.block-mode .canvas-element.drag-over-below::after {
  bottom: -10px;
}

@keyframes dropzone-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Element being dragged */
.canvas.block-mode .canvas-element.block-dragging {
  opacity: 0.4;
  pointer-events: none;
  transform: scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Hover state for draggable elements */
.canvas.block-mode .canvas-element:not(.block-dragging):hover {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Hide grid overlay in block mode */
.canvas.block-mode .canvas-grid-overlay {
  display: none;
}

/* Canvas wrapper auto-height in block mode */
.collection-unified-editor .canvas-wrapper:has(.canvas.block-mode) {
  height: auto !important;
  /* Override JS-set margin-bottom which is calculated for freeform zoom */
  margin-bottom: 0 !important;
}

/* ============================================================================
   Block Mode Layout - Based on timeline-editor.css pattern
   ============================================================================ */

/* Main container in block mode - flex: 1 like timeline-editor-fullwidth */
.collection-unified-editor:has(.canvas.block-mode) {
  display: flex;
  flex-direction: column;
  flex: 1; /* CRITICAL: Grow to fill parent, like timeline editor */
  min-height: 0;
}

/* Editor layout - flex row like timeline editor's editor-main-area */
.collection-unified-editor:has(.canvas.block-mode) .editor-main-layout {
  display: flex;
  flex-direction: row;
  gap: 0;
  position: relative;
  flex: 1; /* Grow to fill parent */
}

/* Sidebar - sticky with viewport height (like timeline-post-sidebar) */
.collection-unified-editor:has(.canvas.block-mode) .canva-sidebar {
  position: sticky;
  top: 0;
  height: calc(100vh - 100px); /* viewport - navbar - toolbar */
  min-height: 0; /* Override base min-height: 100% */
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  overflow: visible; /* Allow panel to extend over canvas */
  z-index: 50;
}

/* Canvas area - like timeline-items-area: flex: 1, scrolls internally */
.collection-unified-editor:has(.canvas.block-mode) .canvas-main-area {
  flex: 1;
  position: relative;
  overflow-y: auto; /* CRITICAL: Scroll internally like timeline-items-area */
  overflow-x: hidden;
  /* Hide scrollbars while maintaining scroll functionality */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.collection-unified-editor:has(.canvas.block-mode) .canvas-main-area::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Canvas scroll container - match portfolio page .section-container layout */
.collection-unified-editor:has(.canvas.block-mode) .canvas-scroll-container {
  display: block;
  /* Match .section-container: max-width 1400px with 2rem (32px) horizontal padding */
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

/* Canvas wrapper - auto height, fill width in block mode */
.collection-unified-editor:has(.canvas.block-mode) .canvas-wrapper {
  display: block; /* Override any flex behavior */
  width: 100%;
  height: auto !important;
  min-height: 0;
  margin: 0 0 60px 0;
  flex-shrink: unset; /* Remove flex-shrink: 0 from base */
  border: none; /* Remove dashed border in block mode */
}

/* Canvas - auto height, grows with blocks */
/* Fill available width - match how content renders on view pages */
.collection-unified-editor:has(.canvas.block-mode) .canvas {
  width: 100%;
  height: auto !important;
  min-height: 400px !important;
  margin: 0;
}

/* Sidebar rail - full height, subtle border */
.collection-unified-editor:has(.canvas.block-mode) .canva-sidebar-rail {
  flex-shrink: 0;
  height: 100%;
  border-right: 1px solid rgba(255, 255, 255, 0.05); /* Subtler separator */
}

/* Sidebar panel - absolutely positioned so it doesn't push layout */
.collection-unified-editor:has(.canvas.block-mode) .canva-sidebar-panel {
  position: absolute;
  top: 0;
  left: 56px; /* Position after rail */
  bottom: 0;
  width: 0;
  overflow: hidden;
  transition: width 0.2s ease;
  background: transparent;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.collection-unified-editor:has(.canvas.block-mode) .canva-sidebar-panel.expanded {
  width: 380px;
}

/* Panel content area - this is what scrolls */
.collection-unified-editor:has(.canvas.block-mode) .canva-panel.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.collection-unified-editor:has(.canvas.block-mode) .canva-panel-content {
  flex: 1;
  min-height: 0; /* Allow flex child to shrink */
  overflow-y: auto; /* Scroll internally */
}

/* Block mode empty state */
.canvas.block-mode .canvas-empty-state {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  padding: 60px 20px;
}

/* Add Block Zone */
.block-add-zone {
  width: 100%;
  padding: 24px;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  transition: all 0.15s ease;
  order: 9999; /* Always appear last in flexbox */
}

/* Hide the add zone when canvas has elements */
.canvas.has-elements .block-add-zone {
  display: none;
}

.block-add-zone:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.02);
}

.block-add-zone-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
}

.block-add-zone-content svg {
  opacity: 0.5;
}

/* ============================================================================
   Athlete Header Block
   ============================================================================ */

.canvas-element[data-type="athlete_header"] .element-content {
  padding: 0;
  background: transparent;
}

.athlete-header-block {
  display: flex;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  overflow: hidden;
  min-height: 120px;
}

.athlete-header-image-section {
  width: 140px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  padding: 12px;
}

.athlete-header-image {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.athlete-header-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.athlete-header-image-placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.athlete-header-info-section {
  flex: 1;
  padding: 12px 16px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.athlete-header-name {
  margin-bottom: 4px;
}

.athlete-header-first-name {
  font-size: 14px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.athlete-header-last-name {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.athlete-header-placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.athlete-header-team-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.athlete-header-bio-table {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 11px;
}

.athlete-header-bio-label {
  color: rgba(255, 255, 255, 0.4);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.athlete-header-bio-value {
  color: #fff;
  font-weight: 500;
}

.athlete-header-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.athlete-header-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.athlete-header-status-dot.inactive {
  background: #ef4444;
}

.athlete-header-status-dot.retired {
  background: #6b7280;
}

.athlete-header-social {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.athlete-header-social-link {
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.2s ease;
}

.athlete-header-social-link:hover {
  color: #00a8ff;
}

/* Block mode adjustments - fractional widths account for gap */
/* Gap is 1.5rem, so subtract 0.75rem from each element to fit side-by-side */
.canvas.block-mode .canvas-element[data-type="athlete_header"] {
  min-height: auto;
  width: calc(33.333% - 0.75rem) !important;  /* 1/3 width minus half gap */
  min-width: 300px;
}

.canvas.block-mode .canvas-element[data-type="athlete_header"] .element-content {
  padding: 0;
  width: 100%;
}

/* Athlete Bio Block - 2/3 width */
.canvas.block-mode .canvas-element[data-type="athlete_bio"] {
  min-height: auto;
  width: calc(66.666% - 0.75rem) !important;  /* 2/3 width minus half gap */
  min-width: 400px;
}

.canvas.block-mode .canvas-element[data-type="athlete_bio"] .element-content {
  padding: 0;
  width: 100%;
}

.canvas-element[data-type="athlete_bio"] .element-content {
  padding: 0;
  background: transparent;
}

/* Athlete Bio Block Styling */
.athlete-bio-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  padding: 16px 20px;
  min-height: 120px;
}

.athlete-bio-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 8px;
}

.athlete-bio-text p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
}

.athlete-bio-placeholder {
  color: rgba(255, 255, 255, 0.3) !important;
  font-style: italic;
}

.athlete-bio-awards {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 16px;
}

.athlete-bio-awards-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.athlete-bio-award-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}

.athlete-bio-award-year {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
}

.athlete-bio-award-title {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.athlete-bio-awards-empty {
  color: rgba(255, 255, 255, 0.3);
  font-size: 12px;
  font-style: italic;
}

/* Panel section label */
.panel-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
  padding: 8px 12px 4px;
  margin: 0;
}

/* ============================================================================
   Athlete Header Editor Modal
   ============================================================================ */

.athlete-editor-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.athlete-editor-modal {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  margin: 20px;
  background: var(--color-bg-elevated, #2a2c34);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.athlete-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.athlete-editor-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.athlete-editor-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 24px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.athlete-editor-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.athlete-editor-form {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.athlete-editor-section {
  margin-bottom: 24px;
}

.athlete-editor-section:last-child {
  margin-bottom: 0;
}

.athlete-editor-section h4 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.5);
}

.athlete-editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.athlete-editor-row:last-child {
  margin-bottom: 0;
}

.athlete-editor-row-4 {
  grid-template-columns: repeat(4, 1fr);
}

.athlete-editor-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.athlete-editor-field label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
}

.athlete-editor-field input,
.athlete-editor-field select {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.athlete-editor-field input:focus,
.athlete-editor-field select:focus {
  border-color: rgba(0, 168, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 168, 255, 0.1);
}

.athlete-editor-field input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.athlete-editor-field input[type="color"] {
  padding: 4px;
  height: 42px;
  cursor: pointer;
}

.athlete-editor-field select {
  cursor: pointer;
}

.athlete-editor-field select option {
  background: #2a2c34;
  color: #fff;
}

.athlete-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 24px;
}

.athlete-editor-cancel,
.athlete-editor-save {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.athlete-editor-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
}

.athlete-editor-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.athlete-editor-save {
  background: rgba(0, 168, 255, 0.15);
  border: 1px solid rgba(0, 168, 255, 0.3);
  color: #00a8ff;
}

.athlete-editor-save:hover {
  background: rgba(0, 168, 255, 0.25);
  border-color: rgba(0, 168, 255, 0.5);
}

/* Athlete Bio Editor - Awards list */
.athlete-bio-form .awards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.athlete-bio-form .award-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.athlete-bio-form .award-year-input {
  width: 80px;
  flex-shrink: 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
}

.athlete-bio-form .award-title-input {
  flex: 1;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
}

.athlete-bio-form .award-year-input:focus,
.athlete-bio-form .award-title-input:focus {
  border-color: rgba(0, 168, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 168, 255, 0.1);
  outline: none;
}

.athlete-bio-form .award-year-input::placeholder,
.athlete-bio-form .award-title-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.athlete-bio-form .award-remove-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: rgba(255, 100, 100, 0.1);
  border: 1px solid rgba(255, 100, 100, 0.2);
  border-radius: 6px;
  color: rgba(255, 100, 100, 0.7);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.athlete-bio-form .award-remove-btn:hover {
  background: rgba(255, 100, 100, 0.2);
  border-color: rgba(255, 100, 100, 0.4);
  color: #ff6464;
}

.athlete-bio-form .add-award-btn {
  align-self: flex-start;
  padding: 8px 16px;
  background: rgba(0, 168, 255, 0.1);
  border: 1px solid rgba(0, 168, 255, 0.2);
  border-radius: 6px;
  color: #00a8ff;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.athlete-bio-form .add-award-btn:hover {
  background: rgba(0, 168, 255, 0.2);
  border-color: rgba(0, 168, 255, 0.3);
}

.athlete-bio-form textarea {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
}

.athlete-bio-form textarea:focus {
  border-color: rgba(0, 168, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 168, 255, 0.1);
  outline: none;
}

.athlete-bio-form textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 768px) {
  .element-sidebar {
    width: 160px;
  }

  .canvas-scroll-container {
    padding: 20px;
  }
}

/* ============================================================================
   Login Popup
   ============================================================================ */

.login-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.login-popup {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 20px;
  padding: 32px;
  background: var(--color-bg-elevated, #2a2c34);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-popup-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.login-popup-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.login-popup-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-popup-header h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text-primary, #fff);
}

.login-popup-header p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-secondary, rgba(255, 255, 255, 0.6));
}

.login-popup-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-popup-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-popup-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary, rgba(255, 255, 255, 0.7));
}

.login-popup-field input {
  padding: 12px 14px;
  background: var(--color-bg-base, #1e1f24);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: var(--color-text-primary, #fff);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-popup-field input:focus {
  border-color: rgba(0, 168, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 168, 255, 0.1);
}

.login-popup-field input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.login-popup-error {
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #ef4444;
  font-size: 0.85rem;
  text-align: center;
  display: none;
}

.login-popup-error:not(:empty) {
  display: block;
}

.login-popup-submit {
  padding: 14px 20px;
  background: transparent;
  border: 2px solid rgba(0, 168, 255, 0.6);
  border-radius: 8px;
  color: #00a8ff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.login-popup-submit:hover:not(:disabled) {
  background: rgba(0, 168, 255, 0.1);
  border-color: rgba(0, 168, 255, 0.8);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(0, 168, 255, 0.4), inset 0 0 20px rgba(0, 168, 255, 0.1);
}

.login-popup-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.login-popup-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.login-popup-footer p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-secondary, rgba(255, 255, 255, 0.6));
}

.login-popup-footer a {
  color: var(--color-accent-primary, #00a8ff);
  text-decoration: none;
  font-weight: 500;
}

.login-popup-footer a:hover {
  text-decoration: underline;
}
