/**
 * Yoink Adventures - Main Styles
 * Step 4 Complete: Category Pills, Category Panel, Category Modal
 * 
 * ACCESSIBILITY (WCAG 2.1 Level AA):
 * - Color contrast meets 4.5:1 minimum
 * - Focus indicators on all interactive elements
 * - Reduced motion support for vestibular disorders
 * - Touch targets meet 44x44px minimum
 */

/* ============================================================================
   RESET & BASE
   ============================================================================ */

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

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #6b7280; /* Fixed: Was #9ca3af (2.8:1), now meets 4.5:1 */
  --bg: #ffffff;
  --bg-secondary: #f9fafb;
  --border: #e5e7eb;
  --success: #10b981;
  --success-light: #d1fae5;
  --error: #ef4444;
  --shadow: rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============================================================================
   HEADER - Two Row Layout
   ============================================================================ */

#main-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px var(--shadow);
}

/* Header Rows */
.header-row {
  display: flex;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

/* Row 1: Logo + Auth (left-aligned) */
.header-row-primary {
  justify-content: flex-start;
  padding: 12px 16px;
}

/* Row 2: Core Actions (centered) */
.header-row-actions {
  justify-content: center;
  padding: 0 16px 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.logo-button:hover {
  transform: scale(1.05);
}

.logo-y {
  width: 40px;
  height: 40px;
  background: white;
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.icon-button {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Core Action Buttons: Discover • Log • Share */
.header-actions-core {
  display: flex;
  gap: 8px;
}

.btn-core {
  padding: 8px 20px;
  background: white;
  border: 1px solid transparent;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-core:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-core:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.btn-secondary,
#login-btn {
  background: white;
  color: var(--primary);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-size: 14px;
}

.btn-secondary:hover,
#login-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.user-menu-button {
  position: relative;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid white;
  background: rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: white;
  transition: transform 0.2s;
  background-size: cover;
  background-position: center;
}

.user-avatar:hover {
  transform: scale(1.05);
}

.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow);
  min-width: 200px;
  overflow: hidden;
  z-index: 1001;
}

.user-menu-dropdown.active {
  display: block;
}

.user-menu-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.user-menu-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.user-menu-email {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.user-menu-signout {
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  transition: background 0.2s;
}

.user-menu-signout:hover {
  background: var(--bg-secondary);
}

/* Mobile Header Adjustments */
@media (max-width: 480px) {
  .header-row-primary {
    padding: 10px 12px;
  }
  
  .header-row-actions {
    padding: 0 12px 10px;
  }
  
  .header-left {
    gap: 8px;
  }
  
  .logo-y {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  
  .btn-core {
    padding: 6px 14px;
    font-size: 13px;
  }
  
  #login-btn,
  .btn-secondary {
    font-size: 13px;
    padding: 6px 12px;
  }
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */

#main-content {
  min-height: calc(100vh - 64px);
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

#main-content:focus {
  outline: none;
}

/* ============================================================================
   CONTEXT PANELS - Show/Hide Logic
   ============================================================================ */

.context-panel {
  display: none;
}

.context-panel.active {
  display: block;
}

/* ============================================================================
   PANEL HEADER (shared styles for Category, User, Location panels)
   ============================================================================ */

.panel-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================================
   CATEGORY PANEL HEADER
   ============================================================================ */

.category-panel-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.category-info {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.category-header-emoji {
  font-size: 48px;
  line-height: 1;
  flex-shrink: 0;
}

.category-header-text {
  flex: 1;
  min-width: 0;
}

.category-header-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px 0;
  line-height: 1.2;
}

.category-header-description {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* Category Stats */
.category-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.category-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
}

/* User's progress stat - slightly different styling */
.category-user-stat {
  padding-left: 24px;
  border-left: 2px solid var(--border);
}

.category-user-stat .stat-number {
  color: var(--success);
}

/* Sign-in prompt (shown for logged out users in Category Panel) */
.signin-prompt {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 8px;
}

.signin-prompt p {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.signin-prompt-link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  padding: 0;
}

.signin-prompt-link:hover {
  color: var(--primary-hover);
}

/* Responsive category header */
@media (max-width: 600px) {
  .category-info {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .category-header-emoji {
    font-size: 56px;
  }
  
  .category-header-title {
    font-size: 24px;
  }
  
  .category-stats {
    justify-content: center;
  }
  
  .category-user-stat {
    padding-left: 0;
    border-left: none;
    padding-top: 12px;
    border-top: 2px solid var(--border);
  }
}

/* ============================================================================
   FILTER BAR & CATEGORY PILLS
   ============================================================================ */

.filter-bar {
  margin-bottom: 20px;
}

.category-pills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.category-pill:hover {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--shadow);
  transform: translateY(-1px);
}

.category-pill:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.category-pill:active {
  transform: translateY(0);
}

/* "All" pill - special styling */
.category-pill-all {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}

.category-pill-all:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: white;
}

.category-pill-all.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Active category pill (non-All) */
.category-pill.active:not(.category-pill-all) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* A3: "Choose categories" CTA pill */
.category-pill-cta {
  background: linear-gradient(135deg, var(--primary-light) 0%, #c7d2fe 100%);
  border: 2px dashed var(--primary);
  color: var(--primary);
  font-weight: 600;
  padding: 8px 16px;
}

.category-pill-cta:hover {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  border-style: solid;
  color: white;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transform: translateY(-2px);
}

.category-pill-cta:hover .category-pill-emoji {
  transform: rotate(90deg);
}

.category-pill-cta .category-pill-emoji {
  font-size: 14px;
  transition: transform 0.2s ease;
}

/* Followed state (for logged in users - Phase A2) */
.category-pill.followed {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.category-pill.followed:hover {
  background: var(--primary);
  color: white;
}

.category-pill-emoji {
  font-size: 16px;
  line-height: 1;
}

.category-pill-name {
  line-height: 1.2;
}

.category-pill-count {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.category-pill:hover .category-pill-count {
  color: var(--primary);
}

.category-pill-all .category-pill-count,
.category-pill-all:hover .category-pill-count {
  color: rgba(255, 255, 255, 0.8);
}

.category-pill-follow-icon {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-left: 2px;
  transition: color 0.2s;
}

.category-pill.followed .category-pill-follow-icon {
  color: var(--success);
}

.category-pill.followed:hover .category-pill-follow-icon {
  color: white;
}

/* Horizontal scroll on mobile */
@media (max-width: 768px) {
  .category-pills-container {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    padding-bottom: 8px;
    margin-bottom: -8px;
  }
  
  .category-pills-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }
  
  .category-pill {
    flex-shrink: 0;
  }
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================================================
   YOINKS GRID
   ============================================================================ */

.yoinks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding: 20px 0;
}

.yoink-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 420px; /* Fixed height for consistent grid */
}

.yoink-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px var(--shadow);
}

.yoink-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.yoink-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  background: var(--bg-secondary); /* Fallback for missing images */
}

/* Placeholder for cards without images */
.yoink-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.yoink-card-placeholder-emoji {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
  animation: floatEmoji 3s ease-in-out infinite;
}

@keyframes floatEmoji {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Hover effect on placeholder */
.yoink-card:hover .yoink-card-placeholder-emoji {
  transform: scale(1.1) translateY(-10px);
  transition: transform 0.3s ease;
}

.yoink-card-content {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0; /* Important for flex overflow */
}

.yoink-card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  /* Truncate to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.yoink-card-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
  flex: 1;
  /* Truncate to 3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yoink-card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: auto; /* Push to bottom */
  flex-shrink: 0;
}

.yoink-card-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  /* Truncate long location names */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state h3 {
  font-size: 24px;
  margin-bottom: 8px;
}

.error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--error);
}

