/* Teona Admin — design tokens from main site (globals.css + buttons.module.css) */

:root {
  /* Brand colors (theme-invariant) */
  --color-brand-red: #ca5252;
  --color-accent-red: #dc3d3d;
  --color-gray-mid: #606060;

  /* Editorial text tokens */
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #4a4a4a;
  --color-text-tertiary: #8a8a8a;
  --color-surface-light: #f5f5f5;

  /* Semantic BG tokens */
  --bg-page: #fff;
  --bg-surface: #f5f5f5;
  --bg-modal: #fff;

  /* Borders */
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-medium: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);

  /* Icon tokens */
  --icon-on-light-bg: #000;
  --icon-on-image: #fff;

  /* Button tokens */
  --button-dark-bg: #111;
  --button-dark-text: #fff;
  --button-accent-bg: var(--color-brand-red);
  --button-accent-text: #fff;
  --button-disabled-bg: #ccc;
  --button-disabled-text: #666;

  /* Spacing scale (4px baseline) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 80px;
  --space-10: 96px;
  --space-12: 128px;

  /* Font-size scale */
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-base: 16px;
  --fs-md: 18px;
  --fs-lg: 21px;
  --fs-xl: 26px;
  --fs-2xl: 32px;
  --fs-3xl: 44px;
  --fs-display: 56px;

  /* Line-heights */
  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-base: 1.55;
  --lh-loose: 1.75;

  /* Typography */
  --font-sans: 'PT Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Modal overlay */
  --bg-backdrop: rgba(0, 0, 0, 0.65);
  --bg-backdrop-cart: rgba(0, 0, 0, 0.42);
}

/* Dark theme overrides */
[data-theme='dark'] {
  --color-text-primary: #f5f5f5;
  --color-text-secondary: #b0b0b0;
  --color-text-tertiary: #777;
  --color-surface-light: #2a2a2a;

  --bg-page: #1a1a1a;
  --bg-surface: #2a2a2a;
  --bg-modal: #222;

  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-strong: rgba(255, 255, 255, 0.25);

  --icon-on-light-bg: #f5f5f5;
  --button-dark-bg: #f5f5f5;
  --button-dark-text: #1a1a1a;
  --button-disabled-bg: #444;
  --button-disabled-text: #888;
}

/* Reset & base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scrollbar-gutter: stable;
}

body {
  background: var(--bg-page);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--fs-md);
  line-height: var(--lh-base);
  min-height: 100vh;
  padding: var(--space-6);
  transition:
    background-color 225ms ease,
    color 225ms ease;
}

@media (prefers-reduced-motion: reduce) {
  body {
    transition: none;
  }
}

a {
  text-decoration: none;
  color: var(--color-text-primary);
  transition: color 225ms ease;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
}
h1 {
  font-size: var(--fs-3xl);
}
h2 {
  font-size: var(--fs-2xl);
}
h3 {
  font-size: var(--fs-lg);
}
h4 {
  font-size: var(--fs-md);
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Screen containers */
.screen {
  min-height: calc(100vh - var(--space-12));
  padding: var(--space-4);
}

/* Auth card */
.auth-card {
  max-width: 420px;
  margin: 10vh auto;
  background: var(--bg-modal);
  border: 1px solid var(--border-medium);
  border-radius: var(--space-4);
  padding: var(--space-6);
  box-shadow: 0 20px 80px var(--bg-backdrop);
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar h1 {
  margin: 0;
}
#session-user {
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
}

/* Tabs */
.tabs {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-3);
}
.tab,
button {
  border: none;
  border-radius: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  background: var(--button-dark-bg);
  color: var(--button-dark-text);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-sm);
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition:
    background-color 225ms ease,
    color 225ms ease;
}
.tab:hover,
button:hover {
  background: var(--button-accent-bg);
  color: var(--button-accent-text);
}
.tab.secondary,
button.secondary {
  background: var(--bg-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--border-medium);
}
.tab.secondary:hover,
button.secondary:hover {
  background: var(--bg-page);
  color: var(--color-text-primary);
  border-color: var(--color-brand-red);
}
.tab.active {
  background: var(--color-brand-red);
  color: #fff;
}
.danger {
  background: var(--button-accent-bg);
  color: var(--button-accent-text);
}
.danger:hover {
  filter: brightness(1.1);
}

/* Panels */
.panel {
  display: none;
}
.panel.active {
  display: block;
}
main {
  overflow: visible;
  max-height: none;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.form-actions {
  margin-top: var(--space-4);
}

/* Stack layout for forms */
.stack {
  display: grid;
  gap: var(--space-4);
}

/* Card */
.card {
  background: var(--bg-modal);
  border: 1px solid var(--border-medium);
  border-radius: var(--space-4);
  padding: var(--space-4);
}
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}
.detail-header h2 {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
  line-height: 24px;
  display: flex;
  align-items: center;
}
.publish-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.publish-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border-medium);
  border-radius: 12px;
  transition: background 225ms ease;
  display: block;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 225ms ease;
}
.publish-toggle input:checked + .toggle-slider {
  background: var(--color-brand-red);
}
.publish-toggle input:checked + .toggle-slider::after {
  transform: translateX(20px);
}
.publish-toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--color-brand-red);
  outline-offset: 2px;
}

