/* Admin layout */
.admin-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-header__title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
}

.admin-nav {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
}

.admin-nav a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: var(--space-xs);
}

.admin-nav a:hover,
.admin-nav a.active {
  color: var(--color-text);
  border-bottom: 2px solid var(--color-accent);
}

.admin-content {
  flex: 1;
  padding: var(--space-lg);
  max-width: var(--container-max);
  margin: 0 auto;
  width: 100%;
}

/* Dashboard */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
}

.stat-card__number {
  font-size: var(--text-2xl);
  font-family: var(--font-heading);
  margin-bottom: var(--space-xs);
}

.stat-card__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quick-actions {
  display: flex;
  gap: var(--space-md);
}

/* Gallery list (admin) */
.admin-gallery-list {
  display: grid;
  gap: var(--space-md);
}

.admin-gallery-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

.admin-gallery-card:hover {
  border-color: var(--color-border-strong);
}

.admin-gallery-card__thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--color-bg-muted);
  flex-shrink: 0;
}

.admin-gallery-card__info {
  flex: 1;
}

.admin-gallery-card__title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  margin-bottom: var(--space-xs);
}

.admin-gallery-card__meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.visibility-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.visibility-badge--public {
  background: #e6f4ea;
  color: var(--color-success);
}

.admin-gallery-card__actions {
  display: flex;
  gap: var(--space-sm);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: var(--space-lg);
}

.upload-zone:hover,
.upload-zone--dragover {
  border-color: var(--color-accent);
  background: var(--color-bg-subtle);
}

.upload-zone__text {
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

/* Upload queue */
.upload-queue {
  display: grid;
  gap: var(--space-sm);
}

.upload-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.upload-item__thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--color-bg-muted);
  flex-shrink: 0;
}

.upload-item__info {
  flex: 1;
  min-width: 0;
}

.upload-item__name {
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-item__size {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.upload-item__progress {
  width: 100%;
  height: 4px;
  background: var(--color-bg-muted);
  border-radius: 2px;
  overflow: hidden;
  margin-top: var(--space-xs);
}

.upload-item__progress-bar {
  height: 100%;
  background: var(--color-accent);
  transition: width 0.2s;
}

.upload-item__status {
  font-size: var(--text-sm);
  white-space: nowrap;
}

.upload-item__status--complete {
  color: var(--color-success);
}

.upload-item__status--error {
  color: var(--color-danger);
}

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg-subtle);
}

.login-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.login-card__title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  text-align: center;
  margin-bottom: var(--space-lg);
}

.login-card .btn--primary {
  width: 100%;
}

.login-error {
  background: #fef2f2;
  color: var(--color-danger);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  margin-bottom: var(--space-md);
  display: none;
}

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

.modal {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-md);
}

.modal__title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  margin-bottom: var(--space-md);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

/* --- Galleries split-pane --- */
.galleries-pane {
  display: flex;
  height: calc(100vh - 60px);
}

.tree-nav {
  width: var(--tree-width);
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: var(--space-sm) 0;
}

.detail-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.tree-node:hover {
  color: var(--color-text);
}

.tree-node--active {
  color: var(--color-text);
  font-weight: 500;
  background: var(--color-bg-muted);
  border-radius: var(--radius);
  margin: 1px 6px;
  width: calc(100% - 12px);
}

.tree-node__chevron {
  width: 10px;
  flex-shrink: 0;
  font-size: 8px;
  color: var(--color-text-light);
  transition: transform 0.15s ease;
  display: inline-block;
}

.tree-node__chevron--open {
  transform: rotate(90deg);
}

.tree-node__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.tree-node__icon svg {
  stroke: currentColor;
  fill: none;
}

.tree-node__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-children {
  /* Indentation handled by padding-left on child .tree-node elements */
}

.tree-node--dragging {
  opacity: 0.4;
}

.tree-node--drag-over {
  background: var(--color-selection-bg);
  outline: 1px solid var(--color-selection);
  border-radius: var(--radius);
}

.tree-drop-zone {
  height: 4px;
  margin: 0 12px;
  border-radius: 2px;
  transition: background 0.15s;
}

.tree-drop-zone--active {
  background: var(--color-selection);
  height: 4px;
}

/* --- Header strip --- */
.header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--header-strip-bg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  gap: var(--space-sm);
}

.header-strip__breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  min-width: 0;
  overflow: hidden;
}

.header-strip__breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.header-strip__breadcrumb a:hover {
  color: var(--color-text);
}

.header-strip__breadcrumb-sep {
  color: var(--color-text-light);
  flex-shrink: 0;
}

