/**
 * ============================================================================
 * ALPINE.JS PROTOTYPE FRAMEWORK — News Component Styles
 * ============================================================================
 * Styling for the News & Announcements admin interface.
 * Prefix: nw-
 *
 * Copyright (c) 2026 Foundation Tutator. All rights reserved.
 * ============================================================================
 */

/* ── Editor page layout ────────────────────────────────────────── */
.nw-editor-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 24px;
}

.nw-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.nw-editor-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-gray-800, #1e293b);
  margin: 0;
}

/* ── Title input ───────────────────────────────────────────────── */
.nw-title-input {
  width: 100%;
  font-size: 22px;
  font-weight: 600;
  padding: 12px 16px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  background: var(--card-bg, #fff);
  color: var(--color-gray-800, #1e293b);
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 16px;
}

.nw-title-input:focus {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px var(--color-primary-bg, #eff6ff);
}

.nw-title-input::placeholder {
  color: var(--color-gray-400, #94a3b8);
  font-weight: 400;
}

/* ── Quill editor wrapper ──────────────────────────────────────── */
.nw-editor-wrap {
  margin-bottom: 20px;
}

.nw-editor-wrap .ql-container {
  min-height: 300px;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  border-radius: 0 0 8px 8px;
  border-color: var(--border-color, #e2e8f0);
  background: var(--card-bg, #fff);
}

.nw-editor-wrap .ql-toolbar {
  border-radius: 8px 8px 0 0;
  border-color: var(--border-color, #e2e8f0);
  background: var(--content-bg, #f8fafc);
}

.nw-editor-wrap .ql-editor {
  min-height: 280px;
  line-height: 1.7;
  color: var(--color-gray-800, #1e293b);
}

.nw-editor-wrap .ql-editor.ql-blank::before {
  color: var(--color-gray-400, #94a3b8);
  font-style: normal;
}

/* ── Metadata fields row ───────────────────────────────────────── */
.nw-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.nw-meta-row label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-gray-600, #475569);
  margin-bottom: 4px;
}

.nw-meta-row input,
.nw-meta-row select {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  background: var(--card-bg, #fff);
  color: var(--color-gray-800, #1e293b);
  outline: none;
}

.nw-meta-row input:focus,
.nw-meta-row select:focus {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px var(--color-primary-bg, #eff6ff);
}

/* ── Hero image preview ────────────────────────────────────────── */
.nw-hero-image {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  margin-top: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color, #e2e8f0);
}

/* ── Pin checkbox ──────────────────────────────────────────────── */
.nw-pin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.nw-pin-row label {
  font-size: 14px;
  color: var(--color-gray-600, #475569);
  cursor: pointer;
  user-select: none;
}

/* ── Toolbar buttons ───────────────────────────────────────────── */
.nw-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.nw-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.nw-btn-primary {
  background: var(--color-primary, #2563eb);
  color: #fff;
}
.nw-btn-primary:hover {
  background: var(--color-primary-dark, #1d4ed8);
}

.nw-btn-secondary {
  background: var(--card-bg, #fff);
  color: var(--color-gray-600, #475569);
  border-color: var(--border-color, #e2e8f0);
}
.nw-btn-secondary:hover {
  background: var(--content-bg, #f8fafc);
}

.nw-btn-danger {
  background: var(--color-error-bg, #fef2f2);
  color: var(--color-error, #ef4444);
  border-color: var(--color-error, #ef4444);
}
.nw-btn-danger:hover {
  background: var(--color-error, #ef4444);
  color: #fff;
}

/* ── Content display (read-only rendered HTML) ─────────────────── */
.nw-content-display {
  padding: 20px 24px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-gray-800, #1e293b);
}

.nw-content-display h1 { font-size: 24px; font-weight: 700; margin: 20px 0 10px; }
.nw-content-display h2 { font-size: 20px; font-weight: 600; margin: 18px 0 8px; }
.nw-content-display h3 { font-size: 17px; font-weight: 600; margin: 16px 0 6px; }
.nw-content-display p { margin: 0 0 12px; }
.nw-content-display ul, .nw-content-display ol { margin: 0 0 12px; padding-left: 24px; }
.nw-content-display li { margin-bottom: 4px; }
.nw-content-display a { color: var(--color-primary, #2563eb); text-decoration: underline; }
.nw-content-display img { max-width: 100%; border-radius: 8px; margin: 12px 0; }
.nw-content-display blockquote {
  border-left: 4px solid var(--color-primary, #2563eb);
  padding: 8px 16px;
  margin: 12px 0;
  background: var(--color-primary-bg, #eff6ff);
  border-radius: 0 6px 6px 0;
}

/* ── Status badges ─────────────────────────────────────────────── */
.nw-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 99px;
  text-transform: capitalize;
}
.nw-badge-draft {
  background: var(--color-warning-bg, #fffbeb);
  color: var(--color-warning, #f59e0b);
}
.nw-badge-published {
  background: var(--color-success-bg, #f0fdf4);
  color: var(--color-success, #22c55e);
}
.nw-badge-archived {
  background: #f1f5f9;
  color: var(--color-gray-500, #64748b);
}

/* ── Detail view overrides ─────────────────────────────────────── */
.nw-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.nw-detail-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--color-primary-bg, #eff6ff);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-primary, #2563eb);
}

.nw-detail-meta {
  flex: 1;
  min-width: 0;
}

.nw-detail-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-gray-800, #1e293b);
  margin: 0 0 4px;
}

.nw-detail-sub {
  font-size: 13px;
  color: var(--color-gray-500, #64748b);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nw-detail-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Image drop zone & gallery ─────────────────────────────────── */
.nw-drop-zone {
  border: 2px dashed var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--content-bg, #f8fafc);
}
.nw-drop-zone:hover,
.nw-drop-active {
  border-color: var(--color-primary, #2563eb);
  background: var(--color-primary-bg, #eff6ff);
}

.nw-image-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.nw-gallery-item {
  position: relative;
  width: 120px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color, #e2e8f0);
}

.nw-gallery-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nw-gallery-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.nw-gallery-item:hover .nw-gallery-remove {
  opacity: 1;
}

/* ── Office multi-select picker ────────────────────────────────── */
.nw-office-picker {
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 12px;
  background: var(--card-bg, #fff);
  max-height: 200px;
  overflow-y: auto;
}

.nw-office-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nw-office-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-gray-800, #1e293b);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.1s;
}
.nw-office-item:hover {
  background: var(--color-primary-bg, #eff6ff);
}

/* ── View toggle bar ──────────────────────────────────────────── */
.nw-view-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 16px 4px;
}

.nw-view-tabs {
  display: inline-flex;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
}

.nw-view-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-gray-500, #64748b);
  background: var(--card-bg, #fff);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nw-view-tab:not(:last-child) {
  border-right: 1px solid var(--border-color, #e2e8f0);
}

.nw-view-tab.active {
  background: var(--color-primary, #2563eb);
  color: #fff;
}

.nw-view-tab:hover:not(.active) {
  background: var(--content-bg, #f8fafc);
}

/* ── Admin feed view ─────────────────────────────────────────── */
.nw-admin-feed {
  max-width: 700px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.nw-feed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.nw-feed-count {
  font-size: 14px;
  color: var(--color-gray-500, #64748b);
}

.nw-admin-card {
  cursor: default;
}

.nw-admin-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.nw-card-preview {
  padding: 4px 20px 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-gray-600, #475569);
}

.nw-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 16px 10px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  margin: 0 20px;
  padding-left: 0;
  padding-right: 0;
}

.nw-card-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-gray-500, #64748b);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nw-card-action:hover {
  background: var(--content-bg, #f8fafc);
  color: var(--color-gray-800, #1e293b);
}

.nw-card-action-success {
  color: var(--color-success, #22c55e);
}

.nw-card-action-success:hover {
  background: var(--color-success-bg, #f0fdf4);
  color: var(--color-success, #22c55e);
}

.nw-card-action-danger:hover {
  background: var(--color-error-bg, #fef2f2);
  color: var(--color-error, #ef4444);
}

/* ── Disabled post card ──────────────────────────────────────── */
.nw-card-disabled {
  opacity: 0.55;
  position: relative;
}

.nw-card-disabled:hover {
  opacity: 0.8;
}

/* ── Engagement stats panel ────────────────────────────────────── */
.nw-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.nw-stat-card {
  text-align: center;
  padding: 14px 8px;
  background: var(--content-bg, #f8fafc);
  border-radius: 10px;
  border: 1px solid var(--border-color, #e2e8f0);
}

.nw-stat-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.nw-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-gray-800, #1e293b);
  line-height: 1.2;
}

.nw-stat-label {
  font-size: 12px;
  color: var(--color-gray-500, #64748b);
  margin-top: 2px;
}

.nw-stats-section {
  margin-bottom: 20px;
}

.nw-stats-section:last-child {
  margin-bottom: 0;
}

.nw-stats-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-gray-600, #475569);
  margin-bottom: 10px;
}

/* ── Device breakdown bars ──────────────────────────────── */
.nw-device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.nw-device-label {
  font-size: 13px;
  color: var(--color-gray-600, #475569);
  width: 64px;
  flex-shrink: 0;
}

.nw-device-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--content-bg, #f1f5f9);
  border-radius: 4px;
  overflow: hidden;
}

.nw-device-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.nw-device-pct {
  font-size: 12px;
  color: var(--color-gray-500, #64748b);
  width: 70px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Views table ────────────────────────────────────────── */
.nw-views-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
}

.nw-views-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.nw-views-table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--color-gray-600, #475569);
  background: var(--content-bg, #f8fafc);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  white-space: nowrap;
}

.nw-views-table td {
  padding: 7px 12px;
  color: var(--color-gray-800, #1e293b);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  white-space: nowrap;
}

.nw-views-table tbody tr:last-child td {
  border-bottom: none;
}

.nw-views-table tbody tr:hover {
  background: var(--color-primary-bg, #eff6ff);
}

/* ── Device badges ──────────────────────────────────────── */
.nw-device-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: capitalize;
}

.nw-device-desktop {
  background: var(--color-primary-bg, #eff6ff);
  color: var(--color-primary, #2563eb);
}

.nw-device-mobile {
  background: var(--color-success-bg, #f0fdf4);
  color: var(--color-success, #22c55e);
}

.nw-device-tablet {
  background: var(--color-warning-bg, #fffbeb);
  color: var(--color-warning, #f59e0b);
}

/* ── Analytics Dashboard ───────────────────────────────────────── */
.nw-analytics-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.nw-analytics-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.nw-analytics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.nw-analytics-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  padding: 18px 12px 14px;
  text-align: center;
  transition: box-shadow 0.15s;
}

.nw-analytics-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.nw-analytics-card-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.nw-analytics-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-gray-800, #1e293b);
  line-height: 1.1;
}

.nw-analytics-card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-gray-500, #64748b);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nw-analytics-card-sub {
  font-size: 11px;
  color: var(--color-gray-400, #94a3b8);
  margin-top: 4px;
}

/* ── Analytics section blocks ─────────────────────────────────── */
.nw-analytics-section {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
}

.nw-analytics-section:last-child {
  margin-bottom: 0;
}

.nw-analytics-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  font-size: 15px;
  font-weight: 600;
  color: var(--color-gray-800, #1e293b);
}

.nw-analytics-sub-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-gray-600, #475569);
  margin-bottom: 12px;
}

.nw-analytics-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.nw-analytics-sub-section {
  padding: 16px 20px;
}

.nw-analytics-sub-section:first-child {
  border-right: 1px solid var(--border-color, #e2e8f0);
}

/* ── Top posts table ──────────────────────────────────────────── */
.nw-top-posts-table-wrap {
  overflow-x: auto;
}

.nw-top-posts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.nw-top-posts-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-gray-500, #64748b);
  background: var(--content-bg, #f8fafc);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  white-space: nowrap;
}

.nw-top-posts-table td {
  padding: 10px 14px;
  color: var(--color-gray-800, #1e293b);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.nw-top-posts-table tbody tr:last-child td {
  border-bottom: none;
}

.nw-top-post-row {
  cursor: pointer;
  transition: background 0.1s;
}

.nw-top-post-row:hover {
  background: var(--color-primary-bg, #eff6ff);
}

.nw-top-rank {
  font-weight: 700;
  color: var(--color-gray-400, #94a3b8);
  width: 36px;
  text-align: center;
}

.nw-top-title {
  font-weight: 500;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Horizontal bar chart ─────────────────────────────────────── */
.nw-bar-chart {
  padding: 16px 20px;
}

.nw-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.nw-bar-row:last-child {
  margin-bottom: 0;
}

.nw-bar-label {
  font-size: 13px;
  color: var(--color-gray-600, #475569);
  width: 72px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nw-bar-track {
  flex: 1;
  height: 10px;
  background: var(--content-bg, #f1f5f9);
  border-radius: 5px;
  overflow: hidden;
}

.nw-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.nw-bar-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-gray-600, #475569);
  min-width: 50px;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Activity feed ────────────────────────────────────────────── */
.nw-activity-feed {
  max-height: 480px;
  overflow-y: auto;
}

.nw-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  transition: background 0.1s;
}

.nw-activity-item:last-child {
  border-bottom: none;
}

.nw-activity-item:hover {
  background: var(--content-bg, #f8fafc);
}

.nw-activity-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--content-bg, #f1f5f9);
  margin-top: 1px;
}

.nw-activity-content {
  flex: 1;
  min-width: 0;
}

.nw-activity-text {
  font-size: 13px;
  color: var(--color-gray-800, #1e293b);
  line-height: 1.4;
  display: block;
}

.nw-activity-time {
  font-size: 11px;
  color: var(--color-gray-400, #94a3b8);
  margin-top: 2px;
  display: block;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nw-meta-row {
    grid-template-columns: 1fr;
  }
  .nw-editor-page {
    padding: 0 12px 16px;
  }
  .nw-toolbar {
    flex-wrap: wrap;
  }
  .nw-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .nw-analytics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .nw-analytics-two-col {
    grid-template-columns: 1fr;
  }
  .nw-analytics-sub-section:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
  }
}