.error-state h3 {
  font-size: 24px;
  margin-bottom: 8px;
}

/* ============================================================================
   FAB
   ============================================================================ */

.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 12px var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 50;
}

.fab:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.fab:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.fab:active {
  transform: scale(0.95);
}

/* ============================================================================
   MODALS
   ============================================================================ */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 1001;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  z-index: 10;
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.modal-close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================================
   AUTH MODAL
   ============================================================================ */

.auth-modal-content {
  max-width: 440px;
}

.auth-modal-body {
  padding: 40px 32px 32px;
}

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

.auth-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.auth-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: 8px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px var(--shadow);
}

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

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

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.form-group input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.auth-error {
  display: none;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: var(--error);
  font-size: 14px;
  line-height: 1.5;
}

.auth-error::before {
  content: "⚠️ ";
  margin-right: 4px;
}

.auth-btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth-btn-primary {
  background: var(--primary);
  color: white;
}

.auth-btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.auth-btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
}

.auth-btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.auth-btn-google {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.auth-btn-google:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  text-align: right;
  padding: 0;
  margin: -8px 0 0 0;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth-help-text {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.5;
}

.auth-success {
  text-align: center;
  padding: 20px;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
}

.auth-success h2,
.auth-success h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.auth-success p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ============================================================================
   CATEGORY MANAGEMENT MODAL
   ============================================================================ */

.category-modal-content {
  max-width: 600px;
  max-height: 80vh;
}

.category-modal-body {
  padding: 32px 24px 24px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
}

.category-modal-header {
  margin-bottom: 24px;
  flex-shrink: 0;
}

.category-modal-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.category-modal-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

/* Category Tree */
.category-tree {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg-secondary);
}

