/* =========================================
   MATBAKH WIDGETS — GLOBAL
   ========================================= */
:root {
  --mk-orange: #E8622A;
  --mk-orange-light: #F7E8DF;
  --mk-orange-mid: #F0A882;
  --mk-text: #2C1A0E;
  --mk-text-light: #7A6355;
  --mk-bg: #FAF7F4;
  --mk-card-bg: #FFFFFF;
  --mk-border: #EDE8E3;
  --mk-radius-sm: 8px;
  --mk-radius-md: 14px;
  --mk-radius-lg: 20px;
  --mk-shadow: 0 2px 16px rgba(0,0,0,0.07);
  --mk-shadow-hover: 0 8px 32px rgba(0,0,0,0.12);
  --mk-transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* =========================================
   WIDGET 1: SEARCH BAR (enhanced)
   ========================================= */
.matbakh-search-filter {
  direction: rtl;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Top row: sort + search */
.matbakh-sf__top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.matbakh-sf__sort {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.matbakh-sf__sort-label {
  color: var(--mk-text-light);
  font-size: 14px;
  margin-left: 4px;
}

.matbakh-sf__sort-btn {
  padding: 9px 22px;
  border-radius: 50px;
  border: 1.5px solid var(--mk-border);
  background: var(--mk-card-bg);
  color: var(--mk-text);
  font-size: 14px;
  cursor: pointer;
  transition: var(--mk-transition);
  white-space: nowrap;
}

.matbakh-sf__sort-btn:hover {
  border-color: var(--mk-orange);
  color: var(--mk-orange);
}

.matbakh-sf__sort-btn.active {
  background: var(--mk-orange);
  border-color: var(--mk-orange);
  color: #fff;
  font-weight: 500;
}

/* ── Enhanced Search Field ── */
.matbakh-sf__search-wrap {
  position: relative;
  flex: 1;
  max-width: 460px;
}

.matbakh-sf__search-inner {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--mk-card-bg);
  border: 2px solid var(--mk-border);
  border-radius: 50px;
  padding: 0 14px 0 12px;
  gap: 10px;
  transition: var(--mk-transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.matbakh-sf__search-inner:focus-within {
  border-color: var(--mk-orange);
  box-shadow: 0 0 0 4px rgba(232,98,42,0.10), 0 4px 16px rgba(232,98,42,0.08);
}

.matbakh-sf__search-icon {
  flex-shrink: 0;
  color: var(--mk-text-light);
  transition: color 0.2s;
  order: 1; /* icon on the right in RTL */
}

.matbakh-sf__search-inner:focus-within .matbakh-sf__search-icon {
  color: var(--mk-orange);
}

.matbakh-sf__search-input {
  flex: 1;
  border: none !important;
  outline: none !important;
  background: transparent;
  color: var(--mk-text);
  font-size: 15px;
  padding: 13px 0;
  min-width: 0;
  order: 2;
  direction: rtl;
  text-align: right;
}

.matbakh-sf__search-input::placeholder {
  color: #C4B8AF;
  font-size: 14px;
}

/* Clear button inside search */
.matbakh-sf__clear-btn {
  flex-shrink: 0;
  order: 3;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--mk-orange-light);
  color: var(--mk-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--mk-transition);
  padding: 0;
}

.matbakh-sf__clear-btn:hover {
  background: var(--mk-orange);
  color: #fff;
}

/* =========================================
   WIDGET 1B: CATEGORY FILTER (standalone)
   ========================================= */
.matbakh-cat-filter {
  direction: rtl;
}

.matbakh-cf__cats-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.matbakh-cf__cat-btn {
  padding: 9px 22px;
  border-radius: 50px;
  border: 1.5px solid var(--mk-border);
  background: var(--mk-card-bg);
  color: var(--mk-text);
  font-size: 14px;
  cursor: pointer;
  transition: var(--mk-transition);
  white-space: nowrap;
  line-height: 1.3;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.matbakh-cf__cat-btn:hover {
  border-color: var(--mk-orange);
  color: var(--mk-orange);
  background: var(--mk-orange-light);
}

.matbakh-cf__cat-btn.active {
  background: var(--mk-orange);
  border-color: var(--mk-orange);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 3px 10px rgba(232,98,42,0.25);
}

/* =========================================
   WIDGET 2: POSTS LIST
   ========================================= */
.matbakh-posts-list {
  direction: rtl;
  position: relative;
}

.matbakh-posts-list__grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Post Card */
.matbakh-post-card {
  display: flex;
  flex-direction: row-reverse;
  align-items: stretch;
  background: var(--mk-card-bg);
  border-radius: var(--mk-radius-md);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--mk-shadow);
  transition: var(--mk-transition);
  min-height: 220px;
}

.matbakh-post-card:hover {
  box-shadow: var(--mk-shadow-hover);
  transform: translateY(-2px);
}

.matbakh-post-card__img-wrap {
  flex: 0 0 42%;
  order: 2;
  overflow: hidden;
  display: block;
  min-height: 220px;
}

.matbakh-post-card__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

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

.matbakh-post-card__img-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #F5EDE6 0%, #EDD5C3 100%);
  min-height: 220px;
}

.matbakh-post-card__body {
  flex: 1;
  order: 1;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.matbakh-post-card__cat {
  display: inline-block;
  background: var(--mk-orange-light);
  color: var(--mk-orange);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 50px;
  width: fit-content;
  letter-spacing: 0.02em;
}

.matbakh-post-card__title {
  margin: 0;
  font-size: 22px;
  line-height: 1.4;
  color: var(--mk-text);
}

.matbakh-post-card__title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.matbakh-post-card__title a:hover {
  color: var(--mk-orange);
}

.matbakh-post-card__excerpt {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--mk-text-light);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.matbakh-post-card__meta {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 4px;
}

.matbakh-post-card__date,
.matbakh-post-card__time {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--mk-text-light);
}

.matbakh-post-card__date svg,
.matbakh-post-card__time svg {
  flex-shrink: 0;
}

.matbakh-post-card__more {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--mk-orange);
  font-size: 14px;
  text-decoration: none;
  width: fit-content;
  margin-top: 4px;
  transition: gap 0.2s;
}

.matbakh-post-card__more:hover {
  gap: 10px;
}

/* Pagination */
.matbakh-pagination {
  margin-top: 40px;
  display: flex;
  justify-content: center;
}

.matbakh-pagination__inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--mk-card-bg);
  padding: 10px 14px;
  border-radius: 50px;
  box-shadow: var(--mk-shadow);
  border: 1px solid var(--mk-border);
}

