/* index.css */
:root {
  --primary: #f26522;
  /* Khamsat Orange */
  --secondary: #2c3e50;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --success: #10b981;
  --error: #ef4444;
}

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

body {
  font-family: 'Cairo', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 0;
  /* Remove body padding */
  min-height: 100vh;
}

.dashboard-container {
  padding: 2rem;
  margin-left: 280px;
  /* Space for the sidebar */
  max-width: none;
  min-height: 100vh;
}

.main-header {
  position: fixed;
  left: 1.5rem;
  top: 1.5rem;
  bottom: 1.5rem;
  width: 250px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 2rem 1rem;
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 10px 0 50px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  gap: 1.5rem;
}

.token-setting {
  width: 100%;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
}

.token-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.token-setting input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  padding: 0.5rem;
  color: white;
  font-family: inherit;
  font-size: 0.8rem;
  width: 100%;
}

.token-note {
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.2;
}

.header-left h1 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  text-align: center;
  gap: 0.8rem;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stats-compact-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 1.25rem 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.03);
  width: 100%;
}

.stat-mini {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0.5rem;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: help;
  transition: all 0.2s;
}

/* CUSTOM TOOLTIP */
.stat-mini::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 15px);
  top: 50%;
  transform: translateY(-50%) translateX(-10px);
  background: rgba(15, 23, 42, 0.95);
  color: white;
  padding: 0.5rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  z-index: 5000;
}

/* Tooltip Arrow */
.stat-mini::before {
  content: '';
  position: absolute;
  left: calc(100% + 5px);
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: rgba(15, 23, 42, 0.95);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.stat-mini:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.stat-mini:hover::before {
  opacity: 1;
}

.stat-mini:hover {
  transform: translateX(5px);
  background: rgba(242, 101, 34, 0.1);
  color: var(--text);
}

.stat-mini i {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.stat-mini:hover i {
  color: var(--primary);
}

/* Pagination Controls */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.page-btn {
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  background: rgba(242, 101, 34, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-info {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.page-separator {
  color: var(--text-dim);
  margin: 0 0.25rem;
}

#current-page {
  color: var(--primary);
}

#total-pages {
  color: var(--text-dim);
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.5rem;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(242, 101, 34, 0.1);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-container {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 1rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--error);
  color: var(--error);
}

.modal-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-content {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(242, 101, 34, 0.5);
}

.header-right {
  margin-top: auto;
  width: 100%;
}

.status-badge {
  padding: 0.8rem 1rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
  width: 100%;
}

.status-badge.polling {
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.2);
}

.pulsing-dot {
  width: 8px;
  height: 8px;
  background-color: currentColor;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(1.2);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 1100px) {
  .dashboard-container {
    margin-left: 0;
    padding-bottom: 7rem;
  }

  .main-header {
    flex-direction: row;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    top: auto;
    width: auto;
    height: 80px;
    padding: 0.5rem 1.5rem;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
  }

  .header-left h1 {
    flex-direction: row;
    font-size: 0.9rem;
  }

  .stats-compact-bar {
    flex-direction: row;
    width: auto;
    background: transparent;
    border: none;
    padding: 0;
    gap: 1rem;
  }

  .stat-mini span {
    display: none;
    /* Hide numbers on small screens to save space */
  }

  .stat-mini {
    padding: 0.5rem;
  }

  .header-right {
    width: auto;
    margin-top: 0;
  }
}

main {
  width: 100%;
}

.scroll-area {
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  padding: 0 0 0 1rem;
}

#recent-feed {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem 0;
}

@keyframes bgPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.scroll-area {
  flex: 1;
  overflow-y: auto;
  /* Removed display: flex to prevent items from squishing due to flex-shrink */
}

.placeholder-msg {
  text-align: center;
  color: var(--text-dim);
  padding: 3rem;
  font-size: 1.1rem;
}

/* Glassmorphism Post Item */
.post-item.glass-effect {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 1rem;
  padding: 1.1rem;
  margin-bottom: .5rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  animation: slideInUp 0.4s ease-out forwards;
}

.post-item.glass-effect::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 1rem;
  background: radial-gradient(800px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(242, 101, 34, 0.06), transparent 40%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.post-item.glass-effect:hover {
  transform: translateY(-3px) scale(1.01);
  border-color: rgba(242, 101, 34, 0.3);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(242, 101, 34, 0.1);
}

.post-item.glass-effect:hover::before {
  opacity: 1;
}

.has-details {
  cursor: pointer;
}

.post-preview-text {
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0.25rem 0;
  color: #94a3b8;
  display: block;
}

.post-item.expanded .post-preview-text {
  display: none;
}

.post-details-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0, 1, 0, 1);
  opacity: 0;
}

