/* ============================================================
   WrAIte Resource Center — shared design system
   Extends the WrAIte Writing Space visual language.
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #111111;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #e5e5e5;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --coral: #ef6f61;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.04);
  --shadow-md: 0 6px 24px rgba(17, 17, 17, 0.06);
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* collection accent colors */
  --coll-ai-tools: #7c3aed;
  --coll-ai-tools-bg: #f3eefe;
  --coll-courses: #0891b2;
  --coll-courses-bg: #e6f7fb;
  --coll-articles: #ef6f61;
  --coll-articles-bg: #fdeceb;
  --coll-writing-tools: #22c55e;
  --coll-writing-tools-bg: #e9f9ef;
  --coll-other: #6b7280;
  --coll-other-bg: #f4f5f7;

  /* type accent colors (legacy) */
  --type-article: #ef6f61;
  --type-article-bg: #fdeceb;
  --type-video: #eab308;
  --type-video-bg: #fdf6e3;
  --type-link: #22c55e;
  --type-link-bg: #e9f9ef;
  --type-document: #3b82f6;
  --type-document-bg: #ebf2fe;

  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.2;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 15px;
}

img {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.material-icons-outlined {
  font-family: 'Material Icons Outlined';
  font-size: 1.35rem;
  line-height: 1;
  font-style: normal;
  font-weight: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   Layout
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 100dvh;
}

.app__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app__content {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 40px 72px;
}

/* ============================================================
   Sidebar (public — slim icon rail)
   ============================================================ */

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  width: 72px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 8px;
  z-index: 20;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.sidebar__logo img {
  width: 40px;
  height: 40px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  align-items: center;
  flex: 1;
}

.sidebar__link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar__link:hover {
  background: #f1f0ee;
  color: var(--text);
}

.sidebar__link.is-active {
  background: #eaf2fe;
  color: var(--blue-dark);
}

.sidebar__link.is-active.coral-active {
  background: #fdeceb;
  color: var(--coral);
}

.sidebar__link .material-icons-outlined {
  font-size: 1.5rem;
}

.sidebar__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sidebar__bottom a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar__bottom a:hover {
  background: #f1f0ee;
  color: var(--text);
}

/* ============================================================
   Sidebar (admin — wider, with labels)
   ============================================================ */

.sidebar--admin {
  width: 240px;
  align-items: stretch;
  padding: 18px 14px;
}

.sidebar--admin .sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar--admin .sidebar__brand img {
  width: 40px;
  height: 40px;
}

.sidebar--admin .sidebar__brandText {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar--admin .sidebar__brandText strong {
  font-family: var(--font-display);
  font-size: 15px;
}

.sidebar--admin .sidebar__brandText span {
  font-size: 12px;
  color: var(--text-secondary);
}

.sidebar--admin .sidebar__nav {
  align-items: stretch;
}

.sidebar--admin .sidebar__link {
  width: 100%;
  justify-content: flex-start;
  gap: 12px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
}

.sidebar--admin .sidebar__link.is-active {
  background: #eaf2fe;
  color: var(--blue-dark);
}

/* ============================================================
   Header
   ============================================================ */

.page-header {
  margin-bottom: 32px;
}

.page-header__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.lang-switch {
  margin-left: auto;
}

.lang-switch--top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

.page-header__title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-header__subtitle {
  margin-top: 8px;
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 640px;
}

.page-header__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.btn:hover {
  background: #f6f5f3;
}

.btn--primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

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

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover {
  background: #f1f0ee;
  color: var(--text);
}

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

.btn--danger:hover {
  background: #fdecec;
}

.btn--sm {
  padding: 7px 12px;
  font-size: 13px;
}

/* ============================================================
   Search
   ============================================================ */

.search {
  position: relative;
  max-width: 520px;
  margin-bottom: 28px;
}

.search__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search__input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 12px 16px 12px 46px;
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search__input::placeholder {
  color: var(--text-muted);
}

.search__input:hover {
  border-color: #d0cfcc;
}

.search__input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ============================================================
   Filters
   ============================================================ */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.type-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.type-tab:hover {
  border-color: #d0cfcc;
  color: var(--text);
}

.type-tab.is-active {
  background: #eaf2fe;
  border-color: var(--blue);
  color: var(--blue-dark);
  font-weight: 600;
}

.filter-select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
}

.filter-select:focus {
  outline: none;
  border-color: var(--blue);
}

.filter__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 4px;
}

.filters__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================
   Resource grid + cards
   ============================================================ */

.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.resource-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  min-height: 250px;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.resource-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: #d8d7d4;
}

.resource-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.resource-card__typeIcon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.resource-card__updated {
  font-size: 12px;
  color: var(--text-muted);
}

.resource-card__title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 8px;
}

.resource-card__thumb-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: top;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.resource-card__desc {
  font-size: 14px;
  color: var(--text-secondary);
  flex: 1;
  margin-bottom: 18px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-clamp: 3;
  overflow: hidden;
}

.resource-card__footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.resource-card__source {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.resource-card__source .material-icons-outlined {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.resource-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.resource-card__link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--radius-lg);
}

