/* =============== Theme Variables =============== */
:root {
  /* Dark mode (default) */
  --bg-color: #000000;
  --text-color: #ffffff;
  --card-bg: #151515;
  --input-bg: #1e1e1e;
  --border-color: rgba(255, 255, 255, 0);
  --secondary-text: #a8b4c0;
  --tertiary-text: #6b7684;
  --hover-bg: rgba(255, 255, 255, 0.05);
  --glass-bg: rgba(10, 10, 10, 0.8);
  --electric-blue: #1d9bf0;
  --electric-blue-hover: #1a8cd8;
  --gradient-start: #1d9bf0;
  --gradient-end: #8b5cf6;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

  /* Mobile-first spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Effects */
  --blur-strong: 24px;
  --blur-medium: 16px;
  --blur-light: 8px;
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glass-hover: 0 16px 48px rgba(0, 0, 0, 0.7);
  --shadow-blue-strong: 0 8px 32px var(--accent-blue-glow);
  --radius-small: 8px;
  --radius-medium: 12px;
  --radius-large: 16px;
  --radius-pill: 50px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.light-mode {
  --bg-color: #f8f9fa;
  --text-color: #212529;
  --card-bg: #ffffff;
  --input-bg: #f1f3f5;
  --border-color: #dee2e6;
  --secondary-text: #6c757d;
  --tertiary-text: #495057;
  --hover-bg: rgba(0, 0, 0, 0.05);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* =============== Base & Reset =============== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  padding-top: 0;
  padding-bottom: 80px;
  transition: background-color 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* =============== Search Bar =============== */
.search-container {
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-color);
  background-clip: padding-box; /* Prevents background from extending under border */
}

.search-form {
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border-radius: 12px;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-color);
  position: relative;
}

.search-form input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-color);
  padding: 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}

.search-form input::placeholder {
  color: var(--tertiary-text);
}

.search-form button {
  background: none;
  border: none;
  color: var(--tertiary-text);
  cursor: pointer;
  padding: 0.5rem;
  font-size: 1.1rem;
}

/* =============== Secondary Menu =============== */
.secondary-menu {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: -250px;
  width: 200px;
  background: var(--glass-bg);
  border-radius: 20px;
  padding: 1rem;
  backdrop-filter: blur(10px);
  transition: bottom 0.3s ease; /* Changed from bottom to top */
  z-index: 99;
  height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.secondary-menu.active {
  bottom: 100px; /* Adjusted for new positioning */
}

.secondary-menu a {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  color: var(--secondary-text);
  text-decoration: none;
  border-radius: 10px;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  cursor: pointer;
}

.secondary-menu a:hover {
  background: var(--hover-bg);
  color: var(--electric-blue);
}

.secondary-menu a i {
  margin-right: 0.75rem;
  width: 16px;
  text-align: center;
}

/* =============== Bottom Nav =============== */
.navbars {
  position: fixed;
  bottom: 0;
  width: 100%;
  z-index: 100;
  background: var(--card-bg);
  padding: 0.75rem 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(var(--blur-strong));
  -webkit-backdrop-filter: blur(var(--blur-strong));
  border-top: none;
  padding: env(safe-area-inset-bottom) 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: var(--secondary-text);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.5rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  cursor: pointer;
  min-width: 48px;
  min-height: 48px;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.nav a i {
  font-size: 1.25rem;
}

.nav a span {
  display: none;
}

#menu-btn i {
  font-size: 35px !important;
  margin: 0 !important;
  color: var(--tertiary-text);
}

#menu-btn,
#menu-btn:focus,
#menu-btn:active {
  outline: none !important;
  background: none !important;
  box-shadow: none !important;
  color: var(--electric-blue);
  font-size: 18px;
  padding: 12px;
  border-radius: var(--radius-large);
  cursor: pointer;
  background: var(--accent-blue-light);
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  position: relative;
}

#menu-btn:hover {
  background: var(--electric-blue);
  color: white;
}

/* =============== Main Content =============== */
.main-content {
  padding-top: 0; /* Removed top padding since search is now at the top */
  padding-bottom: 2rem;
}

.post-editor form,
.posts-container .box {
  background: var(--card-bg);
  box-shadow: var(--shadow);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(var(--blur-strong));
  -webkit-backdrop-filter: blur(var(--blur-strong));
  background: var(--glass-bg);
  border: none;
  box-shadow: var(--shadow-glass);
  position: relative;
  overflow: hidden;
}

