/**
 * newx/app/static/css/style.css
 * 
 * Purpose: Custom styles to enhance the basic Bootstrap look for the Twitter-like social media app.
 * Description: Provides specific styling for tweet cards, navigation elements, buttons, 
 * and layout spacing to create a polished user interface.
 */

/* Global Styles & Layout Utilities */
body {
  padding-top: 56px; /* space for fixed navbar (tighter padding) */
  background-color: #f5f8fa; /* Light gray background similar to Twitter */
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

/* Navbar Overrides */
.navbar {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Main Container Spacing */
.container.main-content {
  max-width: 600px; /* Mimic the narrow feed width */
  padding-top: 2rem;
}

/* Post / Tweet Form Styling */
.card.create-post {
  border: 1px solid #e1e8ed;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem;
}

.card.create-post .card-header {
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
  font-weight: 600;
  border-radius: 0.75rem 0.75rem 0 0;
}

.create-post textarea {
  border: none;
  resize: none;
  box-shadow: none;
  font-size: 1.1rem;
  padding: 1rem;
}

.create-post textarea:focus {
  background-color: #fff;
  border-color: transparent;
  box-shadow: none;
}

/* Post / Tweet Card Styling */
.card.tweet-card {
  border: none;
  border-bottom: 1px solid #e1e8ed;
  border-radius: 0;
  padding: 1rem 0;
  margin-bottom: 0;
  transition: background-color 0.2s ease;
  overflow: hidden;
  max-width: 100%;
}

.card.tweet-card:hover {
  background-color: #f7f9fa;
}

.card.tweet-card .card-body {
  padding: 0;
  padding-left: 1rem;
  min-width: 0;
}

/* Global card containment — the ONLY overflow:hidden boundary.
   Inner containers use min-width:0 + overflow-wrap to fit content. */
.card {
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.card-body {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.tweet-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #e1e8ed;
}

.tweet-header {
  display: flex;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.tweet-username {
  font-weight: 700;
  color: #14171a;
  margin-right: 0.5rem;
  text-decoration: none;
}

.tweet-username:hover {
  text-decoration: underline;
}

.tweet-handle {
  color: #657786;
  font-size: 0.95rem;
}

.tweet-timestamp {
  color: #657786;
  font-size: 0.9rem;
  margin-left: auto;
}

.tweet-content,
.card-text {
  font-size: 1rem;
  line-height: 1.5;
  white-space: pre-wrap; /* Preserve line breaks */
  word-wrap: break-word;
}

.ai-post-content {
  font-size: 1rem;
  line-height: 1.5;
  white-space: normal; /* AI sends HTML, so let browser handle spacing */
  word-wrap: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Text alignment - use logical 'start' so RTL posts align right, LTR stays left */
.card-text,
.ai-post-content {
  text-align: start !important;
}

/* Post detail view - logical alignment */
.card-body .card-text,
.card-body .ai-post-content {
  text-align: start !important;
}

/* Specific override for post detail content - higher specificity */
.card-body > .d-flex > div > .card-text,
.card-body > .d-flex > div > .ai-post-content,
.card-body .w-100 > .card-text,
.card-body .w-100 > .ai-post-content {
  text-align: start !important;
  margin-left: 0 !important;
  margin-right: auto !important;
}

/* AI-Post Formatting */
.ai-post-content {
  color: #1a1a1b;
  line-height: 1.6;
}

.ai-post-content h1,
.ai-post-content h2,
.ai-post-content h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.ai-post-content ul,
.ai-post-content ol {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.ai-post-content li {
  margin-bottom: 0.25rem;
}

.ai-post-content p {
  margin-bottom: 1rem;
}

.ai-post-content blockquote {
  border-left: 4px solid #1da1f2;
  padding-left: 1rem;
  color: #657786;
  margin-bottom: 1rem;
}

.ai-post-content pre {
  background-color: #f6f8fa;
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  font-size: 85%;
  line-height: 1.45;
  margin-bottom: 16px;
  border: 1px solid #e1e4e8;
  max-width: 100%;
  box-sizing: border-box;
}

.ai-post-content code {
  background-color: rgba(27,31,35,0.05);
  border-radius: 3px;
  font-size: 85%;
  margin: 0;
  padding: 0.2em 0.4em;
  font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;
}

.ai-post-content pre code {
  background-color: transparent;
  padding: 0;
  border: 0;
  display: inline;
  line-height: inherit;
  margin: 0;
  overflow: visible;
  word-wrap: normal;
  font-size: 100%;
}
/* Dark theme text colors */
body.dark-theme .card-text,
body.dark-theme .ai-post-content {
  color: #e1e8ed;
}

/* Light theme text colors */
.card-text,
.ai-post-content {
  color: #14171a;
}

/* Action Buttons (Like, Reply etc placeholders) */
.tweet-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: space-between;
  max-width: 300px;
}

.action-btn {
  background: none;
  border: none;
  color: #657786;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}

.action-btn:hover {
  color: #1da1f2;
}

/* Button Overrides */
.btn-primary {
  background-color: #1da1f2;
  border-color: #1da1f2;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
}

.btn-primary:hover {
  background-color: #0d8ddb;
  border-color: #0c7cd5;
}

/* Flash Messages */
.alert {
  border-radius: 0.25rem;
  border: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  margin-bottom: 1.5rem;
}

/* Auth Forms */
.auth-container {
  max-width: 400px;
  margin: 3rem auto;
  padding: 2rem;
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.auth-title {
  text-align: center;
  margin-bottom: 2rem;
  color: #1da1f2;
}

/* Profile Page Styles */
.profile-header {
  background: white;
  padding: 1.5rem;
  border-bottom: 1px solid #e1e8ed;
  margin-bottom: 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.profile-avatar-lg {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 0 0 0 2px #e1e8ed;
}

.profile-info h2 {
  margin: 0;
  font-weight: 700;
}

.profile-info p {
  margin: 0.25rem 0 0;
  color: #657786;
}

/* Load More Button */
.load-more-container {
  text-align: center;
  margin: 2rem 0;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .container.main-content {
    padding: 1rem 0;
  }

  .card.create-post {
    border-radius: 0;
  }

  /* Mobile Navbar - Ensure hamburger is visible */
  .navbar-toggler {
    display: block !important;
    border: 2px solid rgba(0, 0, 0, 0.4) !important;
    padding: 0.4rem 0.6rem;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 0.375rem;
  }

  /* Dark theme hamburger button - light border and background */
  body.dark-theme .navbar-toggler {
    border: 2px solid rgba(255, 255, 255, 0.6) !important;
    background-color: rgba(255, 255, 255, 0.15);
  }

  .navbar-toggler-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    vertical-align: middle;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%280, 0, 0, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='3' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
  }

  /* Dark theme hamburger icon - WHITE lines */
  body.dark-theme .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='3' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
  }

  /* Light theme collapsed menu - SOLID white background */
  .navbar-collapse {
    background-color: #ffffff !important;
    z-index: 1000;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 0 0 0.5rem 0.5rem;
    padding: 0.75rem;
    margin-top: 0.5rem;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  }

  /* Dark theme collapsed menu - SOLID dark background */
  body.dark-theme .navbar-collapse {
    background-color: #192734 !important;
    border: 2px solid #38444d;
  }

  .navbar-collapse.show {
    display: block !important;
  }

  /* Dark theme menu background */
  body.dark-theme .navbar-collapse {
    background-color: #192734 !important;
    border-color: #38444d;
  }

  /* Mobile nav items spacing */
  .navbar-nav .nav-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.25rem 0;
  }

  .navbar-nav .nav-item:last-child {
    border-bottom: none;
  }

  body.dark-theme .navbar-nav .nav-item {
    border-color: #38444d;
  }

  /* Mobile nav links - ensure visibility */
  .navbar-nav .nav-link {
    padding: 0.75rem 1rem;
    text-align: center;
    font-weight: 500;
    color: #212529 !important; /* Dark text for light mode */
  }

  /* Dark theme mobile nav links - WHITE text */
  body.dark-theme .navbar-nav .nav-link {
    color: #ffffff !important;
  }

  /* Active/hover states for mobile nav */
  .navbar-nav .nav-link:hover,
  .navbar-nav .nav-link:active {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 0.375rem;
  }

  body.dark-theme .navbar-nav .nav-link:hover,
  body.dark-theme .navbar-nav .nav-link:active {
    background-color: rgba(255, 255, 255, 0.1);
  }
}

/* ============================================
   NEW POSTS BANNER
   ============================================ */
#new-posts-banner {
  padding: 6px 14px;
  background-color: #e8f5fd;
  color: #1a73e8;
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: 6px;
  margin-bottom: 8px;
  position: sticky;
  top: 56px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Mini avatar strip inside the new-posts banner */
.new-posts-avatar-strip {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.new-posts-mini-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #c7e6fc;
  margin-left: -6px;
  background: #c7e6fc;
}

.new-posts-mini-avatar:first-child {
  margin-left: 0;
}

#new-posts-banner.visible {
  opacity: 1;
}

#new-posts-banner:hover {
  background-color: #d0ebfc;
}

body.dark-theme #new-posts-banner {
  background-color: #1e3a4c;
  color: #5cb8f5;
}

body.dark-theme #new-posts-banner:hover {
  background-color: #244559;
}

/* ============================================
   PULL-TO-REFRESH INDICATOR
   ============================================ */
#pull-refresh-indicator {
  text-align: center;
  height: 0;
  overflow: hidden;
  transition: height 0.2s ease;
}