/* ============================================================
   Tags & badges
   ============================================================ */

.tag {
  display: inline-flex;
  align-items: center;
  background: #f3f2f0;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}

.tag--link {
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag--link:hover {
  border-color: var(--blue);
  color: var(--blue-dark);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge--article { background: var(--type-article-bg); color: var(--type-article); }
.badge--video   { background: var(--type-video-bg); color: #a16207; }
.badge--link    { background: var(--type-link-bg); color: #15803d; }
.badge--document{ background: var(--type-document-bg); color: var(--blue-dark); }

/* Collection (category) badges */
.badge--ai-tools      { background: var(--coll-ai-tools-bg); color: var(--coll-ai-tools); }
.badge--courses       { background: var(--coll-courses-bg); color: var(--coll-courses); }
.badge--articles      { background: var(--coll-articles-bg); color: var(--coll-articles); }
.badge--writing-tools { background: var(--coll-writing-tools-bg); color: var(--coll-writing-tools); }
.badge--other         { background: var(--coll-other-bg); color: var(--coll-other); }

.type-icon--article,
.type-icon--video,
.type-icon--link,
.type-icon--document,
.type-icon--ai-tools,
.type-icon--courses,
.type-icon--articles,
.type-icon--writing-tools,
.type-icon--other {
  background: rgba(17, 17, 17, 0.05);
  color: #463628;
}

/* Collection-specific icon colours (override the defaults above) */
.type-icon--ai-tools      { background: var(--coll-ai-tools-bg);      color: var(--coll-ai-tools); }
.type-icon--courses       { background: var(--coll-courses-bg);       color: var(--coll-courses); }
.type-icon--articles      { background: var(--coll-articles-bg);      color: var(--coll-articles); }
.type-icon--writing-tools { background: var(--coll-writing-tools-bg); color: var(--coll-writing-tools); }
.type-icon--other         { background: var(--coll-other-bg);         color: var(--coll-other); }

/* ============================================================
   States: loading / empty / error / not-found
   ============================================================ */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  gap: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.state__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: #f3f2f0;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.state__title {
  font-size: 20px;
  font-weight: 700;
}

.state__text {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 420px;
}

.state__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.loading-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  animation: pulse 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.9); }
  40% { opacity: 1; transform: scale(1); }
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 36px;
}

.pagination__btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s ease;
}

.pagination__btn:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue-dark);
}

.pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination__info {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============================================================
   Detail page
   ============================================================ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.breadcrumb a {
  color: var(--blue);
  font-weight: 500;
}

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

.breadcrumb .sep {
  color: var(--text-muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-bg, #ebf2fe);
  border: 1px solid var(--blue, #3b82f6);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  margin-bottom: 20px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.back-link:hover {
  color: #fff;
  background: var(--blue, #3b82f6);
}

.detail__header {
  margin-bottom: 28px;
}

.detail__badge-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.detail__title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  max-width: 760px;
}

.detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.detail__meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detail__body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 40px;
  align-items: start;
}

.detail__main {
  min-width: 0;
}

.detail__desc {
  font-size: 16px;
  line-height: 1.7;
  color: #333333;
  margin: 24px 0 28px;
}

.detail__desc p {
  margin: 0 0 14px;
}

.detail__desc p:last-child {
  margin-bottom: 0;
}

.detail__desc h3,
.detail__desc h4 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin: 22px 0 10px;
}

.detail__desc ul,
.detail__desc ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.detail__desc li {
  margin-bottom: 6px;
}

.detail__desc blockquote {
  margin: 0 0 14px;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}

.detail__desc a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.detail__desc a:hover {
  color: var(--blue-dark);
}

.detail__actions {
  margin-bottom: 8px;
}

.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 20px;
}

.preview-card__thumb {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #f1f0ee, #e9e8e5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-card__thumb .material-icons-outlined {
  font-size: 3rem;
  color: var(--text-muted);
}

.preview-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.preview-card__video {
  aspect-ratio: 16 / 9;
}

.preview-card__video iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.preview-card__body {
  padding: 18px;
}

.preview-card__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.preview-card__domain {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.open-resource-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s ease;
}

.open-resource-btn:hover {
  background: var(--blue-dark);
}

/* Detail sidebar */

.detail__aside {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.detail__aside-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 16px;
}

.detail__info-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail__info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail__info-label {
  font-size: 12px;
  color: var(--text-muted);
}

.detail__info-value {
  font-size: 14px;
  font-weight: 500;
  word-break: break-word;
}

.detail__tags {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ============================================================
   Admin table
   ============================================================ */

.admin-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.admin-toolbar .search {
  flex: 1;
  min-width: 240px;
  max-width: none;
}

.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 760px;
}

.admin-table th {
  text-align: left;
  padding: 14px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  white-space: nowrap;
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f0efec;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: #fafaf9;
}

.cell-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.cell-title__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.cell-title__text {
  font-weight: 600;
  line-height: 1.3;
}

.cell-title__domain {
  font-size: 12px;
  color: var(--text-muted);
}