/* Split layout */
.split {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: var(--space-4);
}

/* List */
.list {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
}
.list.compact {
  gap: var(--space-2);
}

/* List items - two column layout */
.list-item {
  border: 1px solid var(--border-medium);
  border-radius: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-surface);
  display: grid;
  grid-template-columns: 28px 64px 1fr;
  gap: var(--space-3);
  align-items: center;
  transition: background-color 225ms ease;
}
.list-item:hover {
  background: var(--bg-page);
  cursor: pointer;
}
.list-item.active {
  outline: 2px solid var(--color-brand-red);
}
.list-item.dragging {
  opacity: 0.5;
  outline: 2px dashed var(--color-brand-red);
}
.list-item[draggable='true'] {
  cursor: grab;
}
.list-item[draggable='true']:active {
  cursor: grabbing;
}
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--color-text-tertiary);
  cursor: grab;
  border-radius: var(--space-2);
  transition:
    color 225ms ease,
    background-color 225ms ease;
}
.drag-handle:hover {
  color: var(--color-brand-red);
  background: var(--bg-surface);
}
.drag-handle:active {
  cursor: grabbing;
}
.list-item-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--space-2);
  flex-shrink: 0;
}
.list-item-info {
  display: grid;
  gap: var(--space-1);
  text-align: left;
}
.list-item-title {
  font-weight: 600;
  font-size: var(--fs-base);
  color: var(--color-text-primary);
}
.list-item-meta {
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.status-published {
  color: var(--color-brand-red);
  font-weight: 600;
}
.status-hidden {
  color: var(--color-text-tertiary);
}
.status-hidden:hover {
  color: var(--button-accent-bg);
}

/* Texts tab */
#texts-list .list-item {
  grid-template-columns: 1fr;
  gap: var(--space-3);
  padding: var(--space-4);
  min-width: 0;
}
#texts-list .list-item-title {
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-2);
}
#texts-list textarea {
  min-height: 120px;
  height: auto;
  width: 100%;
  resize: vertical;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  padding: var(--space-3);
  font-family: var(--font-sans);
}
#texts-list .toolbar {
  margin-top: var(--space-2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.form-row label {
  width: 100%;
}

/* Form inputs */
label {
  display: grid;
  gap: var(--space-1);
  font-size: var(--fs-sm);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}
label > span {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

input,
select {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-4);
  background-color: var(--bg-surface);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--color-text-primary);
  border-radius: var(--space-3);
  transition:
    border-color 220ms ease,
    background-color 220ms ease;
}
textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-surface);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--color-text-primary);
  border-radius: var(--space-3);
  resize: none;
  transition:
    border-color 220ms ease,
    background-color 220ms ease;
  box-sizing: border-box;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-brand-red);
  background-color: var(--bg-page);
}

input[type='checkbox'] {
  width: auto;
  height: auto;
  margin-bottom: 0;
  background-color: transparent;
  cursor: pointer;
}

/* Fieldset */
fieldset {
  border: 1px solid var(--border-medium);
  border-radius: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
legend {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  padding: 0 var(--space-2);
}

/* Select */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a4a4a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-6);
}

/* Translate text link */
.translate-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: var(--color-text-tertiary);
  text-decoration: none;
  vertical-align: middle;
  margin-left: var(--space-2);
  cursor: pointer;
  transition: color 225ms ease, opacity 225ms ease;
  opacity: 0.7;
}
.translate-link:hover {
  color: var(--color-brand-red);
  opacity: 1;
}

/* Admin status toast */
#admin-status {
  position: fixed;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-brand-red);
  color: #fff;
  padding: var(--space-2) var(--space-5);
  border-radius: 999px;
  font-size: var(--fs-sm);
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
#admin-status.visible {
  opacity: 1;
}
#admin-status.error {
  background: var(--button-accent-bg);
}

/* Upload row */
.upload-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.upload-row label {
  flex: 1;
  min-width: 200px;
}

/* Muted text */
.muted {
  color: var(--color-text-tertiary);
  font-size: var(--fs-sm);
}

/* HR */
hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-5) 0;
}

/* Error text */
.error {
  color: var(--button-accent-bg);
  font-size: var(--fs-sm);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: var(--bg-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: var(--space-6);
}
.lightbox.hidden {
  display: none;
}
.lightbox img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--space-3);
  box-shadow: 0 20px 80px var(--bg-backdrop);
}
.lightbox-close {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  width: 40px;
  height: 40px;
  background: transparent;
  color: var(--icon-on-image);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  transition: color 225ms ease;
}
.lightbox-close:hover {
  color: var(--color-brand-red);
}
.lightbox-thumbs {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  justify-content: center;
}
.lightbox-thumbs img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--space-2);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 225ms ease;
}
.lightbox-thumbs img.active,
.lightbox-thumbs img:hover {
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .split {
    grid-template-columns: 1fr;
  }
  .toolbar {
    flex-direction: column;
  }
  .toolbar button {
    width: 100%;
  }
  .tabs {
    flex-wrap: wrap;
  }
}