.pull-refresh-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  margin: 8px 0;
  border: 3px solid #e1e8ed;
  border-top-color: #1da1f2;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.pull-refresh-spinner.active {
  animation: spin 0.8s linear infinite;
  opacity: 1;
}

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

/* ============================================
   DARK THEME STYLES
   ============================================ */

/* Dark Theme - Body and Background */
body.dark-theme {
  background-color: #15202b;
  color: #e1e8ed;
}

/* Dark Theme - Navbar */
body.dark-theme .navbar {
  background-color: #192734 !important;
  border-bottom: 1px solid #38444d;
}

body.dark-theme .navbar-brand,
body.dark-theme .nav-link {
  color: #e1e8ed !important;
}

body.dark-theme .nav-link:hover {
  color: #1da1f2 !important;
}

body.dark-theme .navbar-toggler-icon {
  filter: invert(1);
}

/* Dark Theme - Cards */
body.dark-theme .card {
  background-color: #192734;
  border-color: #38444d;
  color: #e1e8ed;
}

body.dark-theme .card-header {
  background-color: #1e2f3e;
  border-color: #38444d;
  color: #e1e8ed;
}

body.dark-theme .card-header.bg-primary {
  background-color: #1da1f2 !important;
  color: #fff;
}

body.dark-theme .card-body {
  color: #e1e8ed;
}

