@font-face {
  font-family: "Gorton Digital";
  src: url("/fonts/Gorton-Digital-Regular.ttf.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

body {
  font-family: "Gorton Digital", monospace;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  color: #6b6382;
}

/* Custom component styles */
.drop-zone {
  border: 2px dashed #d4c5ff;
  border-radius: 1px;
  padding: 20px;
  text-align: center;
  margin: 20px 0;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f4f0ff;
}

.drop-zone.dragover {
  background-color: #e0d5ff;
  border-color: #b0a0ff;
}

/* View Wrapper - contains toolbar and view container */
.view-wrapper {
  border: 1px solid #d4c5ff;
  margin-top: 20px;
}

.view-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  background-color: #f0ebff;
  border-bottom: 1px solid #d4c5ff;
}

.view-container-wrapper {
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
  max-height: 5000px; /* Large enough for most content */
}

.view-container-wrapper.collapsed {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

.view-container-wrapper.expanded {
  max-height: 5000px;
  opacity: 1;
}

.library-container {
  margin: 0;
}

.table-view-container {
  width: 100%;
}

.grid-view-container {
  width: 100%;
}

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

.file-table th {
  text-align: left;
  padding: 8px;
  background-color: #f0ebff;
  border-bottom: 1px solid #d4c5ff;
  cursor: pointer;
  height: 33px;
  box-sizing: border-box;
}

.file-table th:hover {
  background-color: #e8e0ff;
}

.file-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e8e0ff;
}

.file-table tr:hover {
  background-color: #f4f0ff;
}

.icon {
  margin-right: 5px;
}

.name-cell {
  color: #0066cc;
  text-decoration: none;
}

.name-cell:hover {
  text-decoration: underline;
}

.size-cell:not(.empty-cell) {
  text-align: left;
}

.current-path {
  margin-bottom: 20px;
  padding: 8px;
  background-color: #f0ebff;
  border-radius: 4px;
}

.metadata-panel {
  display: none;
  position: fixed;
  right: 20px;
  top: 20px;
  width: 300px;
  background: white;
  border: 1px solid #d4c5ff;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(180, 160, 255, 0.2);
}

/* Grid View Styles */
.grid-view {
  display: grid;
  gap: 10px;
  padding: 20px;
}

.grid-item {
  position: relative;
  overflow: hidden;
  background-color: rgba(212, 197, 255, 0.13);
  border: 1px solid #d4c5ff;
  border-radius: 0;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  aspect-ratio: 1;
}

.grid-item:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(180, 160, 255, 0.3);
}

.grid-item-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  color: white;
  padding: 10px 8px 8px;
  font-size: 12px;
  font-weight: bold;
  word-wrap: break-word;
  text-align: center;
}

.grid-item-dropzone {
  background: #ede5ff !important;
  border: 2px dashed #d4c5ff !important;
}

.grid-item-dropzone:hover {
  background: #e0d5ff !important;
  border-color: #b0a0ff !important;
}

/* Responsive grid columns */
@media (max-width: 768px) {
  .grid-view {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
  }
}

@media (min-width: 769px) and (max-width: 1023px) {
  .grid-view {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-view {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Grid Viewer Overlay (Are.na style) */
.grid-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 40px;
}

.grid-viewer-wrapper {
  background: white;
  width: 90%;
  max-width: 1400px;
  height: 90%;
  max-height: 900px;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.grid-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #e8e0ff;
  flex-shrink: 0;
}

.grid-viewer-nav {
  display: flex;
  gap: 10px;
  align-items: center;
}

.grid-viewer-nav-btn {
  background: #f4f0ff;
  border: 1px solid #d4c5ff;
  border-radius: 0;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 18px;
  transition: background-color 0.2s;
  min-width: 40px;
}

.grid-viewer-nav-btn:hover:not(:disabled) {
  background: #e8e0ff;
}

.grid-viewer-nav-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.grid-viewer-counter {
  margin-left: 10px;
  font-size: 14px;
  color: #8b7fb8;
}

.grid-viewer-layout-toggle {
  display: none; /* Hide layout toggle - using responsive CSS instead */
}

.grid-viewer-layout-toggle:hover {
  background: #e8e0ff;
}

.grid-viewer-exit {
  background: #f4f0ff;
  border: 1px solid #d4c5ff;
  border-radius: 0;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  transition: background-color 0.2s;
}

.grid-viewer-exit:hover {
  background: #e8e0ff;
}

.grid-viewer-content {
  flex: 1;
  display: flex;
  flex-direction: row; /* Side-by-side by default on desktop */
  overflow: hidden;
  padding: 20px;
  gap: 20px;
}

.grid-viewer-asset {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: #f4f0ff;
  border-radius: 0;
  padding: 20px;
  position: relative;
}

.grid-viewer-asset img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s;
  cursor: zoom-in;
}

.grid-viewer-asset.zoomed img {
  cursor: zoom-out;
}

.grid-viewer-content .grid-viewer-asset {
  flex: 4; /* Takes up more space */
  max-width: 80%;
}

.grid-viewer-metadata {
  flex: 1; /* Takes up less space */
  overflow-y: auto;
  padding: 20px;
  max-width: 20%;
}

.grid-viewer-metadata-content h2 {
  margin: 0 0 15px 0;
  font-size: 24px;
}

.grid-viewer-field {
  margin-bottom: 15px;
}

.grid-viewer-field strong {
  display: inline;
  color: #6b5f98;
}

.grid-viewer-field .editable-field {
  display: inline;
  color: #6b5f98;
  cursor: pointer;
  margin-left: 5px;
  padding: 2px 4px;
  border-radius: 0;
}

.grid-viewer-field .editable-field:hover {
  background-color: #ede5ff;
}

.grid-viewer-description {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 20px;
  color: #6b5f98;
}

.grid-viewer-metadata-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: #8b7fb8;
}

