/* ============================================
   MyMedikoz Forum — Reddit-style Theme
   ============================================ */

:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #DBEAFE;
  --bg: #F8FAFB;
  --card-bg: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --upvote: #F97316;
  --doctor-badge: #7C3AED;
  --verified: #16A34A;
  --danger: #EF4444;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --font: 'Quicksand', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Screen-reader only (SEO H1 etc.) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Navbar ---- */
.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
  color: var(--primary);
}

.navbar-brand img {
  height: 32px;
  width: 32px;
  border-radius: 6px;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--danger); color: white; }

/* ---- Layout ---- */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 24px;
}

@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar-left, .sidebar-right { display: none; }
}

@media (max-width: 768px) {
  .layout { padding: 12px; gap: 12px; }
  .navbar { padding: 0 12px; }
}

/* ---- Sidebar ---- */
.sidebar-left, .sidebar-right {
  position: sticky;
  top: 76px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.sidebar-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.sidebar-card h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* Categories header — collapsible */
.categories-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding-bottom: 10px;
  user-select: none;
}

.collapse-icon {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.collapse-icon.collapsed {
  transform: rotate(180deg);
}

/* Category search */
.category-search {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 12px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
  background: var(--bg);
}

.category-search:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.categories-card.collapsed .category-search,
.categories-card.collapsed .category-list {
  display: none;
}

.category-list {
  list-style: none;
  max-height: 55vh;
  overflow-y: auto;
}

.category-list::-webkit-scrollbar {
  width: 4px;
}

.category-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.12s;
}

.category-item.hidden {
  display: none;
}

.category-item:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.category-item.active {
  background: var(--primary);
  color: white;
}

.category-item .cat-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.category-item .cat-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.category-item .cat-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-item .cat-desc {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.category-item.active .cat-desc {
  opacity: 0.85;
}

/* ---- What's on your mind ---- */
.whats-on-your-mind {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.whats-on-your-mind:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.woym-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.woym-input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  transition: border-color 0.15s;
}

.whats-on-your-mind:hover .woym-input {
  border-color: var(--primary);
  color: var(--text-secondary);
}

.woym-post-btn {
  border-radius: 20px !important;
  padding: 8px 20px !important;
  font-size: 13px !important;
}

@media (max-width: 768px) {
  .woym-avatar { width: 36px; height: 36px; font-size: 16px; }
  .woym-input { padding: 8px 14px; font-size: 13px; }
  .woym-post-btn { display: none; }
}

/* ---- Feed controls ---- */
.feed-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.sort-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  transition: all 0.12s;
}

.sort-btn.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.sort-btn:hover:not(.active) {
  background: var(--bg);
}

/* ---- Post card ---- */
.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color 0.12s;
  display: flex;
  gap: 12px;
}

.post-card:hover {
  border-color: var(--primary);
  cursor: pointer;
}

/* Upvote column */
.post-votes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 40px;
  padding-top: 2px;
}

.vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  padding: 2px;
  border-radius: 4px;
  transition: all 0.12s;
  line-height: 1;
}

.vote-btn:hover { color: var(--upvote); background: #FFF7ED; }
.vote-btn.upvoted { color: var(--upvote); }

.vote-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

/* Post body */
.post-body { flex: 1; min-width: 0; }

.post-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.post-category {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 11px;
}

.post-author {
  font-weight: 600;
  color: var(--text-secondary);
}

.doctor-badge {
  background: var(--doctor-badge);
  color: white;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.post-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.post-content-preview {
  font-size: 14px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.post-images-preview {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}

.post-images-preview img {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.post-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.post-footer-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Comment toggle button in footer */
.comment-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.comment-toggle-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ---- Inline comments (home feed) ---- */
.inline-comments {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.inline-comments-loading {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}

.inline-comment-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.inline-comment-input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg);
  transition: border-color 0.15s;
}
.inline-comment-input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}
.inline-comment-input[readonly] {
  cursor: pointer;
}

.inline-comment-submit {
  white-space: nowrap;
  border-radius: 20px !important;
  padding: 6px 16px !important;
  font-size: 12px !important;
}

.inline-comments-list {
  max-height: 300px;
  overflow-y: auto;
}
.inline-comments-list::-webkit-scrollbar {
  width: 3px;
}
.inline-comments-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.inline-comment {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.inline-comment:last-child {
  border-bottom: none;
}

.inline-comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.inline-comment-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.inline-comment-time {
  font-size: 11px;
  color: var(--text-muted);
}

.inline-comment-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.doctor-replied {
  color: var(--verified);
  font-weight: 600;
}

/* ---- Post detail page ---- */
.post-detail-container {
  max-width: 780px;
  margin: 0 auto;
  padding: 20px 24px;
}

.post-detail {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.post-detail .post-title {
  font-size: 22px;
  margin-bottom: 8px;
}

.post-detail .post-content {
  font-size: 15px;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
  margin: 16px 0;
}

.post-detail .post-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.post-detail .post-images img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.post-detail .post-images img:hover {
  opacity: 0.9;
}

.post-detail .post-stats {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
}

/* ---- Comments ---- */
.comments-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.comments-section h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.comment-form {
  margin-bottom: 20px;
}

.comment-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.15s;
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.comment-form .btn {
  margin-top: 8px;
}

.comment {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child { border-bottom: none; }

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.comment-author {
  font-weight: 700;
  color: var(--text);
}

.comment-time {
  color: var(--text-muted);
  font-size: 12px;
}

.comment-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ---- Auth modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.modal h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.modal p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 10px;
  display: none;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 13px;
}

.modal-footer a { cursor: pointer; }

/* ---- Create post modal ---- */
.create-post-form .form-group textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  resize: vertical;
}

.create-post-form .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.create-post-form .form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  background: white;
}

/* ---- Loading / empty ---- */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 8px;
}

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ---- Responsive mobile sidebar toggle ---- */
.mobile-categories-btn {
  display: none !important;
  margin-bottom: 12px;
}

.mobile-categories {
  display: none !important;
}

@media (max-width: 1024px) {
  .mobile-categories-btn { display: flex !important; }
  .mobile-categories {
    display: none !important;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
  }
  .mobile-categories.show { display: block !important; }
}

/* ---- Back link ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-weight: 600;
}
.back-link:hover { color: var(--primary); text-decoration: none; }

/* ---- User menu ---- */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* ---- Role selection options ---- */
.role-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--bg);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.12s;
}

.role-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.role-option-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--primary);
  flex-shrink: 0;
}

.role-option-text { flex: 1; }

.role-option-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.role-option-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ---- Skeleton loading ---- */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #f1f5f9 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

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

.skeleton-post {
  height: 120px;
  margin-bottom: 8px;
  border-radius: var(--radius);
}