.visibility-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.visibility-pill--everyone { background: #e9f9ef; color: #15803d; }
.visibility-pill--members  { background: #ebf2fe; color: var(--blue-dark); }
.visibility-pill--draft    { background: #f3f2f0; color: var(--text-secondary); }

.row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: #f1f0ee;
  color: var(--text);
}

.icon-btn--danger:hover {
  background: #fdecec;
  color: #dc2626;
}

/* ============================================================
   Forms
   ============================================================ */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 760px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-field--full {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.form-field label .required {
  color: var(--coral);
}

.form-field input,
.form-field select,
.form-field textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 11px 13px;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field input:hover,
.form-field select:hover,
.form-field textarea:hover {
  border-color: #d0cfcc;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-field textarea {
  resize: vertical;
  min-height: 110px;
}

.form-field .hint {
  font-size: 12px;
  color: var(--text-muted);
}

.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.field-error {
  font-size: 12px;
  color: #dc2626;
  font-weight: 500;
}

.field-char-count {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

/* Rich text editor */

.rte {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.rte:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.rte__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  background: #fafaf9;
}

.rte__toolbar button {
  width: 34px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}

.rte__toolbar button:hover {
  background: #eae9e6;
  color: var(--text);
}

.rte__editor {
  min-height: 160px;
  padding: 14px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  outline: none;
}

.rte__editor p {
  margin: 0 0 12px;
}

.rte__editor p:last-child {
  margin-bottom: 0;
}

.rte__editor h3,
.rte__editor h4 {
  font-size: 18px;
  font-weight: 700;
  margin: 18px 0 8px;
}

.rte__editor ul,
.rte__editor ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.rte__editor li {
  margin-bottom: 6px;
}

.rte__editor blockquote {
  margin: 0 0 12px;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}

.rte__editor a {
  color: var(--blue);
  text-decoration: underline;
}

.rte__editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

/* Thumbnail upload */

.thumb-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.thumb-upload__url {
  flex: 1;
  min-width: 200px;
}

.thumb-upload__url input {
  width: 100%;
}

.thumb-upload__sep {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.thumb-preview {
  position: relative;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: inline-block;
}

.thumb-preview img {
  display: block;
  max-height: 160px;
  width: auto;
}

.thumb-preview__remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.thumb-preview__remove:hover {
  color: #dc2626;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Tags chip input */

.tags-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 8px;
}

.tags-input:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.tags-input .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3f2f0;
  border-radius: 999px;
  padding: 4px 8px 4px 12px;
  font-size: 13px;
  font-weight: 500;
}

.tags-input .chip button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.tags-input .chip button:hover {
  color: #dc2626;
}

.tags-input input {
  flex: 1;
  min-width: 120px;
  border: none;
  outline: none;
  padding: 6px;
  background: transparent;
}

/* Live preview */

.preview-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  padding: 20px;
}

.preview-panel__title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 14px;
}

.form-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
}

.form-layout .preview-panel {
  position: sticky;
  top: 24px;
}

/* Toast / messages */

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: 320px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast--success { background: #16a34a; }
.toast--error { background: #dc2626; }

.inline-message {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
}

.inline-message--success {
  background: #e9f9ef;
  color: #15803d;
  border: 1px solid #b9e8c8;
}

.inline-message--error {
  background: #fdecec;
  color: #b91c1c;
  border: 1px solid #f5c2c2;
}

/* ============================================================
   Login
   ============================================================ */

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: min(92vw, 420px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}

.login-card__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  text-align: center;
}

.login-card__logo img {
  width: 64px;
  height: 64px;
}

.login-card__title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

.login-card__subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-form .form-field input {
  padding: 13px 14px;
}

.login-form .btn--primary {
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: 15px;
}

.login-card__hint {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1024px) {
  .app__content {
    padding: 28px 24px 64px;
  }

  .resource-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail__body {
    grid-template-columns: 1fr;
  }

  .detail__aside {
    order: -1;
  }

  .form-layout {
    grid-template-columns: 1fr;
  }

  .form-layout .preview-panel {
    position: static;
  }
}

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

  .sidebar,
  .sidebar--admin {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--border);
  }

  .sidebar__logo {
    display: none;
  }

  .sidebar__nav {
    flex-direction: row;
    flex: none;
    justify-content: center;
  }

  .sidebar__bottom {
    flex-direction: row;
  }

  .sidebar--admin {
    width: 100%;
    overflow-x: auto;
  }

  .sidebar--admin .sidebar__brand {
    display: none;
  }

  .sidebar--admin .sidebar__nav {
    flex-direction: row;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .sidebar--admin .sidebar__link {
    width: auto;
    white-space: nowrap;
  }

  .app__content {
    padding: 24px 18px 96px;
  }

  .resource-grid {
    grid-template-columns: 1fr;
  }

  .page-header__title {
    font-size: 28px;
  }

  .detail__title {
    font-size: 26px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters__right {
    margin-left: 0;
    width: 100%;
  }

  .filter-select {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .app__content {
    padding: 20px 14px 88px;
  }

  .resource-card {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