.grid-viewer-metadata-details strong {
  color: #6b5f98;
}

.grid-viewer-alt {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e8e0ff;
  font-size: 14px;
  color: #8b7fb8;
}

.grid-viewer-alt strong {
  color: #6b5f98;
}

/* Responsive layout - stacked on mobile/tablet, side-by-side on desktop */
@media (max-width: 1023px) {
  .grid-viewer-content {
    flex-direction: column !important;
  }
  
  .grid-viewer-content .grid-viewer-asset {
    max-width: 100% !important;
    max-height: 60%;
    min-height: 300px;
  }
  
  .grid-viewer-content .grid-viewer-metadata {
    max-width: 100% !important;
    max-height: 40%;
  }
}

@media (max-width: 768px) {
  .grid-viewer-overlay {
    padding: 20px 10px;
  }
  
  .grid-viewer-wrapper {
    width: 100%;
    height: 100%;
    max-height: 100%;
  }
  
  .grid-viewer-content {
    padding: 15px;
    gap: 15px;
  }
}

/* View Switcher Styles */
.view-switch-btn {
  padding: 8px 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 0;
  cursor: pointer;
  font-size: 18px;
  transition: background-color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 33px; /* Match table header height */
  line-height: 1;
}

.view-switch-btn svg {
  display: block;
  stroke: currentColor;
}

.view-switch-btn:hover {
  background-color: #e8e0ff;
  border-color: #b0a0ff;
}

.view-switch-btn.active {
  background-color: #0066cc;
  color: white;
  border-color: #0066cc;
}

.view-switch-btn.active:hover {
  background-color: #0052a3;
}

.cursor {
  width: 1px;
  height: 1px;
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  display: none;
}

.cursor::before {
  content: '';
  position: absolute;
  width: 32px;
  height: 32px;
  background-image: url('/cursor.png');
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
}

.cursor::after {
  content: attr(data-id);
  position: absolute;
  left: 8px;
  top: -18px;
  font-size: 12px;
  white-space: nowrap;
  background: white;
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid #d4c5ff;
}

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

.archive-title {
  font-size: 16px;
  margin: 0;
  font-weight: normal;
  color: #6b6382;
}

.user-info {
  font-size: 14px;
  color: #b0a0ff;
  cursor: pointer;
  position: relative;
}

.user-info:hover {
  color: #8b7fb8;
}

.user-info input {
  font-size: 14px;
  padding: 2px 4px;
  border: 1px solid #d4c5ff;
  border-radius: 3px;
  width: 150px;
}

.editable {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
}

.editable:hover {
  background-color: #ede5ff;
}

.editable.editing {
  background-color: white;
  border: 1px solid #d4c5ff;
  padding: 1px 3px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  background: #e1e1e1;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
}

.tag .remove {
  margin-left: 4px;
  cursor: pointer;
  opacity: 0.6;
}

.tag .remove:hover {
  opacity: 1;
}

.tag-picker {
  position: absolute;
  background: white;
  border: 1px solid #d4c5ff;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(180, 160, 255, 0.2);
  padding: 8px;
  z-index: 1000;
}

