/* Theme Variables */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border-color: #d2d2d7;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.16);
  --card-bg: #f5f5f7;
  --card-hover-shadow: 0 4px 20px rgba(0,0,0,0.15);
  --image-bg: #e8e8ed;
  --accent-color: #3498db;
  --accent-hover: #2980b9;
}

[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --border-color: #404040;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
  --card-bg: #2d2d2d;
  --card-hover-shadow: 0 4px 16px rgba(0,0,0,0.5);
  --image-bg: #1f1f1f;
  --accent-color: #3498db;
  --accent-hover: #5dade2;
}

* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.container {
  padding: 20px;
  margin: 0 20px 0 0; /* Add right margin for timeline */
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  margin-right: 40px; /* Add this line - match the container's right margin */
  flex-wrap: wrap;
  gap: 15px;
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 100;
  padding: 10px 0;
  width:100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

h1 {
  margin: 0;
  color: var(--text-primary);
}

.search {
  flex: 1;
  min-width: 0;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search::placeholder {
  color: var(--text-tertiary);
}

.search:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.search:hover:not(:focus) {
  border-color: var(--text-tertiary);
}

.stats {
  background: var(--bg-secondary);
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.breadcrumb {
  background: var(--bg-secondary);
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  /* width: 100%; */
  border: 1px solid var(--border-color);
}

.breadcrumb a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.breadcrumb a:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.breadcrumb-separator {
  color: var(--text-tertiary);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
}

/* Theme Toggle Button */
.theme-toggle {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 50px;
  width: 60px;
  height: 32px;
  cursor: pointer;
  position: relative;
  transition: background-color 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.theme-toggle:hover {
  border-color: var(--accent-color);
}

.theme-toggle-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: var(--accent-color);
  border-radius: 50%;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

[data-theme="dark"] .theme-toggle-slider {
  transform: translateX(28px);
}

/* Detail View Layout */
.detail-view {
  display: none;
  grid-template-columns: 500px 1fr;
  gap: 24px;
  min-height: calc(100vh - 180px);
  margin-right: 20px; /* Space for timeline */
}

.detail-view.active {
  display: grid;
}

.detail-left {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  max-height: calc(100vh - 40px);
}

.detail-right {
  overflow-y: visible; /* Changed from auto */
  min-width: 0;
}

.detail-right h2 {
  color: var(--text-primary);
}

.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  opacity: 0.95;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--accent-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .breadcrumb {
    flex-wrap: wrap;
    padding: 10px 16px;
  }

  .search {
    order: 10;
    width: 100%;
    flex: 1 1 100%;
  }

  #imageCount {
    font-size: 13px;
  }
}

@media (max-width: 1024px) {
  .detail-view {
    grid-template-columns: 1fr;
    height: auto;
  }

  .detail-left {
    position: relative;
    max-height: none;
  }
}

/* Create Menu Styles */
.create-menu {
  position: relative;
  display: inline-block;
}

.create-button {
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: var(--shadow-sm);
}

.create-button:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.create-button:active {
  transform: scale(0.95);
}

.create-dropdown {
  display: none;
  position: absolute;
  top: 38px;
  right: 0;
  background: #ffffff;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 150px;
  z-index: 1000;
  overflow: hidden;
}

[data-theme="dark"] .create-dropdown {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.create-dropdown.show {
  display: block;
}

.dropdown-item {
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: #ffffff;
  color: #1d1d1f;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

[data-theme="dark"] .dropdown-item {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Upload Button Styles */
.upload-button {
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: var(--shadow-sm);
  margin-right: 8px;
}

.upload-button:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.upload-button:active {
  transform: scale(0.95);
}

.dropdown-item:first-child {
  border-radius: 6px 6px 0 0;
}

.dropdown-item:last-child {
  border-radius: 0 0 6px 6px;
}

.dropdown-item:only-child {
  border-radius: 6px;
}

.dropdown-item:hover {
  background: #f5f5f7;
}

[data-theme="dark"] .dropdown-item:hover {
  background: var(--bg-primary);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s, color 0.2s;
}

.modal-close:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.modal form {
  padding: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 14px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box; /* This is the key fix */
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn-cancel,
.btn-primary {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  border: none;
}

.btn-cancel {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-cancel:hover {
  background: var(--border-color);
}

.btn-primary {
  background: var(--accent-color);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-cancel:active,
.btn-primary:active {
  transform: scale(0.98);
}

.dragging {
  opacity: 0.5;
  transform: scale(0.95);
  transition: opacity 0.2s, transform 0.2s;
}

.drag-ready {
  animation: drag-ready-pulse 0.6s ease-in-out;
}

@keyframes drag-ready-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.explicitly-related-section {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

.explicitly-related-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.related-classification-tag {
  background: var(--card-bg);
  border: 2px solid var(--accent-color);
  border-radius: 6px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.related-classification-tag:hover {
  background: var(--accent-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.breadcrumb-project-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.breadcrumb-project-link:hover {
  color: var(--accent-color);
  text-decoration: underline;
}

.breadcrumb-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: 8px;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.breadcrumb-settings-btn:hover {
  background: var(--bg-primary);
  border-color: var(--accent-color);
  color: var(--accent-color);
}