body.dark-theme .card.tweet-card:hover {
  background-color: #1e2f3e;
}

/* Dark Theme - Form Elements */
body.dark-theme .form-control,
body.dark-theme .form-select,
body.dark-theme textarea {
  background-color: #253341;
  border-color: #38444d;
  color: #e1e8ed;
}

body.dark-theme .form-control:focus,
body.dark-theme .form-select:focus,
body.dark-theme textarea:focus {
  background-color: #253341;
  border-color: #1da1f2;
  color: #e1e8ed;
  box-shadow: 0 0 0 0.2rem rgba(29, 161, 242, 0.25);
}

body.dark-theme .form-label {
  color: #e1e8ed;
}

body.dark-theme .form-check-label {
  color: #e1e8ed;
}

body.dark-theme .form-check-input {
  background-color: #253341;
  border-color: #38444d;
}

body.dark-theme .form-check-input:checked {
  background-color: #1da1f2;
  border-color: #1da1f2;
}

/* Dark Theme - Text */
body.dark-theme .text-dark {
  color: #e1e8ed !important;
}

body.dark-theme .text-muted {
  color: #8899a6 !important;
}

body.dark-theme .text-primary {
  color: #1da1f2 !important;
}

/* Dark Theme - Links */
body.dark-theme a {
  color: #1da1f2;
}

body.dark-theme a:hover {
  color: #0d8ddb;
}

body.dark-theme a.text-decoration-none {
  color: inherit;
}

body.dark-theme .tweet-username {
  color: #e1e8ed;
}

body.dark-theme .tweet-content {
  color: #e1e8ed;
}

/* Dark Theme - Buttons */
body.dark-theme .btn-outline-secondary {
  color: #e1e8ed;
  border-color: #38444d;
}

body.dark-theme .btn-outline-secondary:hover {
  background-color: #253341;
  border-color: #1da1f2;
  color: #e1e8ed;
}

body.dark-theme .btn-link {
  color: #e1e8ed;
}

body.dark-theme .btn-close {
  filter: invert(1);
}

/* Dark Theme - Alerts */
body.dark-theme .alert {
  background-color: #192734;
  border-color: #38444d;
  color: #e1e8ed;
}

body.dark-theme .alert-info {
  background-color: #1e3a4c;
  border-color: #1da1f2;
  color: #e1e8ed;
}

