/* Palette sampled directly from the Sehdini app (chat screen): warm cream
   background, deep forest green for primary/active elements, and a
   terracotta/burnt-orange for notification-style badges. Kept as a single
   fixed light theme (no dark-mode variant) so the webview always matches
   the host app's chart, regardless of the device's system appearance.

   Layout uses CSS logical properties (margin-inline, padding-inline,
   text-align: start/end, etc.) instead of left/right so the whole page
   mirrors automatically between Arabic (RTL, default) and French (LTR) —
   see <html dir> toggled by app.js, no separate RTL stylesheet needed. */
:root {
  --bg: #f2eee3;
  --surface: #f2eee3;
  --surface-hover: #ece6d6;
  --chip-bg: #ffffff;
  --card-bg: #ffffff;
  --border: #e2dbc7;
  --text: #201d17;
  --text-dim: #8a8578;
  --accent: #2a4c3e;
  --accent-dark: #1f3c30;
  --accent-soft: #e4ebe4;
  --badge-bg: #b8512f;
  --badge-text: #fdf6ee;
  --shadow: 0 1px 2px rgba(32, 29, 23, 0.05), 0 8px 24px rgba(32, 29, 23, 0.06);
  --card-shadow: 0 1px 2px rgba(32, 29, 23, 0.05);
  --radius: 16px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Geeza Pro", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-align: start;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

@media (min-width: 720px) {
  .app {
    min-height: calc(100vh - 32px);
    margin: 16px auto;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
  }
}

/* --- Filters: now the sticky top nav (replaces the old brand/topbar) --- */

.filters {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 14px 14px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
}

.status-line {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Bottom bar: language switch, fixed at the bottom, centered --- */

.bottom-bar {
  flex: none;
  display: flex;
  justify-content: center;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.lang-btn {
  flex: none;
  height: 38px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid rgba(32, 29, 23, 0.12);
  background: var(--chip-bg);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lang-btn:hover {
  border-color: var(--accent);
}

.filter-chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-block: 6px;
  padding-inline: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(32, 29, 23, 0.1);
  background: var(--chip-bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip-logo {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
}

.filter-chip:hover {
  border-color: var(--accent);
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fdf6ee;
}

/* --- Feed: a column of Facebook-style post cards --- */

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px 14px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: background 0.12s ease, transform 0.1s ease;
  animation: rowIn 0.28s ease both;
}

.post:hover, .post:focus-visible {
  background: var(--surface-hover);
  outline: none;
}

.post:active {
  background: var(--accent-soft);
  transform: scale(0.995);
}

@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header row: avatar + name + views + time, all on ONE single line */

.post-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}

.post-header .avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
  border: 1px solid var(--border);
}

.post-name {
  flex: none;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}

/* Meta bits: eye icon + views count + time, dimmer/smaller than the name,
   sharing the same single line as the source name and avatar */

.post-views {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.post-views .eye-icon {
  flex: none;
  display: block;
}

.post-views[data-zero="false"] .click-count {
  color: var(--badge-bg);
  font-weight: 700;
}

.meta-dot {
  flex: none;
  opacity: 0.6;
  font-size: 11px;
  color: var(--text-dim);
}

.post-time {
  flex: none;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The headline: bold, prominent — this is the "post text" */

.post-title {
  margin: 8px 0 0;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}

/* --- Skeleton loading state (mirrors the post-card shape) --- */

.skeleton-list {
  padding: 4px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px 14px;
}

.skeleton-row .skeleton-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.skeleton-avatar, .skeleton-line {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-hover) 37%, var(--border) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex: none;
}

.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.skeleton-line {
  height: 9px;
}

.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w28 { width: 28%; }
.skeleton-line.w90 { width: 90%; height: 13px; }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 14px;
}

[hidden] {
  display: none !important;
}
