/* ────────────────────────────────────────────────────────────
   OH-Previews — Design System
   Tokens and components shared across admin and client views
   ──────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');

/* ── Tokens ─────────────────────────────────────────────────── */
/* Color tokens live in theme.css (loaded before this file).    */
:root {
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --transition:    .15s ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 14px; overflow-y: scroll; scrollbar-gutter: stable; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--btn-hover); }

/* ── Logo mark ──────────────────────────────────────────────── */
.logo-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--logo-bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-mark svg { width: 14px; height: 14px; }
.logo-mark-lg {
  width: 36px; height: 36px;
  border-radius: 10px;
}
.logo-mark-lg svg { width: 18px; height: 18px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px; font-weight: 500;
  background: var(--btn);
  color: var(--text);
  transition: background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: scale(.98); }

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

.btn-danger {
  background: var(--btn-danger-bg);
  color: var(--btn-danger-text);
}
.btn-danger:hover { background: var(--btn-danger-hover); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
  background: var(--btn);
  border: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.btn-icon:hover { background: var(--btn-hover); color: var(--text); }

/* ── Form elements ───────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text);
  outline: none;
  transition: border var(--transition), background var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--text);
  background: var(--surface);
}
.form-textarea { resize: vertical; min-height: 80px; padding: 8px 12px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 11px; font-weight: 500;
  background: var(--btn);
  color: var(--text-muted);
}
.badge-green { background: var(--badge-green-bg); color: var(--badge-green-text); }
.badge-blue  { background: var(--badge-blue-bg);  color: var(--badge-blue-text);  }
.badge-red   { background: var(--badge-red-bg);   color: var(--badge-red-text);   }

/* ── Tags (filter chips) ─────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center;
  padding: 5px 13px;
  border-radius: 100px;
  font-size: 12px; font-weight: 500;
  background: var(--btn);
  color: var(--text-muted);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.tag.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.tag:hover:not(.active) { background: var(--btn-hover); color: var(--text); }
/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  position: sticky; top: 0; z-index: 100;
}
.topbar-brand {
  font-size: 15px; font-weight: 600; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 8px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--btn);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
}

/* ── Modal overlay ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(18,18,20,.45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px;
  padding: 28px;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--btn);
  border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-muted);
}
.modal-close:hover { background: var(--btn-hover); color: var(--text); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

/* ── Toast notifications ─────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 500;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
  max-width: 320px;
}
.toast.success { background: #15803D; }
.toast.error   { background: #DC2626; }
@keyframes toastIn {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 64px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state-desc { font-size: 13px; color: var(--text-muted); }

/* ── Loading spinner ─────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute; inset: 0;
  background: var(--loading-overlay);
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit;
  z-index: 10;
}

/* ── Utilities ───────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.mono { font-family: 'DM Mono', monospace; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }

/* ── Toggle switch ───────────────────────────────────────────── */
.toggle-wrap {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-muted);
}
.toggle {
  width: 34px; height: 19px;
  background: var(--toggle-off);
  border-radius: 100px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid var(--toggle-border);
  flex-shrink: 0;
}
.toggle.on { background: var(--toggle-on); }
.toggle::after {
  content: '';
  position: absolute;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #FFFFFF;
  top: 50%; left: 2px;
  transform: translateY(-50%);
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on::after { transform: translateY(-50%) translateX(15px); }

/* ── Share link banner ───────────────────────────────────────── */
.share-link-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--share-banner-bg);
  border: 1px solid var(--share-banner-bd);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px; color: var(--share-banner-text);
  flex-wrap: wrap;
}
.share-link-banner code {
  font-family: 'DM Mono', monospace;
  background: var(--share-banner-bg);
  padding: 2px 7px; border-radius: 5px;
  font-size: 11px;
}

/* ── Drag-and-drop upload zone ───────────────────────────────── */
.upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg);
  cursor: pointer;
  transition: all var(--transition);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--text-muted);
  background: var(--surface);
}
.upload-zone-icon { font-size: 26px; margin-bottom: 8px; }
.upload-zone strong { color: var(--text); font-weight: 500; }
.upload-zone small { font-size: 11px; color: var(--text-faint); }

/* ── Breadcrumb ──────────────────────────────────────────────── */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted);
}
.breadcrumb .crumb-link { cursor: pointer; }
.breadcrumb .crumb-link:hover { color: var(--text); }
.breadcrumb-sep { opacity: .4; }

/* ── Tab bar ─────────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 2px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border-light);
}
.tab {
  padding: 10px 14px;
  font-size: 13px; font-weight: 400;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all var(--transition);
}
.tab.active { color: var(--text); font-weight: 500; border-color: var(--text); }
.tab:hover:not(.active) { color: var(--text); }

/* ── Stats bar ───────────────────────────────────────────────── */
.stats-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 28px;
  border-top: 1px solid var(--border-light);
  background: var(--surface);
  font-size: 12px; color: var(--text-muted);
  flex-wrap: wrap;
}
.stat-item { display: flex; align-items: center; gap: 5px; }
.stat-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
}

/* ── Skeleton loading ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border-light) 25%,
    var(--border)       50%,
    var(--border-light) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.skeleton-thumb  { height: 130px; }
.skeleton-line   { height: 12px; border-radius: 6px; margin: 0; }
.skeleton-line-sm { height: 10px; border-radius: 6px; margin: 0; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .tab-bar { padding: 0 16px; }
  .stats-bar { padding: 10px 16px; }

  /* Prevent iOS Safari zoom on input focus (triggered when font-size < 16px) */
  input, textarea, select { font-size: 16px !important; }
}