body.dark-theme .alert-success {
  background-color: #1e3a2e;
  border-color: #17bf63;
  color: #e1e8ed;
}

body.dark-theme .alert-danger {
  background-color: #3a1e1e;
  border-color: #e0245e;
  color: #e1e8ed;
}

body.dark-theme .alert-warning {
  background-color: #3a321e;
  border-color: #ffad1f;
  color: #e1e8ed;
}

body.dark-theme .alert-light {
  background-color: #253341;
  border-color: #38444d;
  color: #e1e8ed;
}

/* Dark Theme - Accordion (Settings Page) */
body.dark-theme .accordion-item {
  background-color: #192734;
  border-color: #38444d;
}

body.dark-theme .accordion-button {
  background-color: #192734;
  color: #e1e8ed;
}

body.dark-theme .accordion-button:not(.collapsed) {
  background-color: #1e2f3e;
  color: #e1e8ed;
}

body.dark-theme .accordion-button::after {
  filter: invert(1);
}

body.dark-theme .accordion-body {
  background-color: #192734;
  color: #e1e8ed;
}

/* Dark Theme - Pagination */
body.dark-theme .pagination .page-link {
  background-color: #192734;
  border-color: #38444d;
  color: #e1e8ed;
}

body.dark-theme .pagination .page-link:hover {
  background-color: #253341;
  border-color: #1da1f2;
  color: #e1e8ed;
}

body.dark-theme .pagination .page-item.active .page-link {
  background-color: #1da1f2;
  border-color: #1da1f2;
  color: #fff;
}

body.dark-theme .pagination .page-item.disabled .page-link {
  background-color: #192734;
  border-color: #38444d;
  color: #657786;
}

/* Dark Theme - Footer */
body.dark-theme #mainFooter {
  background-color: #192734 !important;
  border-top: 1px solid #38444d;
  color: #8899a6 !important;
}

/* Dark Theme - Dropdown */
body.dark-theme .dropdown-menu {
  background-color: #192734;
  border-color: #38444d;
}

body.dark-theme .dropdown-item {
  color: #e1e8ed;
}

body.dark-theme .dropdown-item:hover {
  background-color: #253341;
  color: #e1e8ed;
}

body.dark-theme .dropdown-divider {
  border-top-color: #38444d;
}

/* Dark Theme - Modals */
body.dark-theme .modal-content {
  background-color: #192734;
  border-color: #38444d;
  color: #e1e8ed;
}

body.dark-theme .modal-header {
  border-color: #38444d;
}

body.dark-theme .modal-footer {
  border-color: #38444d;
}

/* Dark Theme - Inputs Placeholder */
body.dark-theme ::placeholder {
  color: #657786;
  opacity: 1;
}

body.dark-theme :-ms-input-placeholder {
  color: #657786;
}

body.dark-theme ::-ms-input-placeholder {
  color: #657786;
}

/* Dark Theme - Borders */
body.dark-theme .border-light {
  border-color: #38444d !important;
}

body.dark-theme .border-primary {
  border-color: #1da1f2 !important;
}

/* Dark Theme - Background Utilities */
body.dark-theme .bg-light {
  background-color: #253341 !important;
}

/* Dark Theme - Badges */
body.dark-theme .badge.bg-secondary {
  background-color: #657786 !important;
  color: #192734;
}

/* ============================================
   VIDEO STYLING - Desktop Feed
   ============================================ */

/* Video container for consistent sizing */
.video-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  background-color: #000;
  border-radius: 0.5rem;
  overflow: hidden;
}

/* Video element styling — fill card width, adapt height to aspect ratio */
.video-container video {
  width: 100%;
  max-height: 80vh;
  display: block;
  border-radius: 0.5rem;
  object-fit: contain; /* Show full video, no cropping */
}

/* Post media images — fill card width, extend height naturally */
.post-media-img {
  width: 100%;
  height: auto;
  border-radius: 0.5rem;
  display: block;
}

/* Dark theme video container */
body.dark-theme .video-container {
  background-color: #000;
}

/* Video fallback message styling */
.video-fallback {
  background-color: rgba(0, 0, 0, 0.8);
  margin: 0;
  font-size: 0.9rem;
}

.video-fallback a {
  color: #000;
  text-decoration: none;
}

/* Video fallback message */
.video-fallback {
  background-color: #333;
  margin: 0;
  border-radius: 0.5rem;
}

.video-fallback a {
  color: #000;
  text-decoration: none;
}

