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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #16213e;
  color: #e0e0e0;
  min-height: 100vh;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

h1 {
  color: #e94560;
  margin-bottom: 0.5rem;
}

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 320px;
  margin-top: 1rem;
}

.login-form input[type="password"] {
  padding: 0.75rem 1rem;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  background-color: #1a1a2e;
  color: #e0e0e0;
  font-size: 1rem;
}

.login-form input[type="password"]:focus {
  outline: none;
  border-color: #e94560;
}

.login-form button {
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 6px;
  background-color: #e94560;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.login-form button:hover {
  background-color: #d63851;
}

.error {
  color: #e94560;
  font-size: 0.9rem;
}

/* Storage bar */
.storage-bar {
  margin-bottom: 1.25rem;
}

.storage-bar-track {
  position: relative;
  width: 100%;
  height: 6px;
  background-color: #2a2a4a;
  border-radius: 3px;
  overflow: hidden;
}

.storage-bar-used {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background-color: #3a3a5a;
  border-radius: 3px;
}

.storage-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background-color: #e94560;
  border-radius: 3px;
  z-index: 1;
}

.storage-bar-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #888;
}

/* Browse page */
.browse-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.breadcrumb-link {
  color: #e94560;
  text-decoration: none;
}

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

.breadcrumb-sep {
  color: #555;
  margin: 0 0.25rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-primary {
  background-color: #e94560;
  color: #fff;
}

.btn-primary:hover {
  background-color: #d63851;
}

.btn-secondary {
  background-color: #2a2a4a;
  color: #e0e0e0;
}

.btn-secondary:hover {
  background-color: #3a3a5a;
}

.btn-danger {
  background-color: transparent;
  color: #e94560;
}

.btn-danger:hover {
  background-color: rgba(233, 69, 96, 0.15);
}

.btn-icon {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 4px;
}

.browse-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.browse-actions a {
  text-decoration: none;
}

/* New folder form */
.new-folder-form {
  margin-bottom: 1rem;
}

.new-folder-form form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  background-color: #1a1a2e;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.input:focus {
  outline: none;
  border-color: #e94560;
}

/* Directory grid */
.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.directory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  transition: border-color 0.2s;
}

.directory-item:hover {
  border-color: #e94560;
}

.directory-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #e0e0e0;
  flex: 1;
  min-width: 0;
}

.directory-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

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

.directory-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.directory-rename-input {
  background: #16213e;
  border: 1px solid #e94560;
  border-radius: 4px;
  color: #e0e0e0;
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
  outline: none;
}

/* Section title */
.section-title {
  color: #e0e0e0;
  font-size: 1rem;
  margin: 1.5rem 0 0.75rem;
}

/* Gallery grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.gallery-card {
  background-color: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.gallery-card:hover {
  border-color: #e94560;
}

.gallery-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background-color: #0f0f23;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.gallery-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #555;
}

.placeholder-icon {
  width: 48px;
  height: 48px;
}

.gallery-type-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background-color: rgba(0, 0, 0, 0.6);
  color: #e0e0e0;
  border-radius: 4px;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-info {
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.gallery-filename {
  font-size: 0.8rem;
  color: #e0e0e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-meta {
  font-size: 0.7rem;
  color: #888;
}

.gallery-meta-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Transcode status badges */
.transcode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.transcode-processing {
  color: #f0ad4e;
}

.transcode-processing svg {
  animation: spin 1.5s linear infinite;
}

.transcode-failed {
  color: #e94560;
}

.transcode-done {
  color: #28a745;
}