.category-tree-item {
  margin-bottom: 4px;
}

.category-tree-parent {
  margin-bottom: 8px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: white;
  border-radius: 8px;
  cursor: default;
  transition: all 0.2s;
  user-select: none;
}

.category-item:hover {
  background: var(--primary-light);
}

.category-item.followed {
  background: var(--success-light);
  border-left: 3px solid var(--success);
}

/* Expand/Collapse Triangle */
.category-expand {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
}

.category-expand:hover {
  background: var(--border);
}

.category-expand:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.category-expand.expanded {
  transform: rotate(90deg);
}

.category-expand-icon {
  width: 0;
  height: 0;
  border-left: 6px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.category-expand-placeholder {
  width: 24px;
  flex-shrink: 0;
}

/* Category Info */
.category-info-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.category-emoji-inline {
  font-size: 20px;
  flex-shrink: 0;
}

.category-name-inline {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-count-inline {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Follow Toggle Button */
.category-follow-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.category-follow-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.category-follow-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.category-follow-btn.following {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.category-follow-btn.following:hover {
  background: var(--success);
  opacity: 0.9;
}

/* Child Categories (nested) */
.category-children {
  margin-left: 24px;
  margin-top: 4px;
  display: none;
}

.category-children.expanded {
  display: block;
}

/* Modal Footer */
.category-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#category-follow-count {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.btn-primary {
  padding: 10px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 640px) {
  .category-modal-content {
    width: 95%;
    max-height: 90vh;
  }
  
  .category-modal-body {
    padding: 24px 16px 16px;
  }
  
  .category-children {
    margin-left: 16px;
  }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
  .yoinks-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .auth-modal-body {
    padding: 32px 24px 24px;
  }
  
  .modal-content {
    width: 95%;
  }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

.yoink-card {
  animation: fadeIn 0.3s ease-out;
}

/* Pill appear animation */
@keyframes pillFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.category-pill {
  animation: pillFadeIn 0.2s ease-out;
}

/* Stagger animation for pills */
.category-pill:nth-child(1) { animation-delay: 0.02s; }
.category-pill:nth-child(2) { animation-delay: 0.04s; }
.category-pill:nth-child(3) { animation-delay: 0.06s; }
.category-pill:nth-child(4) { animation-delay: 0.08s; }
.category-pill:nth-child(5) { animation-delay: 0.10s; }
.category-pill:nth-child(6) { animation-delay: 0.12s; }
.category-pill:nth-child(7) { animation-delay: 0.14s; }
.category-pill:nth-child(8) { animation-delay: 0.16s; }
.category-pill:nth-child(9) { animation-delay: 0.18s; }
.category-pill:nth-child(10) { animation-delay: 0.20s; }

/* Panel transition animation */
.context-panel {
  animation: fadeIn 0.2s ease-out;
}

/* ============================================================================
   REDUCED MOTION - Accessibility
   Respects user's system preference for reduced motion
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .yoink-card:hover {
    transform: none;
  }
  
  .yoink-card-placeholder-emoji {
    animation: none;
  }
  
  .yoink-card:hover .yoink-card-placeholder-emoji {
    transform: none;
  }
  
  .category-pill:hover {
    transform: none;
  }
  
  .category-pill-cta:hover {
    transform: none;
  }
  
  .category-pill-cta:hover .category-pill-emoji {
    transform: none;
  }
  
  .btn-core:hover,
  .btn-secondary:hover,
  #login-btn:hover,
  .btn-primary:hover,
  .auth-btn-primary:hover {
    transform: none;
  }
  
  .logo-button:hover {
    transform: none;
  }
  
  .user-avatar:hover {
    transform: none;
  }
  
  .fab:hover {
    transform: none;
  }
  
  .fab:active {
    transform: none;
  }
}

/* ============================================================================
   PRINT
   ============================================================================ */

@media print {
  #main-header,
  .fab,
  .modal,
  .filter-bar {
    display: none !important;
  }
  
  .yoinks-grid {
    display: block;
  }
  
  .yoink-card {
    page-break-inside: avoid;
    margin-bottom: 20px;
  }
}

/* ============================================================================
   ADMIN PANEL STYLES - Phase 4.5a
   ============================================================================ */

/* User Menu Dropdown - Expanded */
.user-menu-items {
  padding: 8px 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  transition: background 0.2s;
}

.user-menu-item:hover {
  background: var(--bg-secondary);
}

.user-menu-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.user-menu-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.user-menu-admin {
  color: var(--primary);
  font-weight: 500;
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Admin Panel - Full Page */
.admin-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 900;
  overflow-y: auto;
}

/* Admin Header */
.admin-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  background: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.admin-back-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.admin-back-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.admin-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

/* Read-Only Toggle */
.admin-readonly-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.readonly-label {
  font-size: 14px;
  font-weight: 500;
}

.readonly-toggle-btn {
  padding: 6px 16px;
  border: 2px solid white;
  border-radius: 20px;
  background: transparent;
  color: white;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.readonly-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.readonly-toggle-btn[aria-pressed="true"] {
  background: #ef4444;
  border-color: #ef4444;
}

.readonly-toggle-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Read-Only Banner */
.readonly-banner {
  background: #fef2f2;
  border-bottom: 2px solid #ef4444;
  color: #dc2626;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.admin-tab {
  padding: 10px 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.admin-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.admin-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.admin-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Admin Content */
.admin-content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
}

/* Stats Cards Grid */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.admin-stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 4px var(--shadow);
}

.admin-stat-card.stat-card-highlight {
  background: var(--primary-light);
  border-color: var(--primary);
}

.stat-card-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.stat-card-highlight .stat-card-value {
  color: var(--primary);
}

.stat-card-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

/* Dashboard Grid */
.admin-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.admin-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 4px var(--shadow);
}

.admin-card-wide {
  grid-column: span 3;
}

.admin-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* Leaderboard List */
.admin-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.leaderboard-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.leaderboard-item:nth-child(1) .leaderboard-rank { background: #fbbf24; }
.leaderboard-item:nth-child(2) .leaderboard-rank { background: #9ca3af; }
.leaderboard-item:nth-child(3) .leaderboard-rank { background: #d97706; }

.leaderboard-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-count {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

/* Activity Chart */
.admin-chart {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 20px 0;
}

.chart-bar-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.chart-bar {
  width: 100%;
  max-width: 40px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.chart-bar-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
}

.chart-bar-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

/* Recent Activity List */
.admin-recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.recent-item-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
}

.recent-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recent-item-info {
  flex: 1;
  min-width: 0;
}

.recent-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.recent-item-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Admin Placeholder */
.admin-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  background: var(--bg-secondary);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 16px;
}

/* Responsive Admin */
@media (max-width: 1024px) {
  .admin-dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .admin-card-wide {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .admin-header {
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
  }
  
  .admin-header-left,
  .admin-header-right {
    width: 100%;
    justify-content: space-between;
  }
  
  .admin-tabs {
    padding: 12px 16px;
  }
  
  .admin-tab {
    padding: 8px 14px;
    font-size: 13px;
  }
  
  .admin-content {
    padding: 16px;
  }
  
  .admin-dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .admin-card-wide {
    grid-column: span 1;
  }
  
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   ADMIN - Categories Management (Phase 4.5b)
   ============================================================================ */

/* Section Header with Search + Add */
.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-search-box {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.admin-search-input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.admin-add-btn {
  white-space: nowrap;
}

/* Admin Table */
.admin-table-container {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 4px var(--shadow);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table thead {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
}

.admin-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: var(--bg-secondary);
}

.admin-table .loading-state,
.admin-table .empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary);
}

/* Table Cell Variants */
.admin-table .cell-emoji {
  font-size: 24px;
  text-align: center;
  width: 60px;
}

.admin-table .cell-name {
  font-weight: 500;
}

.admin-table .cell-parent {
  color: var(--text-secondary);
}

.admin-table .cell-count {
  text-align: center;
  font-weight: 600;
  color: var(--primary);
}

.admin-table .cell-actions {
  white-space: nowrap;
  text-align: right;
  width: 120px;
}

/* Action Buttons */
.admin-action-btn {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 4px;
}

.admin-action-btn:first-child {
  margin-left: 0;
}

.admin-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.admin-action-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.admin-action-btn.btn-edit:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.admin-action-btn.btn-delete:hover {
  background: #fef2f2;
  border-color: var(--error);
  color: var(--error);
}

/* Table Footer */
.admin-table-footer {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Admin Form Modal */
.admin-form-modal {
  max-width: 500px;
}

.admin-form-body {
  padding: 32px;
}

.admin-form-body h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 24px 0;
}

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

.form-row {
  display: flex;
  gap: 12px;
}

.form-group-small {
  flex: 0 0 80px;
}

.form-group-large {
  flex: 1;
}

.admin-form .form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.admin-form .form-group label .required {
  color: var(--error);
}

.admin-form input[type="text"],
.admin-form select,
.admin-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.admin-form textarea {
  resize: vertical;
  min-height: 80px;
}

.emoji-input {
  font-size: 24px;
  text-align: center;
  padding: 8px !important;
}

.admin-form-error {
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: var(--error);
  font-size: 14px;
}

.admin-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Delete Confirmation Modal */
.delete-confirm-modal {
  max-width: 400px;
}

.delete-confirm-body {
  padding: 32px;
  text-align: center;
}

.delete-confirm-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.delete-confirm-body h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px 0;
}

.delete-confirm-body p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.delete-confirm-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn-danger {
  padding: 10px 24px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-danger:focus-visible {
  outline: 2px solid var(--error);
  outline-offset: 2px;
}

/* Sortable Table Headers */
.col-sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.col-sortable:hover {
  background: var(--border);
}

.col-sortable .sort-icon {
  margin-left: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.col-sortable.sort-asc .sort-icon::after {
  content: '↑';
}

.col-sortable.sort-desc .sort-icon::after {
  content: '↓';
}

.col-sortable.sort-asc .sort-icon,
.col-sortable.sort-desc .sort-icon {
  color: var(--primary);
}

/* Hide default icon when sorted */
.col-sortable.sort-asc .sort-icon,
.col-sortable.sort-desc .sort-icon {
  font-size: 0; /* Hide the ↕ */
}

.col-sortable.sort-asc .sort-icon::after,
.col-sortable.sort-desc .sort-icon::after {
  font-size: 12px;
}

/* Locations Table */
#admin-tab-locations .admin-table-container {
  overflow-x: auto;
}

#locations-table {
  table-layout: fixed;
  width: 100%;
  min-width: 500px;
}

#locations-table th:nth-child(1),
#locations-table td:nth-child(1) { 
  width: 55%;
}

#locations-table th:nth-child(2),
#locations-table td:nth-child(2) { 
  width: 15%; 
  text-align: center; 
}

#locations-table th:nth-child(3),
#locations-table td:nth-child(3) { 
  width: 15%; 
}

#locations-table th:nth-child(4),
#locations-table td:nth-child(4) { 
  width: 15%; 
}

#locations-table .cell-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#locations-table .cell-date {
  color: var(--text-secondary);
}