.matbakh-pagination__btn {
  width: 38px;
  height: 38px;
  padding: 0px !important;
  border-radius: 50%;
  border: 1.5px solid var(--mk-border);
  background: transparent;
  color: var(--mk-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--mk-transition);
  flex-shrink: 0;
}

.matbakh-pagination__btn:hover:not(:disabled) {
  background: var(--mk-orange);
  border-color: var(--mk-orange);
  color: #fff;
}

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

.matbakh-pagination__pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.matbakh-page-num {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--mk-text);
  font-size: 14px;
  cursor: pointer;
  transition: var(--mk-transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.matbakh-page-num:hover {
  border-color: #E8622A !important;
  color: white !important;
}

.matbakh-page-num.active {
  background: var(--mk-orange);
  color: #fff;
  border-color: var(--mk-orange);
}

/* Loading */
.matbakh-loading {
  position: absolute;
  inset: 0;
  background: rgba(250,247,244,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--mk-radius-md);
  backdrop-filter: blur(2px);
}

.matbakh-loading__spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--mk-orange-light);
  border-top-color: var(--mk-orange);
  border-radius: 50%;
  animation: mkSpin 0.7s linear infinite;
}

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

.matbakh-no-posts {
  text-align: center;
  color: var(--mk-text-light);
  padding: 40px;
  font-size: 16px;
}

/* =========================================
   WIDGET 3: MOST READ
   ========================================= */
.matbakh-most-read {
  direction: rtl;
}

.matbakh-most-read__title {
  font-size: 18px;
  color: var(--mk-text);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--mk-orange);
  display: inline-block;
}

.matbakh-most-read__list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.matbakh-mr-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--mk-border);
  text-decoration: none;
  transition: var(--mk-transition);
}

.matbakh-mr-item:last-child {
  border-bottom: none;
}

.matbakh-mr-item:hover {
  opacity: 0.85;
}

.matbakh-mr-item__img-wrap {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--mk-radius-sm);
  overflow: hidden;
  display: block;
}

.matbakh-mr-item__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.matbakh-mr-item:hover .matbakh-mr-item__img-wrap img {
  transform: scale(1.06);
}

.matbakh-mr-item__img-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #F5EDE6 0%, #EDD5C3 100%);
}

.matbakh-mr-item__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.matbakh-mr-item__cat {
  font-size: 11px;
  color: var(--mk-orange);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.matbakh-mr-item__title {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--mk-text);
}

.matbakh-mr-item__title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.matbakh-mr-item__title a:hover {
  color: var(--mk-orange);
}

.matbakh-mr-item__time {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--mk-text-light);
}

/* =========================================
   RESPONSIVE — MOBILE
   ========================================= */
@media (max-width: 767px) {
  /* Search filter */
  .matbakh-sf__top-row {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .matbakh-sf__search-wrap {
    width: 100%;
    max-width: 100%;
  }
  .matbakh-sf__sort {
    justify-content: center;
  }

  /* Category filter */
  .matbakh-cf__cats-row {
    gap: 8px;
    justify-content: center;
  }
  .matbakh-cf__cat-btn {
    font-size: 13px;
    padding: 7px 14px;
  }

  /* Post card → vertical on mobile */
  .matbakh-post-card {
    flex-direction: column;
    min-height: unset;
  }
  .matbakh-post-card__img-wrap {
    flex: unset;
    order: 1;
    width: 100%;
    height: 220px;
    min-height: unset;
  }
  .matbakh-post-card__img-placeholder {
    min-height: 200px;
  }
  .matbakh-post-card__body {
    order: 2;
    padding: 20px 18px;
    gap: 8px;
  }
  .matbakh-post-card__title {
    font-size: 17px;
  }
  .matbakh-post-card__meta {
    gap: 12px;
  }

  /* Pagination on mobile */
  .matbakh-pagination__inner {
    padding: 8px 10px;
    gap: 4px;
  }
  .matbakh-pagination__btn,
  .matbakh-page-num {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  /* Most read on mobile */
  .matbakh-mr-item__img-wrap {
    width: 70px;
    height: 70px;
  }
  .matbakh-mr-item__title {
    font-size: 13px;
  }
}

/* Posts list count header */
.matbakh-posts-list__header {
  margin-bottom: 20px;
}

.matbakh-posts-list__count {
  margin: 0;
  font-size: 15px;
  color: var(--mk-text-light);
  direction: rtl;
}

.matbakh-posts-list__count-num {
  font-size: 22px;
  color: var(--mk-orange);
  margin-left: 4px;
}

.matbakh-posts-list__count strong {
  color: var(--mk-text);
}
