/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: hsl(0, 0%, 97%);
  --fg: hsl(220, 20%, 12%);
  --card: hsl(0, 0%, 100%);
  --primary: hsl(0, 78%, 50%);
  --primary-fg: hsl(0, 0%, 100%);
  --secondary: hsl(220, 14%, 96%);
  --muted: hsl(220, 10%, 46%);
  --border: hsl(220, 13%, 90%);
  --destructive: hsl(0, 84%, 60%);
  --radius: 0.5rem;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-serif: 'Merriweather', Georgia, serif;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ===== NAVBAR ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.navbar-top {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
  padding: 0 1rem;
}
.logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary);
}
.navbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.nav-link { font-size: 0.875rem; font-weight: 500; color: var(--muted); transition: color 0.2s; }
.nav-link:hover { color: var(--fg); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--primary);
  color: var(--primary-fg);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }

/* Search */
.search-form { display: flex; align-items: center; }
.search-wrapper { position: relative; }
.search-icon {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--muted);
}
.search-input {
  height: 2.25rem;
  width: 16rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--secondary);
  padding-left: 2.25rem;
  padding-right: 1rem;
  font-size: 0.875rem;
  outline: none;
  transition: box-shadow 0.2s;
}
.search-input:focus { box-shadow: 0 0 0 3px hsla(0, 78%, 50%, 0.15); }

.cat-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s;
  white-space: nowrap; /* Prevents text from breaking into two lines */
  flex-shrink: 0;      /* Prevents the flex container from squishing the links */
}
.cat-link:hover, .cat-link.active { color: var(--primary); }

/* Mobile menu */
.menu-toggle { padding: 0.25rem; color: var(--fg); }
.mobile-menu {
  border-top: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.mobile-menu .search-input { width: 100%; }
.mobile-cats { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  background: var(--secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.chip:hover { background: var(--border); }

/* Responsive */
.desktop-only { display: none; }
.mobile-only { display: flex; }
@media (min-width: 768px) {
  .desktop-only { display: flex; }
  .mobile-only { display: none !important; }
}

/* ===== APP CONTAINER ===== */
.app-container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ===== FEATURED CARD ===== */
.featured-card {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  cursor: pointer;
}
.featured-card img {
  width: 100%;
  height: 20rem;
  object-fit: cover;
  transition: transform 0.3s;
}
.featured-card:hover img { transform: scale(1.05); }
.featured-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, hsla(220,20%,12%,0.8), transparent);
}
.featured-content {
  position: absolute;
  bottom: 0;
  padding: 1.5rem;
}
.badge {
  display: inline-block;
  background: var(--primary);
  color: var(--primary-fg);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  margin-bottom: 0.5rem;
  text-transform: capitalize;
}
.featured-content h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  line-height: 1.3;
}
.featured-meta {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.7);
}

