@import url("/css/tokens.css");

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.admin-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.admin-aside {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: var(--space-5);
  overflow-y: auto;
  max-height: 100vh;
}

.admin-main {
  padding: var(--space-6) var(--space-7);
  overflow-y: auto;
  max-height: 100vh;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-3);
  flex-wrap: wrap;
}

.admin-topbar__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.admin-topbar__title span {
  color: var(--accent);
}

.admin-topbar__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  transition: all var(--transition);
}

.btn--primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

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

.btn--ghost {
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn--danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.btn--danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn--small {
  padding: 6px 10px;
  font-size: 0.8rem;
}

/* Login screen */
.login-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-5);
}

.login-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6);
  width: 100%;
  max-width: 420px;
}

.login-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.login-card__header h1 {
  margin-bottom: 0;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-bottom: var(--space-2);
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: var(--space-5);
  font-size: 0.9rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Project list */
.aside-search {
  margin-bottom: var(--space-3);
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.project-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition);
  user-select: none;
}

.project-item:hover {
  border-color: var(--border-strong);
}

.project-item.is-active {
  border-color: var(--accent);
}

.project-item.is-dragging {
  opacity: 0.4;
}

.project-item__thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  flex-shrink: 0;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  overflow: hidden;
}

.project-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.project-item__title {
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-item__meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.project-item__meta .draft {
  color: var(--info);
  margin-left: 6px;
}

.project-item__handle {
  cursor: grab;
  color: var(--text-dim);
  padding: 0 4px;
}

/* Editor */
.editor {
  max-width: 920px;
}

.editor__section {
  margin-bottom: var(--space-7);
}

.editor__section h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: var(--space-3);
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-4);
}

.field__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

@media (max-width: 720px) {
  .field__row {
    grid-template-columns: 1fr;
  }
}

.field label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.field__hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.field__error {
  font-size: 0.8rem;
  color: #ef4444;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="url"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field input[readonly] {
  background: var(--bg-elev);
  color: var(--text-muted);
  cursor: not-allowed;
}

.field textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.5;
}

.field__inline {
  display: flex;
  gap: var(--space-2);
}

.field__inline input {
  flex: 1;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9rem;
}

.checkbox input {
  width: 18px;
  height: 18px;
}

/* Repeatable items (effects, steps) */
.items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--space-2);
  align-items: start;
}

.item--steps {
  grid-template-columns: 1fr 2fr auto;
}

.item input,
.item textarea {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.item textarea {
  resize: vertical;
  min-height: 64px;
}

.item__remove {
  align-self: stretch;
}

@media (max-width: 720px) {
  .item,
  .item--steps {
    grid-template-columns: 1fr;
  }
}

.items__add {
  margin-top: var(--space-3);
}

/* Images */
.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.image-card {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: grab;
}

.image-card.is-dragging {
  opacity: 0.4;
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card__btn {
  position: absolute;
  top: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}

.image-card__btn:hover {
  transform: scale(1.06);
}

.image-card__remove {
  right: 6px;
}

.image-card__remove:hover {
  background: rgba(239, 68, 68, 0.85);
}

.image-card__crop {
  right: 40px;
  font-size: 0.9rem;
}

.image-card__crop:hover {
  background: rgba(45, 161, 255, 0.85);
}

.cover-card {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 16 / 10;
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.cover-card img,
.cover-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.cover-card--video {
  aspect-ratio: 16 / 10;
}

.upload-zone {
  margin-top: var(--space-3);
  padding: var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}

.upload-zone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone input[type="file"] {
  display: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 0.9rem;
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  max-width: 360px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  border-color: var(--success);
}

.toast--error {
  border-color: #ef4444;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
}

.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  max-width: 520px;
  width: 100%;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: var(--space-3);
}

.modal p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: var(--space-4);
  line-height: 1.5;
}

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

/* Cropper */
.cropper {
  max-width: 720px;
}

.cropper__ratios {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-3);
}

.cropper__ratio {
  border: 1px solid var(--border);
}

.cropper__ratio.is-active {
  border-color: var(--accent);
  background: rgba(45, 161, 255, 0.12);
  color: var(--text);
}

.cropper__stage {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  margin: 0 auto;
}

.cropper__stage.is-dragging {
  cursor: grabbing;
}

.cropper__image {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.cropper__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.cropper__controls .cropper__zoom {
  flex: 1;
  accent-color: var(--accent);
}

.cropper__zoom-label {
  min-width: 56px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.is-error {
  border-color: #ef4444 !important;
}

.editor-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--text-dim);
  font-size: 1rem;
}

@media (max-width: 880px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .admin-aside {
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .admin-main {
    max-height: none;
  }
}