.video-fallback a:hover {
  background-color: #f0f0f0;
}

/* ============================================
   URL PREVIEW CARD STYLING
   ============================================ */

/* URL Preview card - ensure consistent sizing */
.url-preview-card {
  max-width: 100%;
  overflow: hidden;
  border-radius: 12px;
}

.url-preview-card .card-body {
  padding: 0.6rem 0.75rem;
}

/* Full-width stacked preview image (matches SMS/iMessage/Twitter style) */
.url-preview-image-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

.url-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
/* Defensive fix for center-justified text issue reported by user */
.container .card .card-body .card-text,
.container .card .card-body .ai-post-content,
.tweet-card .card-text,
.reply-card .card-text,
.quote-preview-card .card-text,
.ai-post-content {
  text-align: start !important;
  justify-content: flex-start !important;
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

/* Feed Content Truncation */
.tweet-card .card-body .feed-content {
    display: -webkit-box !important;
    -webkit-line-clamp: 4 !important;
    line-clamp: 4 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    word-break: break-word;
}

/* Quote Retweet Preview — truncate embedded content to 4 lines */
.tweet-card .quote-preview-card .card-text {
    display: -webkit-box !important;
    -webkit-line-clamp: 4 !important;
    line-clamp: 4 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    word-break: break-word;
}

/* ============================================
   REPLY CARD & CONTENT CONTAINMENT
   Ensure all content stays within card boundaries
   on desktop, tablet, and phone
   ============================================ */

/* Reply card container — fluid boundaries */
.reply-card {
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

/* Flex containers inside cards: children must shrink.
   Flex items default to min-width:auto which prevents shrinking below
   content width. min-width:0 fixes this. */
.card .d-flex > * {
  min-width: 0;
}

/* The .w-100 content area inside d-flex must not exceed card width. */
.reply-card .w-100,
.tweet-card .w-100,
.card .w-100 {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

/* Code-block-wrapper created by JS — must respect parent width */
.code-block-wrapper {
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* All block children inside cards must respect boundaries */
.card-text pre,
.card-text code,
.card-text img,
.card-text table,
.ai-post-content pre,
.ai-post-content code,
.ai-post-content img,
.ai-post-content table {
  max-width: 100%;
  box-sizing: border-box;
}

/* Code blocks scroll horizontally inside card — never expand beyond */
.card-text pre,
.ai-post-content pre {
  overflow-x: auto;
  overflow-y: hidden;
}

/* Inline code that's too long — allow wrapping */
.card-text code,
.ai-post-content code {
  word-break: break-all;
}

/* Images inside posts/replies must fit */
.card-text img,
.ai-post-content img {
  height: auto;
}

/* ============================================
   BOOTSTRAP NAV-TABS (Friends Tab, etc.)
   ============================================ */

/* Light theme (default) - Bootstrap handles most of this */
.nav-tabs .nav-link {
  color: #495057;
  border-color: #dee2e6 #dee2e6 #dee2e6;
}

.nav-tabs .nav-link:hover {
  border-color: #e9ecef #e9ecef #dee2e6;
  color: #495057;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
  color: #1da1f2;
  font-weight: 700;
  background-color: #fff;
  border-color: #dee2e6 #dee2e6 #fff;
  border-bottom: 3px solid #1da1f2;
}

/* Dark theme - Nav tabs */
body.dark-theme .nav-tabs .nav-link {
  color: #e1e8ed;
  border-color: #38444d;
}

body.dark-theme .nav-tabs .nav-link:hover {
  border-color: #495057 #495057 #38444d;
  color: #e1e8ed;
  background-color: #1e2f3e;
}

body.dark-theme .nav-tabs .nav-link.active,
body.dark-theme .nav-item.show .nav-link {
  color: #1da1f2;
  font-weight: 700;
  background-color: #192734;
  border-color: #38444d #38444d #192734;
  border-bottom: 3px solid #1da1f2;
}

body.dark-theme .nav-tabs {
  border-bottom-color: #38444d;
}

body.dark-theme .badge.bg-secondary {
  background-color: #657786 !important;
  color: #192734;
}

/* ============================================
   BOOTSTRAP LIST-GROUP (Notifications, Friends lists)
   ============================================ */

/* Light theme (default) - Bootstrap handles most of this */
.list-group-item {
  background-color: #fff;
  border-color: rgba(0, 0, 0, 0.125);
  color: #212529;
}

.list-group-item-action {
  color: #495057;
}

.list-group-item-action:hover,
.list-group-item-action:focus {
  background-color: #f8f9fa;
  color: #495057;
}

.list-group-item-primary {
  background-color: #cfe2ff;
  color: #084298;
}

/* Dark theme - List group */
body.dark-theme .list-group-item {
  background-color: #192734;
  border-color: #38444d;
  color: #e1e8ed;
}

body.dark-theme .list-group-item-action {
  color: #e1e8ed;
}

body.dark-theme .list-group-item-action:hover,
body.dark-theme .list-group-item-action:focus {
  background-color: #1e2f3e;
  color: #e1e8ed;
}

/* Dark theme - List group item with primary state (unread notifications) */
body.dark-theme .list-group-item-primary {
  background-color: #1e3a4c;
  color: #a9cce8;
}

body.dark-theme .list-group-item-primary:hover,
body.dark-theme .list-group-item-primary:focus {
  background-color: #244559;
}

/* ============================================
   FRIEND APPROVAL CARD (in notifications)
   ============================================ */

/* Friend approval card uses inline styles with CSS variables,
   but we add explicit dark theme overrides for consistency */
body.dark-theme .card.friend-request-card {
  background-color: #253341 !important;
  border-color: #38444d !important;
}

/* ============================================
   ANNOUNCEMENT POST STYLES
   ============================================ */

/* Announcement banner - gradient header with emoji and title */
.announcement-banner {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  border-radius: 10px;
  font-size: 1.3em;
  font-weight: bold;
  text-align: center;
  margin-bottom: 15px;
}

/* Announcement bullet points */
.announcement-bullets {
  margin: 15px 0;
  padding-left: 25px;
}

.announcement-bullets li {
  margin-bottom: 10px;
  font-size: 1.05em;
}

/* Announcement footer */
.announcement-footer {
  color: #6c757d;
  font-size: 0.9em;
  margin-top: 15px;
  text-align: center;
}

/* Dark theme - Announcement styles */
body.dark-theme .announcement-banner {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
  color: #ffffff;
}

body.dark-theme .announcement-bullets li {
  color: #e1e8ed;
}

body.dark-theme .announcement-footer {
  color: #8899a6;
}

/* ============================================
   ANNOUNCEMENT POST STYLES
   ============================================ */

/* Announcement banner - gradient header for platform announcements */
.announcement-banner {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  padding: 15px 20px;
  border-radius: 10px;
  font-size: 1.3em;
  font-weight: bold;
  text-align: center;
  margin-bottom: 15px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Announcement post card styling */
.announcement-post .card {
  border: 2px solid #667eea;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
}

.announcement-post .card-body {
  padding: 1.25rem;
}

/* Announcement bullet points */
.announcement-post ul {
  margin: 15px 0;
  padding-left: 25px;
}

.announcement-post li {
  margin-bottom: 10px;
  font-size: 1.05em;
  line-height: 1.5;
}

/* Announcement footer */
.announcement-footer {
  color: #6c757d;
  font-size: 0.9em;
  margin-top: 15px;
  text-align: center;
}

/* Dark theme - Announcement styles */
body.dark-theme .announcement-banner {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
  box-shadow: 0 4px 12px rgba(90, 103, 216, 0.4);
}

body.dark-theme .announcement-post .card {
  border-color: #5a67d8;
  box-shadow: 0 4px 20px rgba(90, 103, 216, 0.25);
}

body.dark-theme .announcement-footer {
  color: #a0aec0;
}

body.dark-theme .card.friend-request-card .text-muted {
  color: #8899a6 !important;
}

/* ============================================
   POST IMAGE GALLERY (Premium CSS Grid)
   ============================================ */
.post-image-gallery {
  display: grid;
  gap: 4px;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px solid rgba(0,0,0,0.05);
}

body.dark-theme .post-image-gallery {
  border-color: rgba(255,255,255,0.05);
}

/* 1 Image/Video: Variable height, constrained per media type */
.post-image-gallery[data-count="1"] {
  grid-template-columns: 1fr;
  max-height: none;
}
.post-image-gallery[data-count="1"] .gallery-item {
  aspect-ratio: auto;
  height: auto; /* Override height:100% so container sizes to content */
}
.post-image-gallery[data-count="1"] .gallery-item img {
  position: static; /* Override absolute positioning for single images */
  width: 100%;
  height: auto;
  max-height: 600px;
  object-fit: contain;
  background-color: #000;
}

/* Single video: show full aspect ratio (portrait videos from iPhone etc.) */
.post-image-gallery[data-count="1"] .gallery-item video {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
}

/* 2 Images: Side by side */
.post-image-gallery[data-count="2"] {
  grid-template-columns: 1fr 1fr;
  aspect-ratio: 16 / 9;
}

/* 3 Images: 1 tall left, 2 stacked right */
.post-image-gallery[data-count="3"] {
  grid-template-columns: 60% 40%;
  grid-template-rows: 50% 50%;
  aspect-ratio: 16 / 9;
}
.post-image-gallery[data-count="3"] .gallery-item:nth-child(1) {
  grid-row: 1 / 3;
  grid-column: 1 / 2;
}
.post-image-gallery[data-count="3"] .gallery-item:nth-child(2) {
  grid-row: 1 / 2;
  grid-column: 2 / 3;
}
.post-image-gallery[data-count="3"] .gallery-item:nth-child(3) {
  grid-row: 2 / 3;
  grid-column: 2 / 3;
}

/* 4 Images: 2x2 */
.post-image-gallery[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 16 / 9;
}
.post-image-gallery[data-count="4"] .gallery-item:nth-child(1) {
  grid-row: 1 / 2;
  grid-column: 1 / 2;
}
.post-image-gallery[data-count="4"] .gallery-item:nth-child(2) {
  grid-row: 1 / 2;
  grid-column: 2 / 3;
}
.post-image-gallery[data-count="4"] .gallery-item:nth-child(3) {
  grid-row: 2 / 3;
  grid-column: 1 / 2;
}
.post-image-gallery[data-count="4"] .gallery-item:nth-child(4) {
  grid-row: 2 / 3;
  grid-column: 2 / 3;
}

/* Media preview strip (pre-submit thumbnails) */
#media-preview-strip .position-relative > div {
  background-color: #e9ecef;
}
body.dark-theme #media-preview-strip .position-relative > div {
  background-color: #253341;
  color: #e7e9ea;
}

.gallery-item {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
  background-color: #f7f9fa;
  cursor: zoom-in;
}

body.dark-theme .gallery-item {
  background-color: #253341;
}

.gallery-item img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

/* Multi-item gallery videos: fill grid cell */
.gallery-item video {
  object-fit: cover;
}

.gallery-item:hover img {
  transform: scale(1.02);
}

/* ============================================
   MOBILE / TABLET RESPONSIVE MARGINS
   Reduces horizontal padding on small screens.
   base.html wraps content in .container > .row > .col, and page
   templates add their own .container > .row > .col-md-8 inside.
   On mobile this stacks up to ~48px+ of wasted horizontal space.
   Fix: reduce padding at EVERY level on screens < 992px.
   ============================================ */

/* Phones (up to 575px) — tightest layout */
@media (max-width: 575.98px) {
  /* Outer container from base.html — minimal side padding */
  body > nav + .container,
  body > .container {
    padding-left: 4px !important;
    padding-right: 4px !important;
  }

  /* All rows: tighter gutters */
  .row {
    --bs-gutter-x: 8px;
  }

  /* Inner containers from page templates — no extra padding */
  .container .container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
  }

  /* Reduce top margin on inner content containers */
  .container .container.mt-4 {
    margin-top: 0.75rem !important;
  }

  /* Cards: tighter horizontal padding */
  .card-body {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  /* Profile header action buttons — stack compactly */
  .profile-action-group {
    margin-top: 0.5rem;
    flex-wrap: wrap;
  }
}

/* Tablets + large phones (576px–991px) */
@media (min-width: 576px) and (max-width: 991.98px) {
  /* Outer container — slightly reduced padding */
  body > nav + .container,
  body > .container {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  /* Tighter gutters */
  .row {
    --bs-gutter-x: 16px;
  }

  /* Inner containers — no extra padding */
  .container .container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
  }

  .container .container.mt-4 {
    margin-top: 1rem !important;
  }
}

/* Landscape orientation on phones/tablets — recover vertical space */
@media (max-width: 991.98px) and (orientation: landscape) {
  .container .container.mt-4 {
    margin-top: 0.5rem !important;
  }

  .navbar {
    margin-bottom: 0.75rem;
  }

  .card.tweet-card {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
  }
}

/* ==============================================
   QUICK-ACCESS TOOLBAR (left edge)
   ============================================== */
#quick-toolbar {
  position: fixed;
  top: 56px;
  left: 0;
  width: 52px;
  bottom: 0;
  z-index: 1020;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

#quick-toolbar-content {
  pointer-events: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  overflow-y: auto;
  max-height: calc(100vh - 70px);
}

/* Hide scrollbar on toolbar */
#quick-toolbar-content::-webkit-scrollbar { display: none; }
#quick-toolbar-content { scrollbar-width: none; }

/* Tab strip (mobile only) */
#quick-toolbar-tab {
  display: none;
  pointer-events: auto;
}

/* Avatar buttons */
.qt-avatar-btn {
  position: relative;
  background: none;
  border: 2px solid transparent;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.qt-avatar-btn:hover {
  transform: scale(1.15);
  border-color: #1d9bf0;
}

.qt-avatar {
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.qt-status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ── Online / offline dot states (shared by .status-dot and .qt-status-dot) ── */
@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 210, 106, 0.55); }
  50%       { box-shadow: 0 0 0 3px rgba(0, 210, 106, 0.10); }
}