/* Responsive: mobile 2-3 columns, desktop 4-6 columns */
@media (max-width: 767px) {
  main {
    padding: 1rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .directory-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

.empty-message {
  color: #888;
  text-align: center;
  padding: 3rem 1rem;
}

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

.modal {
  background-color: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
}

.modal h3 {
  color: #e0e0e0;
  margin-bottom: 0.75rem;
}

.modal-warning {
  color: #e94560;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Upload page */
.upload-container {
  max-width: 600px;
}

.upload-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.upload-header a {
  text-decoration: none;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  color: #aaa;
}

.upload-select {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
}

/* Dropzone: large tap target for mobile */
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 180px;
  border: 2px dashed #2a2a4a;
  border-radius: 12px;
  background-color: #1a1a2e;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  padding: 2rem 1rem;
  -webkit-tap-highlight-color: transparent;
}

.upload-dropzone:hover,
.upload-dropzone:focus-within {
  border-color: #e94560;
  background-color: rgba(233, 69, 96, 0.05);
}

.upload-dropzone.has-files {
  border-color: #e94560;
  border-style: solid;
}

.upload-dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.upload-dropzone-icon {
  width: 48px;
  height: 48px;
  color: #e94560;
}

.upload-dropzone-text {
  font-size: 1.1rem;
  color: #e0e0e0;
  font-weight: 500;
}

.upload-dropzone-hint {
  font-size: 0.8rem;
  color: #888;
}

.upload-start-btn {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
}

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

/* Upload progress area */
.upload-overall {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #e0e0e0;
}

.upload-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.upload-file-item {
  background-color: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.upload-file-item.active {
  border-color: #e94560;
}

.upload-file-item.done {
  border-color: rgba(40, 167, 69, 0.4);
}

.upload-file-item.error {
  border-color: rgba(233, 69, 96, 0.4);
}

.upload-file-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.upload-file-name {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 0.5rem;
}

.upload-file-percent {
  font-size: 0.85rem;
  font-weight: bold;
  color: #e94560;
  flex-shrink: 0;
}

.upload-file-item.done .upload-file-percent {
  color: #28a745;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background-color: #2a2a4a;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: #e94560;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.upload-file-item.done .progress-bar {
  background-color: #28a745;
}

.upload-file-details {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #888;
}

/* Upload success */
.upload-success {
  background-color: rgba(40, 167, 69, 0.15);
  border: 1px solid rgba(40, 167, 69, 0.4);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.upload-success-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.upload-success-icon {
  width: 32px;
  height: 32px;
  color: #28a745;
  flex-shrink: 0;
}

.upload-success-title {
  color: #28a745;
  font-weight: bold;
  font-size: 1rem;
}

.upload-success-detail {
  color: #888;
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.upload-success-actions {
  display: flex;
  gap: 0.75rem;
}

.upload-success-actions .btn {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.upload-error {
  color: #e94560;
  background-color: rgba(233, 69, 96, 0.1);
  border: 1px solid rgba(233, 69, 96, 0.3);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Mobile upload optimizations */
@media (max-width: 767px) {
  .upload-container {
    max-width: none;
  }

  .upload-dropzone {
    min-height: 200px;
  }

  .upload-success-actions {
    flex-direction: column;
  }

  .upload-success-actions .btn {
    width: 100%;
  }
}

/* Video player page */
.player-page {
  max-width: 960px;
}

.player-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.player-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  flex-shrink: 0;
}

.player-title {
  font-size: 1.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-container {
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
}

.player-video {
  display: block;
  width: 100%;
  max-height: 80vh;
}

.player-meta {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #888;
}

/* Gallery card link (for clickable thumbnails) */
.gallery-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

@media (max-width: 767px) {
  .player-page {
    padding: 0.75rem;
  }

  .player-header {
    gap: 0.5rem;
  }

  .player-title {
    font-size: 0.95rem;
  }

  .player-video {
    max-height: 50vh;
  }
}

/* Image viewer */
.imgview-page {
  max-width: none;
  padding: 0;
  margin: 0;
  height: 100vh;
}

.imgview-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  z-index: 2000;
}

.imgview-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  flex-shrink: 0;
}

.imgview-filename {
  color: #e0e0e0;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 1rem;
}

.imgview-close {
  color: #e0e0e0;
  text-decoration: none;
  padding: 0.25rem;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.imgview-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.imgview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
}

.imgview-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  z-index: 10;
  transition: color 0.2s;
}

.imgview-nav:hover {
  color: #fff;
}

.imgview-nav-prev {
  left: 0;
}

.imgview-nav-next {
  right: 0;
}

.imgview-nav-disabled {
  pointer-events: none;
  opacity: 0;
}

.imgview-img-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: calc(100% - 120px);
  max-height: 100%;
  flex: 1;
  min-height: 0;
}

.imgview-img {
  max-width: 100%;
  max-height: calc(100vh - 100px);
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.3s;
}

.imgview-spinner {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #e94560;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.imgview-meta {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: #888;
  text-align: center;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .imgview-nav {
    width: 40px;
  }

  .imgview-img-wrap {
    max-width: calc(100% - 80px);
  }

  .imgview-img {
    max-height: calc(100vh - 80px);
  }
}

/* Transcode status badges */
.gallery-meta-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.transcode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  padding: 1px 3px;
  line-height: 1;
}

.transcode-processing {
  color: #f0ad4e;
  animation: spin 1.5s linear infinite;
}

.transcode-failed {
  color: #e94560;
}

.transcode-done {
  color: #28a745;
}

/* Download button in player meta */
.player-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  font-size: 0.8rem;
}

/* Image viewer top bar actions */
.imgview-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.imgview-action {
  color: #e0e0e0;
  text-decoration: none;
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.imgview-action:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Gallery filename row and action buttons */
.gallery-filename-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}

.gallery-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.gallery-action-btn {
  color: #888;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
}

.gallery-action-btn:hover {
  color: #e94560;
  background-color: rgba(233, 69, 96, 0.15);
}

.gallery-card-wrap {
  display: block;
}

/* Delete button in player/viewer */
.delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  font-size: 0.8rem;
}

/* Image viewer delete button */
.imgview-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
}

.imgview-delete:hover {
  color: #e94560;
}

/* ========== Drag and Drop ========== */

/* Draggable cursor feedback */
[draggable="true"] {
  cursor: grab;
}
[draggable="true"]:active {
  cursor: grabbing;
}

/* Source element while being dragged */
.mv-dragging {
  opacity: 0.4 !important;
  outline: 2px dashed #e94560;
  outline-offset: -2px;
}

/* Valid drop target highlight */
.mv-drop-target {
  outline: 2px solid #e94560 !important;
  outline-offset: -2px;
  background-color: rgba(233, 69, 96, 0.12) !important;
  transition: outline-color 0.15s, background-color 0.15s;
}

/* Breadcrumb-specific drop target highlight */
.breadcrumb-link.mv-drop-target {
  background-color: rgba(233, 69, 96, 0.25) !important;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
}

/* Toast notification */
.mv-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mv-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.mv-toast-success {
  background-color: rgba(40, 167, 69, 0.92);
  color: #fff;
}
.mv-toast-error {
  background-color: rgba(233, 69, 96, 0.92);
  color: #fff;
}

/* Notes section */
.notes-section {
  margin-top: 1rem;
  width: 100%;
}
.notes-textarea {
  width: 100%;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  padding: 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
  box-sizing: border-box;
}
.notes-textarea:focus {
  outline: none;
  border-color: #e94560;
}
.notes-textarea::placeholder {
  color: #666;
}
.notes-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.notes-status {
  font-size: 0.8rem;
  color: #28a745;
  opacity: 0;
  transition: opacity 0.3s;
}
.notes-status.visible {
  opacity: 1;
}

/* Notes in image viewer */
.imgview-notes {
  max-width: 960px;
  margin: 0.5rem auto 0;
  padding: 0 1rem;
  box-sizing: border-box;
}
