/* ─────────────────────────────────────────────
   Facebook Posts Widget — Premium Stylesheet
   Reka bentuk untuk Agensi Kerajaan Malaysia
   ───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Source+Sans+3:wght@400;500;600&display=swap');

:root {
  --fbw-primary:    #003399;
  --fbw-accent:     #c8a951;
  --fbw-dark:       #1a1a2e;
  --fbw-mid:        #555577;
  --fbw-light:      #f4f6fb;
  --fbw-white:      #ffffff;
  --fbw-border:     #e2e6f0;
  --fbw-radius:     12px;
  --fbw-shadow:     0 4px 24px rgba(0,51,153,0.10), 0 1px 4px rgba(0,0,0,0.06);
  --fbw-shadow-h:   0 8px 40px rgba(0,51,153,0.18), 0 2px 8px rgba(0,0,0,0.08);
  --fbw-transition: 0.28s cubic-bezier(0.4,0,0.2,1);
  --fbw-font-head:  'Playfair Display', Georgia, serif;
  --fbw-font-body:  'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
}

/* ── Editor Notice ───────────────────────────── */
.fbw-editor-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff8e1;
  border: 1.5px dashed #c8a951;
  border-radius: 8px;
  padding: 16px 20px;
  font-family: var(--fbw-font-body);
  font-size: 14px;
  color: #7a6010;
}
.fbw-editor-notice span { font-size: 20px; }

/* ── Loading State ───────────────────────────── */
.fbw-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  color: var(--fbw-mid);
  font-family: var(--fbw-font-body);
  font-size: 15px;
  gap: 16px;
}

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

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

/* ── Page Header ─────────────────────────────── */
.fbw-page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0 28px;
  border-bottom: 2px solid var(--fbw-border);
  margin-bottom: 32px;
  position: relative;
}

.fbw-page-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--fbw-primary);
}

.fbw-page-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--fbw-white);
  box-shadow: 0 2px 12px rgba(0,51,153,0.15);
  object-fit: cover;
  flex-shrink: 0;
}

.fbw-page-avatar-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fbw-primary), #0055cc);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  flex-shrink: 0;
}

.fbw-page-info { flex: 1; }

.fbw-page-name {
  font-family: var(--fbw-font-head);
  font-size: 20px;
  font-weight: 700;
  color: var(--fbw-dark);
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fbw-page-verified {
  color: var(--fbw-primary);
  font-size: 16px;
  line-height: 1;
}

.fbw-page-meta {
  font-family: var(--fbw-font-body);
  font-size: 13px;
  color: var(--fbw-mid);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.fbw-page-meta .fbw-dot { opacity: 0.4; }

.fbw-fb-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #1877f2;
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-decoration: none;
  font-family: var(--fbw-font-body);
  transition: opacity var(--fbw-transition);
}

.fbw-fb-badge:hover { opacity: 0.85; color: white; }

/* ── Grids ───────────────────────────────────── */
.fbw-posts-grid {
  display: grid;
  gap: 24px;
}

.fbw-posts-grid.fbw-cols-2 { grid-template-columns: repeat(2, 1fr); }
.fbw-posts-grid.fbw-cols-3 { grid-template-columns: repeat(3, 1fr); }
.fbw-posts-grid.fbw-cols-4 { grid-template-columns: repeat(4, 1fr); }

.fbw-posts-grid.fbw-layout-list,
.fbw-posts-grid.fbw-layout-list.fbw-cols-2,
.fbw-posts-grid.fbw-layout-list.fbw-cols-3,
.fbw-posts-grid.fbw-layout-list.fbw-cols-4 {
  grid-template-columns: 1fr;
}

/* Masonry */
.fbw-posts-grid.fbw-layout-masonry {
  align-items: start;
}

/* Magazine layout — first card spans 2 rows */
.fbw-posts-grid.fbw-layout-magazine.fbw-cols-3 .fbw-post-card:first-child {
  grid-column: span 2;
  grid-row: span 2;
}

.fbw-posts-grid.fbw-layout-magazine.fbw-cols-3 .fbw-post-card:first-child .fbw-post-image-wrap {
  height: 320px;
}

.fbw-posts-grid.fbw-layout-magazine.fbw-cols-4 .fbw-post-card:first-child {
  grid-column: span 2;
}

/* ── Post Card ───────────────────────────────── */
.fbw-post-card {
  background: var(--fbw-white);
  border-radius: var(--fbw-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--fbw-border);
  transition: transform var(--fbw-transition), box-shadow var(--fbw-transition);
  animation: fbw-fadeInUp 0.45s ease both;
}

.fbw-post-card.fbw-shadow {
  box-shadow: var(--fbw-shadow);
  border-color: transparent;
}

.fbw-post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--fbw-shadow-h);
}