.post-editor {
  padding: var(--spacing-md);
  max-width: 600px;
  margin: 0 auto;
}

.post-editor .box {
  background: var(--input-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  width: 100%;
  padding: var(--spacing-md);
  border: none;
  border-radius: var(--radius-medium);
  font-family: inherit;
  font-size: 16px;
  resize: vertical;
  min-height: 60px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  backdrop-filter: blur(var(--blur-light));
  -webkit-backdrop-filter: blur(var(--blur-light));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  -webkit-appearance: none;
  appearance: none;
}

.post-editor .box:focus {
  outline: none;
  border-color: var(--electric-blue);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px var(--accent-blue-light);
}

.post-editor .box.cooo {
  height: 60px;
  overflow-y: hidden;
}

.post-editor .box.cooo:focus {
  height: auto;
  min-height: 120px;
  overflow-y: auto;
}

.post-editor .box::placeholder,
.ainfo .dat,
.icons > div,
.icons > button {
  color: var(--tertiary-text) !important;
}

.post-editor .flex-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: var(--spacing-sm);
}

.post-editor .io {
  width: 44px;
  height: 44px;
  padding: 10px;
  border-radius: var(--radius-medium);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.post-editor .io:hover {
  background: var(--accent-blue-light);
  border-color: var(--accent-blue);
}

.post-editor .flex-btn .btn {
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  color: var(--secondary-text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-blue);
  position: relative;
  overflow: hidden;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.post-editor .flex-btn .btn:hover {
  background: var(--blue-gradient-hover);
}

.post-editor .flex-btn .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

#imageBtn {
  display: none;
}

#image-preview {
  margin-top: var(--spacing-md);
}

.posts-container {
  padding: 0 var(--spacing-md) 20px;
  max-width: 600px;
  margin: 0 auto;
}

.box-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-admin {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--spacing-md);
}

.post-admin .pimg {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--electric-blue);
  box-shadow: 0 4px 12px var(--accent-blue-glow);
}

.ainfo {
  flex: 1;
  min-width: 0;
}

.ainfo .profile-link {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  cursor: pointer;
  margin-bottom: 4px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ainfo .profile-link:hover {
  color: var(--electric-blue);
}

.post-content {
  line-height: 1.7;
  white-space: pre-wrap;
  margin-bottom: var(--spacing-md);
  font-size: 15px;
  color: var(--tertiary-text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.post-image {
  border-radius: var(--radius-medium);
  margin-bottom: var(--spacing-md);
  max-width: 100%;
  height: auto;
}

.icons {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-top: var(--spacing-md);
  border-top: none;
  gap: var(--spacing-xs);
}

.icons > div, .icons > button {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: var(--radius-medium);
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  flex: 1;
}

.icons > div:hover, .icons > button:hover {
  color: var(--electric-blue);
  background: var(--hover-bg);
}

.like-btn.liked {
  color: rgb(250, 0, 42) !important;
}

a {
  text-decoration: none !important;
}

.icons i {
  font-size: 16px;
}

/* =============== Overlay =============== */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 98;
  display: none;
}

.menu-overlay.active {
  display: block;
}

/* =============== Loading Spinner =============== */
#spinner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(var(--blur-strong));
  -webkit-backdrop-filter: blur(var(--blur-strong));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loader {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  border-top-color: var(--electric-blue);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: var(--electric-blue);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  margin-top: 16px;
}

.loading {
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

.loading::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--glass-border);
  border-top: 3px solid var(--electric-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* =============== Custom Scrollbar =============== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--electric-blue);
}

/* =============== Focus States for Accessibility =============== */

/* =============== Reduced Motion Support =============== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============== Responsive =============== */
@media (max-width: 768px) {
  .nav a { font-size: 0.75rem; }
  .nav a i { font-size: 1.1rem; }
}

/* =============== Search specific styles =============== */
.no-results {
  text-align: center;
  padding: 20px;
  color: var(--text-primary);
}

.search-active .post-editor {
  display: none;
}

.clear-search {
  position: absolute;
  right: 50px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 16px;
  padding: 5px;
  opacity: 0.7;
}

.clear-search:hover {
  opacity: 1;
}

img {
  margin-top: 5px !important;
  margin-bottom: -10px !important;
  margin-left: 5px !important;
}