.tag-picker input {
  width: 100%;
  padding: 4px;
  margin-bottom: 8px;
}

.tag-suggestions {
  max-height: 200px;
  overflow-y: auto;
}

.tag-suggestion {
  padding: 4px 8px;
  cursor: pointer;
}

.tag-suggestion:hover {
  background-color: #ede5ff;
}

.column-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border: 1px solid #d4c5ff;
  border-radius: 4px;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(180, 160, 255, 0.2);
  min-width: 150px;
  z-index: 1000;
}

.column-menu.show {
  display: block;
}

.column-option {
  display: flex;
  align-items: center;
  padding: 4px 8px;
}

.column-option:hover {
  background: #f4f0ff;
}

.column-option input {
  margin-right: 8px;
}

.hidden-column {
  display: none;
}

.chat-popup {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 300px;
  height: 400px;
  background: white;
  border: 1px solid #d4c5ff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(180, 160, 255, 0.2);
  display: none;
  z-index: 1000;
}

/* Media Modal Styles */
.media-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  border: none;
  border-radius: 0px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 1000;
  min-width: 320px;
  min-height: 240px;
  width: 640px;
  height: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  cursor: move;
}

/* Ensure auto-sized modals maintain centering when resized */
.media-modal.auto-size {
  /* Keep transform for centering */
  transform: translate(-50%, -50%);
}

.media-modal.preserve-ratio {
  resize: horizontal;
}

.media-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(244, 240, 255, 0.7);
  border-bottom: 1px solid rgba(212, 197, 255, 0.3);
  position: relative;
}

.media-modal-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.media-modal-nav-btn {
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  font-size: 18px;
  padding: 4px 8px;
}

.media-modal-nav-btn:hover {
  opacity: 1;
}

.media-modal-counter {
  font-size: 12px;
  color: #8b7fb8;
  margin-left: 4px;
}

.media-modal-title {
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 10px;
}

.media-modal-controls {
  display: flex;
  gap: 8px;
  position: relative;
}

.media-modal-control {
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.media-modal-control:hover {
  opacity: 1;
}

.media-blend-btn i {
  font-style: italic;
}

.media-blend-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.1);
  z-index: 1001;
  max-height: 300px;
  overflow-y: auto;
  min-width: 120px;
  pointer-events: auto;
  mix-blend-mode: normal;
  isolation: isolate;
}

.media-blend-menu-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.media-blend-menu-item:last-child {
  border-bottom: none;
}

.media-blend-menu-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.media-modal-content {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

/* PDF and text content need minimal padding to avoid button collisions */
.media-modal-content.pdf-content {
  padding: 45px 8px 8px 8px;
  background: #f4f0ff;
}

.media-modal-content.text-content {
  padding: 2px 8px 8px 8px;
  background: white;
}

/* Images, videos, and models have transparent backgrounds */
.media-modal-content img,
.media-modal-content video,
.media-modal-content model-viewer {
  background: transparent;
}

/* GIFs, GLB, and GLTF specifically */
.media-modal-content img[src$=".gif"],
.media-modal-content img[src$=".GIF"],
.media-modal-content model-viewer[src$=".glb"],
.media-modal-content model-viewer[src$=".GLB"],
.media-modal-content model-viewer[src$=".gltf"],
.media-modal-content model-viewer[src$=".GLTF"] {
  background: transparent;
}

.media-modal-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.media-modal-content video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.media-modal-content audio {
  width: 100%;
  max-width: 600px;
  display: block;
}

.media-modal-content model-viewer {
  width: 100%;
  height: 100%;
  display: block;
}

/* Auto-size modals for specific content types */
.media-modal.auto-size .media-modal-content {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-modal.auto-size .media-modal-content img,
.media-modal.auto-size .media-modal-content video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media-modal img,
.media-modal video,
.media-modal model-viewer {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.media-modal video::-webkit-media-controls,
.media-modal model-viewer::part(default-ar-button),
.media-modal model-viewer::part(default-progress-bar) {
  pointer-events: auto;
}

/* Context Menu Styles */
.context-menu {
  position: absolute;
  background: white;
  border: 1px solid #d4c5ff;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(180, 160, 255, 0.2);
  padding: 5px 0;
  min-width: 150px;
  z-index: 1000;
  display: none;
}

.context-menu-item {
  padding: 8px 15px;
  cursor: pointer;
  font-size: 14px;
}

.context-menu-item:hover {
  background-color: #f4f0ff;
}

.context-menu-item.danger {
  color: #d9534f;
}

.context-menu-item.danger:hover {
  background-color: #ffeeee;
}

.context-menu-divider {
  height: 1px;
  background-color: #e8e0ff;
  margin: 5px 0;
}

.media-modal-content #text-content {
  background: white;
  color: #6b5f98;
  line-height: 1.5;
  font-size: 14px;
}

.media-modal-content #text-content p {
  margin-bottom: 1em;
}

.media-modal.header-draggable-only .media-modal-header {
  cursor: move;
}

.media-modal.header-draggable-only .media-modal-content {
  cursor: default;
}

.media-modal:not(.header-draggable-only) {
  cursor: move;
}

.media-modal.model-viewer-modal .media-modal-content {
  cursor: auto;
}

.media-modal.model-viewer-modal .media-modal-content model-viewer {
  pointer-events: auto;
  user-select: none;
  width: 100%;
  height: 100%;
}

.media-modal model-viewer {
  pointer-events: auto !important;
  background: transparent !important;
}

/* Ensure all model-viewer elements have transparent backgrounds */
.media-modal-content model-viewer {
  background: transparent !important;
  background-color: transparent !important;
}

/* Metadata overlay styles - info button in header */
.media-modal-info-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
  color: black;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: opacity 0.2s;
  margin-left: 8px;
}