/* Readonly form fields */
.form-label-readonly {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-readonly-value {
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Input with inline button */
.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button input {
  flex: 1;
}

.btn-fetch-google {
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-fetch-google:hover {
  border-color: #4285F4;
  color: #4285F4;
  background: #f0f7ff;
}

.btn-fetch-google:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#location-google-status {
  margin-top: 4px;
}

#location-google-status.success {
  color: var(--success);
}

#location-google-status.error {
  color: var(--error);
}

/* Responsive Admin Tables */
@media (max-width: 768px) {
  .admin-section-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .admin-search-box {
    max-width: none;
  }
  
  .admin-table-container {
    overflow-x: auto;
  }
  
  .admin-table {
    min-width: 500px;
  }
}

/* ============================================================================
   ADMIN - Users Management (Phase 4.5d)
   ============================================================================ */

/* Export button */
.admin-export-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.admin-export-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.admin-export-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Users table specific */
#users-table {
  table-layout: fixed;
  width: 100%;
  min-width: 700px;
}

#users-table th:nth-child(1),
#users-table td:nth-child(1) { width: 22%; } /* User */

#users-table th:nth-child(2),
#users-table td:nth-child(2) { width: 25%; } /* Email */

#users-table th:nth-child(3),
#users-table td:nth-child(3) { width: 12%; } /* Role */