@keyframes fbw-fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger animation delay */
.fbw-post-card:nth-child(1)  { animation-delay: 0.05s; }
.fbw-post-card:nth-child(2)  { animation-delay: 0.10s; }
.fbw-post-card:nth-child(3)  { animation-delay: 0.15s; }
.fbw-post-card:nth-child(4)  { animation-delay: 0.20s; }
.fbw-post-card:nth-child(5)  { animation-delay: 0.25s; }
.fbw-post-card:nth-child(6)  { animation-delay: 0.30s; }

/* Image */
.fbw-post-image-wrap {
  height: 200px;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  background: var(--fbw-light);
}

.fbw-post-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  display: block;
}

.fbw-post-card:hover .fbw-post-image-wrap img {
  transform: scale(1.04);
}

.fbw-no-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
  color: #c0c8e0;
  font-size: 40px;
}

/* Card Body */
.fbw-post-body {
  padding: 20px 22px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Date */
.fbw-post-date {
  font-family: var(--fbw-font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--fbw-mid);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 7px;
}

.fbw-post-date::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 2.5px;
  background: var(--fbw-primary);
  border-radius: 2px;
  flex-shrink: 0;
}

/* Title */
.fbw-post-title {
  font-family: var(--fbw-font-head);
  font-size: 17px;
  font-weight: 700;
  color: var(--fbw-dark);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Excerpt */
.fbw-post-excerpt {
  font-family: var(--fbw-font-body);
  font-size: 14px;
  line-height: 1.65;
  color: var(--fbw-mid);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

/* Footer */
.fbw-post-footer {
  padding: 0 22px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fbw-read-more {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--fbw-primary);
  color: #ffffff !important;
  font-family: var(--fbw-font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none !important;
  transition: background var(--fbw-transition), transform var(--fbw-transition);
  letter-spacing: 0.02em;
}

.fbw-read-more:hover {
  background: #001d80;
  transform: translateX(2px);
  color: #ffffff !important;
}

.fbw-read-more svg {
  transition: transform var(--fbw-transition);
}

.fbw-read-more:hover svg {
  transform: translateX(3px);
}

/* ── List Layout ─────────────────────────────── */
.fbw-layout-list .fbw-post-card {
  flex-direction: row;
}

.fbw-layout-list .fbw-post-image-wrap {
  width: 220px;
  height: auto;
  min-height: 160px;
  flex-shrink: 0;
  border-radius: 0;
}

.fbw-layout-list .fbw-post-body {
  padding: 22px 24px;
}

.fbw-layout-list .fbw-post-footer {
  padding: 0 24px 22px;
}

.fbw-layout-list .fbw-post-title {
  font-size: 19px;
  -webkit-line-clamp: 2;
}

.fbw-layout-list .fbw-post-excerpt {
  -webkit-line-clamp: 4;
}

/* ── Error State ─────────────────────────────── */
.fbw-error-state {
  padding: 32px 24px;
  background: #fff5f5;
  border: 1.5px solid #ffc0c0;
  border-radius: var(--fbw-radius);
  text-align: center;
  font-family: var(--fbw-font-body);
}

.fbw-error-state strong {
  display: block;
  font-size: 16px;
  color: #c0392b;
  margin-bottom: 8px;
}

.fbw-error-state p {
  font-size: 14px;
  color: #888;
  margin: 0;
}

/* ── Empty State ─────────────────────────────── */
.fbw-empty-state {
  padding: 40px 24px;
  text-align: center;
  font-family: var(--fbw-font-body);
  color: var(--fbw-mid);
  font-size: 15px;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 1024px) {
  .fbw-posts-grid.fbw-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .fbw-posts-grid.fbw-cols-2,
  .fbw-posts-grid.fbw-cols-3,
  .fbw-posts-grid.fbw-cols-4 { grid-template-columns: 1fr; }

  .fbw-posts-grid.fbw-layout-magazine.fbw-cols-3 .fbw-post-card:first-child {
    grid-column: span 1;
    grid-row: span 1;
  }

  .fbw-layout-list .fbw-post-card { flex-direction: column; }
  .fbw-layout-list .fbw-post-image-wrap { width: 100%; height: 200px; }
}