.media-modal-info-btn:hover {
  opacity: 0.6;
}

.media-modal-metadata-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  overflow-y: auto;
  padding: 40px 20px;
}

.media-modal-metadata-overlay.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.media-modal-metadata-content {
  background: rgba(255, 255, 255, 0.95);
  padding: 30px;
  max-width: 600px;
  width: 100%;
  margin-top: 40px;
  max-height: 80vh;
  overflow-y: auto;
}

.metadata-field {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e8e0ff;
}

.metadata-field:last-of-type {
  border-bottom: none;
}

.metadata-field strong {
  display: block;
  margin-bottom: 8px;
  color: #6b5f98;
  font-size: 14px;
}

.metadata-field .editable-field {
  display: block;
  color: #6b5f98;
  cursor: pointer;
  padding: 4px 0;
  min-height: 20px;
}

.metadata-field .editable-field:hover {
  background-color: #ede5ff;
}

.metadata-field .editable-field:empty::before {
  content: '(empty)';
  color: #b0a0ff;
  font-style: italic;
}

.metadata-details {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e8e0ff;
  font-size: 12px;
  color: #8b7fb8;
}

.metadata-details div {
  margin-bottom: 8px;
}

.metadata-details strong {
  color: #6b5f98;
}

/* Tag picker styles */
.tag-picker {
  margin-top: 10px;
  border: 1px solid #d4c5ff;
  padding: 10px;
  background: white;
}

.tag-picker input {
  width: 100%;
  padding: 6px;
  border: 1px solid #d4c5ff;
  margin-bottom: 10px;
}

.tag-suggestions {
  max-height: 200px;
  overflow-y: auto;
}

.tag-suggestion {
  padding: 6px;
  cursor: pointer;
  border-bottom: 1px solid #e8e0ff;
}

.tag-suggestion:hover {
  background: #f4f0ff;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #e0d5ff;
  border-radius: 0;
}

.tag .remove {
  cursor: pointer;
  font-weight: bold;
  opacity: 0.7;
}

.tag .remove:hover {
  opacity: 1;
}

/* Mobile responsive overrides */
@media (max-width: 768px) {
  .media-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95vw;
    height: 95vh;
    max-width: 95vw;
    max-height: 95vh;
    resize: none;
    cursor: default;
  }

  .media-modal-nav-btn {
    font-size: 24px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
  }

  .media-modal-info-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .media-modal-metadata-content {
    padding: 20px;
    margin-top: 20px;
  }
  /* Make table scrollable on mobile */
  .library-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .file-table {
    min-width: 100%;
  }
  
  /* Increase touch targets on mobile */
  .file-table th,
  .file-table td {
    min-height: 44px;
  }
  
  .editable {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Make metadata panel full-width on mobile */
  .metadata-panel {
    right: 0;
    left: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    max-height: 50vh;
    overflow-y: auto;
    border-radius: 8px 8px 0 0;
  }
  
  /* Adjust spacing on mobile */
  body {
    padding: 10px;
  }
  
  .drop-zone {
    padding: 15px;
    min-height: 80px;
  }
  
  .user-info {
    font-size: 12px;
  }
  
  .archive-title {
    font-size: 14px;
  }
}