#users-table th:nth-child(4),
#users-table td:nth-child(4) { width: 10%; text-align: center; } /* Yoinks */

#users-table th:nth-child(5),
#users-table td:nth-child(5) { width: 14%; } /* Joined */

#users-table th:nth-child(6),
#users-table td:nth-child(6) { width: 17%; } /* Actions */

/* Inline editable name field */
.inline-edit-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inline-edit-text {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-edit-text:hover {
  background: var(--primary-light);
}

.inline-edit-text:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.inline-edit-input {
  width: 100%;
  padding: 6px 10px;
  border: 2px solid var(--primary);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}

.inline-edit-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Role dropdown */
.role-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
  min-width: 100px;
}

.role-select:hover {
  border-color: var(--primary);
}

.role-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.role-select:disabled {
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: not-allowed;
}

.role-select option {
  padding: 8px;
}

/* Lock toggle button */
.lock-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 18px;
}

.lock-toggle:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.lock-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.lock-toggle.locked {
  background: #fef2f2;
  border-color: var(--error);
  color: var(--error);
}

.lock-toggle.locked:hover {
  background: #fee2e2;
}

.lock-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lock-toggle:disabled:hover {
  background: white;
  border-color: var(--border);
}

/* Cell with lock + go to button */
.cell-actions-users {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* "Go to" link button */
.btn-goto {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.btn-goto:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Locked user row */
.user-row-locked {
  background-color: #fef2f2;
}

.user-row-locked td {
  color: var(--text-muted);
}

/* Self row indicator (can't edit own role/lock) */
.user-row-self {
  background-color: #f0f9ff;
}

/* Email cell */
.cell-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

/* Yoinks count cell */
.cell-yoinks {
  text-align: center;
  font-weight: 600;
  color: var(--primary);
}

/* Joined date cell */
.cell-joined {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ============================================================================
   ADMIN - Yoinks Management (Phase 4.5e)
   ============================================================================ */

/* Yoinks table layout */
#yoinks-table {
  table-layout: fixed;
  width: 100%;
  min-width: 800px;
}

#yoinks-table th:nth-child(1),
#yoinks-table td:nth-child(1) { width: 70px; } /* Thumb */

#yoinks-table th:nth-child(2),
#yoinks-table td:nth-child(2) { width: 20%; } /* Title */

#yoinks-table th:nth-child(3),
#yoinks-table td:nth-child(3) { width: 15%; } /* User */

#yoinks-table th:nth-child(4),
#yoinks-table td:nth-child(4) { width: 15%; } /* Category */

#yoinks-table th:nth-child(5),
#yoinks-table td:nth-child(5) { width: 18%; } /* Location */

#yoinks-table th:nth-child(6),
#yoinks-table td:nth-child(6) { width: 12%; } /* Created */

#yoinks-table th:nth-child(7),
#yoinks-table td:nth-child(7) { width: 140px; } /* Actions */

/* Thumbnail cell */
.col-thumb {
  text-align: center;
}

.yoink-thumb {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-secondary);
}

.yoink-thumb-placeholder {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

/* Title cell */
#yoinks-table .cell-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* User cell - clickable for transfer */
#yoinks-table .cell-user {
  cursor: pointer;
  padding: 8px 12px;
}

.user-cell-content {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.user-cell-content:hover {
  background: var(--primary-light);
}

.user-cell-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-cell-icon {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Category cell - clickable for inline edit */
#yoinks-table .cell-category {
  cursor: pointer;
}

.category-cell-content {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.category-cell-content:hover {
  background: var(--primary-light);
}

.category-cell-emoji {
  font-size: 16px;
  flex-shrink: 0;
}

.category-cell-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-cell-icon {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: auto;
}

/* Location cell */
#yoinks-table .cell-location {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

/* Created date cell */
#yoinks-table .cell-created {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

/* Actions cell for yoinks */
#yoinks-table .cell-actions {
  white-space: nowrap;
}

.yoink-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Pagination */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  padding: 16px 0;
}

.pagination-btn {
  padding: 8px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.pagination-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 14px;
  color: var(--text-secondary);
  min-width: 100px;
  text-align: center;
}

/* ============================================================================
   YOINKS TAB - USER TRANSFER AUTOCOMPLETE
   ============================================================================ */

.user-cell-content {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.15s ease;
}

.user-cell-content:hover {
  background-color: var(--bg-secondary, #f5f5f5);
}

.user-cell-icon {
  font-size: 10px;
  opacity: 0.5;
}

/* Autocomplete dropdown */
.user-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  min-width: 280px;
  max-height: 300px;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #ddd);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.user-autocomplete-search {
  padding: 8px;
  border-bottom: 1px solid var(--border-color, #ddd);
}

.user-autocomplete-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 4px;
  font-size: 14px;
}

.user-autocomplete-search input:focus {
  outline: none;
  border-color: var(--primary-color, #4a90d9);
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.user-autocomplete-list {
  flex: 1;
  overflow-y: auto;
  max-height: 240px;
}

.user-autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color-light, #eee);
  transition: background-color 0.1s ease;
}

.user-autocomplete-item:last-child {
  border-bottom: none;
}

.user-autocomplete-item:hover {
  background-color: var(--bg-secondary, #f5f5f5);
}

.user-autocomplete-item.selected {
  background-color: var(--primary-light, #e8f0fe);
}

.user-autocomplete-name {
  font-weight: 500;
  color: var(--text-primary, #333);
}

.user-autocomplete-email {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-left: 8px;
}

.user-autocomplete-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted, #888);
  font-style: italic;
}

/* Make user cell position relative for dropdown positioning */
#yoinks-table .cell-user {
  position: relative;
}

/* ============================================================================
   YOINKS TAB - CATEGORY INLINE EDIT
   ============================================================================ */

.category-cell-content {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.15s ease;
}

.category-cell-content:hover {
  background-color: var(--bg-secondary, #f5f5f5);
}

.category-cell-icon {
  font-size: 10px;
  opacity: 0.5;
  margin-left: auto;
}

/* Category dropdown */
.category-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  min-width: 250px;
  max-height: 320px;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #ddd);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.category-autocomplete-search {
  padding: 8px;
  border-bottom: 1px solid var(--border-color, #ddd);
}

.category-autocomplete-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 4px;
  font-size: 14px;
}

.category-autocomplete-search input:focus {
  outline: none;
  border-color: var(--primary-color, #4a90d9);
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.category-autocomplete-list {
  flex: 1;
  overflow-y: auto;
  max-height: 260px;
}

.category-autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color-light, #eee);
  transition: background-color 0.1s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-autocomplete-item:last-child {
  border-bottom: none;
}

.category-autocomplete-item:hover {
  background-color: var(--bg-secondary, #f5f5f5);
}

.category-autocomplete-item.selected {
  background-color: var(--primary-light, #e8f0fe);
}

.category-autocomplete-item.is-child {
  padding-left: 28px;
}

.category-autocomplete-emoji {
  font-size: 16px;
}

.category-autocomplete-name {
  font-weight: 500;
  color: var(--text-primary, #333);
}

.category-autocomplete-parent {
  font-size: 11px;
  color: var(--text-muted, #888);
  margin-left: 4px;
}

.category-autocomplete-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted, #888);
  font-style: italic;
}

/* Make category cell position relative for dropdown positioning */
#yoinks-table .cell-category {
  position: relative;
}

/* ============================================================================
   USER PANEL (Step 6)
   ============================================================================ */

/* User Panel Header */
.user-panel-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-panel-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.user-header-text {
  flex: 1;
  min-width: 0;
}

.user-header-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px 0;
  line-height: 1.2;
}

.user-header-stats {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0;
}

/* User's Category Pills (for filtering within panel) */
.user-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

/* Responsive */
@media (max-width: 480px) {
  .user-panel-avatar {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
  
  .user-header-title {
    font-size: 20px;
  }
}

/* User Panel Category Pills */
.user-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle, #e5e7eb);
}

.user-category-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-secondary, #f3f4f6);
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-secondary, #6b7280);
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-category-pill:hover {
  background: var(--bg-tertiary, #e5e7eb);
}

.user-category-pill.active {
  background: var(--accent-color, #4f46e5);
  color: white;
  border-color: var(--accent-color, #4f46e5);
}

/* ============================================================================
   LOCATION PANEL (Step 7)
   ============================================================================ */

/* Location Panel Header */
.location-panel-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.location-info {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.location-panel-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}

.location-header-text {
  flex: 1;
  min-width: 0;
}

.location-header-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px 0;
  line-height: 1.3;
}

.location-header-address {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 4px 0;
}

.location-header-stats {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* Location Category Pills */
.location-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.location-category-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.location-category-pill:hover {
  background: var(--bg-tertiary, #e5e7eb);
  border-color: var(--primary);
}

.location-category-pill:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.location-category-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Responsive */
@media (max-width: 600px) {
  .location-info {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .location-panel-icon {
    width: 64px;
    height: 64px;
    font-size: 32px;
  }
  
  .location-header-title {
    font-size: 20px;
  }
}