.header-strip__breadcrumb-current {
  color: var(--color-text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-strip__count {
  color: var(--color-text-light);
  font-size: var(--text-sm);
  margin-left: var(--space-sm);
  flex-shrink: 0;
}

.header-strip__actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

.header-strip__btn {
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
  border: none;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-strip__btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.header-strip__btn--primary {
  background: var(--color-success);
  color: var(--color-white);
}

.header-strip__btn--primary:hover {
  opacity: 0.9;
}

/* --- Content area --- */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  position: relative;
}

/* Folder view: card grid */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
}

.content-card {
  background: var(--color-bg-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: border-color 0.15s;
}

.content-card:hover {
  border-color: var(--color-border-strong);
}

.content-card__thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-muted);
}

.content-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.content-card__thumb--folder {
  background: var(--color-bg-muted);
}

.content-card__thumb--folder svg {
  stroke: var(--color-text-light);
  fill: none;
}

.content-card__body {
  padding: var(--space-sm) 10px;
}

.content-card__title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.content-card__count {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.visibility-badge--unlisted {
  background: var(--color-badge-unlisted-bg);
  color: var(--color-badge-unlisted-text);
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 3px;
}

/* Empty state */
.content-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--color-text-light);
  font-size: var(--text-sm);
  gap: var(--space-sm);
}

/* --- Selection toolbar (contextual, gallery view) --- */
.selection-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--space-md);
  background: var(--color-selection-bg);
  border-bottom: 1px solid var(--color-selection);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.selection-toolbar__left {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.selection-toolbar__count {
  color: var(--color-selection);
  font-weight: 600;
}

.selection-toolbar__action {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  padding: 0;
  color: var(--color-selection);
}

.selection-toolbar__action:hover {
  text-decoration: underline;
}

.selection-toolbar__action--danger {
  color: var(--color-danger);
}

.selection-toolbar__cancel {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-selection);
  padding: 0;
}

.selection-toolbar__cancel:hover {
  text-decoration: underline;
}

/* --- Upload toast (bottom of content area) --- */
.upload-toast {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
}

.upload-toast__info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.upload-toast__label {
  color: var(--color-text);
  font-weight: 500;
}

.upload-toast__progress {
  width: 200px;
  height: 4px;
  background: var(--color-bg-muted);
  border-radius: 2px;
  overflow: hidden;
}

.upload-toast__progress-bar {
  height: 100%;
  background: var(--color-success);
  border-radius: 2px;
  transition: width 0.3s;
}

.upload-toast__count {
  color: var(--color-text-muted);
}

.upload-toast__close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-base);
  padding: 2px 4px;
}

/* --- Drop overlay (drag-to-upload hint) --- */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: var(--color-selection-bg);
  border: 2px dashed var(--color-selection);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-selection);
  font-size: var(--text-lg);
  pointer-events: none;
  z-index: 10;
}

/* --- Create dropdown --- */
.create-dropdown {
  position: absolute;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 100;
  min-width: 160px;
  padding: 4px 0;
}

.create-dropdown__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: var(--text-sm);
  cursor: pointer;
}

.create-dropdown__item:hover {
  background: var(--color-bg-muted);
}

/* --- Toast notification --- */
.toast {
  position: fixed;
  top: 70px;
  right: var(--space-md);
  background: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  z-index: 1000;
  animation: toast-fade 2s ease forwards;
}

@keyframes toast-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Image grid (gallery view) --- */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}

.image-grid__item {
  aspect-ratio: 1;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.image-grid__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-grid__item--selected {
  border-color: var(--color-selection);
}

.image-grid__check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: var(--color-selection);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--color-white);
  font-size: 11px;
}

.image-grid__item--selected .image-grid__check {
  display: flex;
}

.image-grid__item.drag-over {
  border-color: var(--color-accent);
}

/* Flush modifier — removes padding/max-width for split-pane views */
.admin-content--flush {
  padding: 0;
  max-width: none;
}

/* About / generic content section */
.admin-section {
  max-width: 500px;
}

.admin-section h2 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  margin-bottom: var(--space-lg);
}

.form-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.save-status--success {
  font-size: var(--text-sm);
  color: var(--color-success);
  margin-left: var(--space-sm);
}

.save-status--error {
  font-size: var(--text-sm);
  color: var(--color-danger);
  margin-left: var(--space-sm);
}

.btn--sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.85rem;
}

.context-menu {
  position: fixed;
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 1000;
  min-width: 160px;
  padding: var(--space-xs) 0;
}

.context-menu__item {
  display: block;
  width: 100%;
  padding: var(--space-xs) var(--space-md);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--color-text);
}

.context-menu__item:hover {
  background: var(--color-bg-muted, #f0f0f0);
}

.context-menu__item--danger {
  color: var(--color-danger, #c53030);
}