.status-dot-online {
  background: #00d26a !important;
  animation: status-pulse 2.5s ease-in-out infinite;
}

.status-dot-offline {
  background: #e2e8f0 !important; /* pale gray — much less prominent */
}

[data-bs-theme="dark"] .status-dot-offline {
  background: #4b5563 !important;
}

/* Divider */
.qt-divider {
  width: 30px;
  margin: 4px 0;
  border-top: 1px solid rgba(0,0,0,0.15);
}

/* Tool buttons */
.qt-tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}

a.qt-tool-btn {
  text-decoration: none;
  color: inherit;
}

.qt-tool-btn:hover:not(:disabled) {
  background: rgba(29,155,240,0.1);
  transform: scale(1.1);
}

.qt-tool-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Tablet/Desktop (≥768px): always visible, transparent bg ── */
@media (min-width: 768px) {
  #quick-toolbar-tab { display: none !important; }
}

/* ── Mobile (<768px): collapsible with backdrop ── */
@media (max-width: 767.98px) {
  #quick-toolbar {
    width: 56px;
  }

  #quick-toolbar-content {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 0 12px 12px 0;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.08);
    transition: opacity 0.25s, transform 0.25s;
  }

  #quick-toolbar-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 44px;
    background: rgba(29,155,240,0.8);
    color: #fff;
    border-radius: 0 6px 6px 0;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.15s;
  }

  #quick-toolbar-tab:active {
    background: rgba(29,155,240,1);
  }

  /* Collapsed state */
  #quick-toolbar.collapsed #quick-toolbar-content {
    opacity: 0;
    transform: translateX(-60px);
    pointer-events: none;
  }

  #quick-toolbar.collapsed #quick-toolbar-tab {
    display: flex;
  }

  #quick-toolbar:not(.collapsed) #quick-toolbar-tab {
    display: flex;
  }

  #quick-toolbar:not(.collapsed) #quick-toolbar-tab::after {
    content: '\2039';
  }

  #quick-toolbar.collapsed #quick-toolbar-tab::after {
    content: '\203A';
  }
}