.post-item.expanded .post-details-drawer {
  max-height: 1000px;
  transition: max-height 0.6s ease-in-out;
  opacity: 1;
}

.divider-subtle {
  height: 1px;
  background: linear-gradient(to left, transparent, rgba(242, 101, 34, 0.2), transparent);
  margin: 0.75rem 0;
}

.stats-compact-bar .divider-subtle {
  margin: 0.5rem 0;
}

.post-full-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-wrap;
  padding-bottom: 0.5rem;
}

.expand-icon {
  font-size: 0.8rem;
  color: var(--primary);
  opacity: 0.5;
  transition: all 0.3s;
  margin-right: 0.5rem;
}

.post-item.has-details:hover .expand-icon {
  opacity: 1;
  transform: scale(1.2);
}


@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post-item-layout {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  box-shadow: 0 0 10px rgba(242, 101, 34, 0.2);
  background-color: var(--card-bg);
  object-fit: cover;
  flex-shrink: 0;
}

.post-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.post-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.post-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.post-item.has-details:hover .post-title {
  color: var(--primary);
}

.post-meta-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
}

.buyer-name-tag {
  color: #e2e8f0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.buyer-level-tag {
  color: #a78bfa;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.tag-subtle {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-weight: 500;
}

.time-ago {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}

.text-dim {
  color: var(--text-dim);
}

.post-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  min-width: 100px;
}

.action-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.post-icon-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.comment-icon-btn {
  background: rgba(242, 101, 34, 0.1);
  color: var(--primary);
  border: 1px solid rgba(242, 101, 34, 0.2);
  min-width: 32px;
  height: 32px;
  padding: 0 0.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.2s;
}

.comment-icon-btn .comment-count {
  font-size: 0.8rem;
  font-weight: 600;
}

.comment-icon-btn:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.external-link-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(242, 101, 34, 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid rgba(242, 101, 34, 0.2);
  transition: all 0.2s;
  pointer-events: auto;
}

.external-link-btn:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(242, 101, 34, 0.3);
}

.id-tag {
  font-family: monospace;
  background: rgba(0, 0, 0, 0.3);
  color: #64748b;
  padding: 0.3rem 0.6rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

/* Scrollbar Styling */
.fancy-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.fancy-scrollbar::-webkit-scrollbar-track {
  background: transparent;
  margin: 10px 0;
}

.fancy-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.fancy-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(242, 101, 34, 0.5);
}

@media (max-width: 640px) {
  .post-item-layout {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .post-action {
    align-items: flex-start;
    width: 100%;
    margin-top: 0.5rem;
  }
}

/* Comment Modal Styles */
.comment-modal-container {
  max-width: 900px;
}

.comment-post-info {
  padding: 1rem 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.comment-post-info h4 {
  font-size: 1rem;
  color: var(--accent);
  margin: 0;
  margin-bottom: 0.25rem;
}

#comment-author-info {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.comment-modal-content {
  display: flex;
  gap: 1.5rem;
  align-items: stretch;
}

.comment-list-section {
  flex: 1;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.comment-list-header {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 40vh;
  overflow-y: auto;
  padding-left: 0.5rem;
}

.comment-list::-webkit-scrollbar {
  width: 6px;
}

.comment-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.comment-item {
  display: flex;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 0.75rem;
  padding: 0.75rem;
}

.comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  object-fit: cover;
  flex-shrink: 0;
}

.comment-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.comment-user {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.comment-user:hover {
  color: var(--primary);
}

.comment-time {
  font-size: 0.75rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.comment-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  word-wrap: break-word;
}

.comment-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0.75rem;
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

.comment-form-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.comment-textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 1rem;
  color: white;
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  margin-bottom: 1rem;
  min-height: 180px;
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(242, 101, 34, 0.2);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.submit-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.submit-btn:hover {
  background: #ff7b3d;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(242, 101, 34, 0.3);
}

.submit-btn:disabled {
  background: var(--text-dim);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.status-msg {
  padding: 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: none;
}

@media (max-width: 800px) {
  .comment-modal-content {
    flex-direction: column;
  }

  .comment-list-section {
    border-left: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-left: 0;
    padding-bottom: 1rem;
  }

  .comment-list {
    max-height: 200px;
  }
}

.status-msg.success {
  display: block;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-msg.error {
  display: block;
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

div[style*="font-size: 11pt"] {
  position: absolute !important;
  display: none !important;
}

div[style="opacity: 0.9; z-index: 2147483647; position: fixed; left: 0px; bottom: 0px; height: 65px; right: 0px; display: block; width: 100%; background-color: #202020; margin: 0px; padding: 0px;"] {
  display: none !important;
  position: absolute !important;
}