/* ===== ARTICLE CARD ===== */
.article-card {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.article-card:last-child { border-bottom: none; }
.article-card-body { flex: 1; min-width: 0; }
.article-card-cat {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.article-card-title {
  margin-top: 0.25rem;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.2s;
}
.article-card:hover .article-card-title { color: var(--primary); }
.article-card-desc {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card-meta {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.article-card-img {
  width: 7rem;
  height: 5rem;
  flex-shrink: 0;
  border-radius: var(--radius);
  object-fit: cover;
}
@media (min-width: 640px) {
  .article-card-img { width: 8rem; height: 6rem; }
}

/* ===== ARTICLES GRID ===== */
.section-heading {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--fg);
}
.articles-grid {
  display: grid;
  gap: 0;
}
@media (min-width: 768px) {
  .articles-grid { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
  .articles-grid .article-card { border-bottom: none; }
}
.empty-state {
  text-align: center;
  padding: 3rem 0;
  color: var(--muted);
}

/* ===== ARTICLE PAGE ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  transition: color 0.2s;
}
.back-link:hover { color: var(--fg); }
.article-page { max-width: 48rem; margin: 0 auto; }
.article-page h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--fg);
}
@media (min-width: 768px) { .article-page h1 { font-size: 2.5rem; } }
.article-page-meta {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.article-page-meta .author { font-weight: 500; color: var(--fg); }
.draft-badge {
  background: var(--secondary);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 500;
}
.article-cover {
  margin-top: 1.5rem;
  width: 100%;
  height: 16rem;
  object-fit: cover;
  border-radius: var(--radius);
}
@media (min-width: 640px) { .article-cover { height: 25rem; } }
.article-body {
  margin-top: 2rem;
}
.article-body p {
  font-size: 1rem;
  line-height: 1.8;
  color: hsla(220, 20%, 12%, 0.85);
  margin-bottom: 1rem;
}
.article-footer {
  margin-top: 2.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  transition: background 0.2s;
}
.btn-outline:hover { background: var(--secondary); }
.btn-outline.danger { color: var(--destructive); }
.btn-outline.danger:hover { background: var(--destructive); color: var(--primary-fg); }

/* ===== WRITE PAGE ===== */
.write-page { max-width: 42rem; margin: 0 auto; }
.write-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.write-header h1 { font-size: 1.25rem; font-weight: 700; }
.write-actions { display: flex; gap: 0.5rem; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.375rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  transition: background 0.2s;
}
.btn-secondary:hover { background: var(--secondary); }
.write-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.write-title {
  width: 100%;
  background: transparent;
  border: none;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fg);
  outline: none;
}
.write-title::placeholder { color: hsla(220,10%,46%,0.5); }
.write-row { display: flex; gap: 0.75rem; }
.write-input {
  flex: 1;
  height: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--secondary);
  padding: 0 0.75rem;
  font-size: 0.875rem;
  outline: none;
  transition: box-shadow 0.2s;
}
.write-input:focus { box-shadow: 0 0 0 3px hsla(0, 78%, 50%, 0.15); }
.write-select {
  height: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--secondary);
  padding: 0 0.75rem;
  font-size: 0.875rem;
  outline: none;
}
.write-preview {
  width: 100%;
  height: 12rem;
  object-fit: cover;
  border-radius: var(--radius);
}
.write-textarea {
  width: 100%;
  min-height: 300px;
  resize: none;
  background: transparent;
  border: none;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--fg);
  outline: none;
}
.write-textarea::placeholder { color: hsla(220,10%,46%,0.4); }

/* ===== DRAFTS PAGE ===== */
.drafts-list { border-top: 1px solid var(--border); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--fg);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 100;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.5s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(1rem); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(1rem); } }


/*aa*/
/* --- Desktop Category Section --- */
@media (min-width: 769px) {
  .category-section {
    max-width: 72rem;
    margin: 0 auto;
    display: flex; /* This is now safely locked to desktop only */
    align-items: center;
    border-top: 1px solid var(--border);
  }

  .category-bar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 1rem;
    height: 2.5rem;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .category-bar::-webkit-scrollbar { display: none; }

  /* Help Icon & Tooltip Styles */
  .help-wrapper {
    position: relative;
    margin-right: 1rem;
    display: flex;
    align-items: center;
  }

  .help-icon {
    width: 1.25rem;
    height: 1.25rem;
    border: 1.5px solid var(--muted);
    border-radius: 50%;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    transition: all 0.2s;
  }

  .help-icon:hover {
    border-color: var(--fg);
    color: var(--fg);
    background: var(--secondary);
  }

  .tooltip-box {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    right: 0;
    top: 150%;
    width: 18rem;
    background: var(--fg);
    color: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
    font-size: 0.815rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: all 0.2s ease;
    pointer-events: none;
  }

  .tooltip-box::before {
    content: "";
    position: absolute;
    top: -5px;
    right: 8px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--fg);
  }

  .help-wrapper:hover .tooltip-box {
    visibility: visible;
    opacity: 1;
    top: 130%;
  }

  .tooltip-box p { margin-bottom: 0.5rem; }
  .tooltip-box ul { list-style: none; }
  .tooltip-box li { margin-bottom: 0.25rem; }
}

/* --- Mobile Safety Rule --- */
@media (max-width: 768px) {
  .category-section {
    display: none !important; /* Forces the bar to hide on mobile */
  }
}


/* WhatsApp Corner Button */
.wa-float-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, opacity 0.2s;
}

.wa-float-container:hover {
  transform: translateY(-3px);
}

.wa-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.wa-logo-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.wa-link span {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
}

/* The Close Button */
.wa-close-btn {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 20px;
  height: 20px;
  background: var(--fg);
  color: var(--bg);
  border-radius: 50%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  line-height: 1;
}

/* Mobile: make it a bit smaller so it doesn't block text */
@media (max-width: 768px) {
  .wa-float-container {
    bottom: 1rem;
    right: 1rem;
    padding: 0.4rem 0.8rem;
  }
}