/* ── Dark theme ── */
[data-bs-theme="dark"] .qt-status-dot {
  border-color: #212529;
}

[data-bs-theme="dark"] .qt-divider {
  border-top-color: rgba(255,255,255,0.15);
}

[data-bs-theme="dark"] .qt-tool-btn {
  border-color: rgba(255,255,255,0.1);
  background: rgba(33,37,41,0.6);
}

[data-bs-theme="dark"] .qt-tool-btn:hover:not(:disabled) {
  background: rgba(29,155,240,0.2);
}

@media (max-width: 767.98px) {
  [data-bs-theme="dark"] #quick-toolbar-content {
    background: rgba(33,37,41,0.85);
  }
}

/* ── New-Post FAB (all screen sizes) ── */
#new-post-fab {
  position: fixed;
  bottom: 24px;
  left: 28px;       /* clears the 20px collapse-tab strip on mobile */
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(29, 155, 240, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1030;
  box-shadow: 0 3px 14px rgba(0,0,0,0.20);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, opacity 0.2s;
}

#new-post-fab:hover,
#new-post-fab:focus {
  background: rgba(29, 155, 240, 0.88);
  transform: scale(1.08);
  outline: none;
}

#new-post-fab:active {
  transform: scale(0.95);
}

[data-bs-theme="dark"] #new-post-fab {
  background: rgba(29, 155, 240, 0.52);
  box-shadow: 0 3px 14px rgba(0,0,0,0.40);
}
