:root {
  --primary: #0056b3;
  --primary-dark: #003d7a;
  --secondary: #ffc107;
  --light: #f8f9fa;
  --dark: #212529;
  --gray: #6c757d;
  --light-gray: #e9ecef;
  --twitter-blue: #1D9BF0;
  --like-color: #f91880;
  --comment-color: #00ba7c;
  --share-color: #0095f6;
  --hover-bg: rgba(0, 0, 0, 0.05);
  --text-secondary: #65676B;
  --text-tertiary: #8E8E8E;
  --border-color: #dbdbdb;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
  padding: 0;
}

.post-container {
  width: 100%;
  background: white;
  padding: 20px;
  border-bottom: 1px solid var(--light-gray);
}

.post {
  margin-bottom: 0;
}

.post-header {
  display: flex;
  align-items: flex-start;
  
  position: relative;
}

.post-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 15px;
}

.post-user-info {
  flex: 1;
}

.post-user {
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--dark);
  gap: 4px; /* Reduced space between name, verified badge, and username */
  line-height: 1; /* Tighter line-height */
}

.post-username {
  color: var(--gray);
  font-size: 14px;
  margin: 0; /* Remove vertical margin */
  line-height: 1; /* Tighter spacing */
}

.verified-badge {
  color: var(--primary);
  font-size: 16px;
  margin-left: 5px;
}


.post-time {
  font-size: 13px;
  color: var(--gray);
  position: absolute;
  right: 0;
  top: 0;
}

.connect-btn {
  position: absolute;
  right: 0;
  top: 25px;
  background-color: white;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.connect-btn:hover {
  background-color: rgba(0, 86, 179, 0.1);
}

.post-content {
  margin-top: -9px; /* Pull closer to user info */
  margin-left: 65px; /* Align with avatar */
  margin-bottom: 10px;
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
}

.post-content a,
.post-content .hashtag,
.post-content .mention {
  color: var(--primary);
  text-decoration: none;
}

.post-content a:hover,
.post-content .hashtag:hover,
.post-content .mention:hover {
  text-decoration: underline;
}

.post-image {
  width: calc(100% - 65px);
  margin-left: 65px;
  border-radius: 8px;
  margin-bottom: 8px;
  max-height: 500px;
  object-fit: cover;
}

.post-actions {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-left: 65px;
  position: relative;
}

.post-action {
  display: flex;
  align-items: center;
  color: var(--gray);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.post-action i {
  margin-right: 5px;
}

.post-action:hover {
  color: var(--primary);
}

.post-action.share:hover {
  color: var(--twitter-blue);
}

.post-action.views {
  margin-left: auto;
  color: var(--gray);
}

.post-more {
  color: var(--gray);
  cursor: pointer;
  padding: 5px;
  margin-left: 5px;
}

.post-more:hover {
  color: var(--dark);
}

.post-avatar.initials {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: #0056b3;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
}

.media-container {
  width: calc(100% - 65px);
  margin-left: 65px;
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
}

.post-media {
  width: 100%;
  max-height: 510px;
  object-fit: cover;
  border-radius: 12px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  width: calc(100% - 65px);
  margin-left: 65px;
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.grid-media-container {
  aspect-ratio: 1/1;
  overflow: hidden;
}

.grid-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mention, .hashtag, .url {
  color: #1d9bf0;
  cursor: pointer;
}

.more-options-popup {
  position: fixed;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transform: translateY(20px);
  transition: transform 0.2s, opacity 0.2s;
  overflow: hidden;
}

.more-options-content {
  padding: 8px 0;
}

.more-option {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.more-option:hover {
  background-color: #f5f5f5;
}

.more-option i {
  width: 20px;
  text-align: center;
}

.media-viewer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}

.media-viewer-content {
  width: 100%;
  height: 100%;
  position: relative;
}

.viewer-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.media-viewer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}

.media-controls {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
}

.play-button {
  color: white;
  font-size: 30px;
  background: rgba(0, 0, 0, 0.5);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.feedback-message {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: white;
  padding: 12px 24px;
  border-radius: 30px;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 1000;
}

.feedback-message.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.post-action.share-action i {
  transform: rotate(90deg);
}

a, .mention, .hashtag, .url {
  text-decoration: none !important;
}

.mention, .hashtag, .url {
  color: #1d9bf0;
  cursor: pointer;
}

.media-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.media-viewer-overlay.closing {
  opacity: 0;
}

.media-viewer-container {
  width: 100%;
  max-width: 800px;
  height: 80vh;
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.media-viewer-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.media-viewer-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.media-viewer-item.active {
  opacity: 1;
}

.media-viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.media-viewer-video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: auto;
}

.media-viewer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 24px;
  cursor: pointer;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.5);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 24px;
  cursor: pointer;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.5);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-viewer-prev {
  left: 20px;
}

.media-viewer-next {
  right: 20px;
}

.media-viewer-dots {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 1001;
}

.media-viewer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.media-viewer-dot.active {
  background-color: white;
}

.video-preview {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.video-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
}
  

.refresh-container {
  position: fixed;
  top: -60px;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.refresh-loader {
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #0056b3;
  font-size: 20px;
}

.refresh-container.refreshing .refresh-loader {
  animation: spin 1s linear infinite;
}

.see-more {
  color: #0056b3;
  cursor: pointer;
  font-weight: bold;
}

.url {
  color: #0056b3;
  text-decoration: none;
}

.url:hover {
  text-decoration: underline;
}





.media-viewer-close {
  background: rgba(0, 0, 0, 0.5);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
}

.media-viewer-nav {
  background: rgba(0, 0, 0, 0.5);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
}

.media-viewer-dots {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.media-viewer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.media-viewer-dot.active {
  background-color: white;
}

.post-action.like-action.liked {
  color: #f91880;
}

.post-action.like-action.liked i {
  color: #f91880;
}

.post-action.like-action:hover {
  color: #f91880;
}

.post-action.like-action:hover i {
  color: #f91880;
}

like-button {
  display: inline-block;
}

.like-action {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.like-action:hover {
  background-color: rgba(254, 84, 102, 0.1);
}

.like-action.liked {
  color: var(--like-color);
}

.like-action i {
  font-size: 16px;
  transition: transform 0.2s ease;
}

.like-action:hover i {
  transform: scale(1.1);
}

.like-action.liked i {
  animation: like-pulse 0.45s ease;
}

@keyframes like-pulse {
  0% { transform: scale(1); }
  25% { transform: scale(1.2); }
  50% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.post-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  margin-top: 8px;
  border-top: 1px solid var(--border-color);
}

.post-action {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.post-action:hover {
  background-color: var(--hover-bg);
}

.post-action.comment-action:hover {
  color: var(--comment-color);
  background-color: rgba(0, 186, 124, 0.1);
}

.post-action.share-action:hover {
  color: var(--share-color);
  background-color: rgba(0, 149, 246, 0.1);
}

.post-action.views {
  margin-left: auto;
  color: var(--text-tertiary);
}

.post-more {
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
}

.post-more:hover {
  background-color: var(--hover-bg);
}


  
  .like-action {
    padding: 6px;
    font-size: 13px;
  }
  
  .like-action i {
    font-size: 15px;
  }
}

.view-counter-animation {
  display: inline-flex;
  flex-direction: column;
  overflow: hidden;
  height: 20px;
  vertical-align: middle;
  transition: transform 0.3s ease-out;
}

.view-counter-animation div {
  transition: opacity 0.2s ease;
}

.like-counter-animation {
  display: inline-flex;
  flex-direction: column;
  overflow: hidden;
  height: 20px;
  vertical-align: middle;
  transition: transform 0.3s ease-out;
}

.like-counter-animation div {
  transition: opacity 0.2s ease;
}

.like-action.liked i {
  color: #ff0000;
}

.edit-post-textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  resize: vertical;
  font-family: inherit;
  font-size: inherit;
}

.edit-post-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.edit-post-actions button {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
}

.edit-post-save {
  background-color: #0056b3;
  color: white;
}

.edit-post-cancel {
  background-color: #f0f0f0;
}

.post-error {
    padding: 20px;
    text-align: center;
    color: #ff4444;
    background: #ffeeee;
    border-radius: 8px;
    margin: 10px;
}

.post-error i {
    font-size: 24px;
    margin-bottom: 8px;
}

.retry-btn {
    margin-top: 10px;
    padding: 8px 16px;
    background: #0056b3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.post-loading .loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0056b3;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* Add this to your existing CSS */
.posts-container {
    margin-top: -10px; /* This will pull the posts up by 120px */
    
    /* Ensure it stays below any sticky headers */
}

/* Post Options Popup Styles */
.post-options-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.post-options-popup.visible {
  opacity: 1;
}

.post-options-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.post-options-container {
  background-color: white;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 1;
}

.dark-mode .post-options-container {
  background-color: #000;
  border-top: 1px solid #333;
}

.post-options-container.visible {
  transform: translateY(0);
}

.post-option {
  padding: 16px;
  display: flex;
  align-items: center;
  font-size: 18px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.dark-mode .post-option {
  border-bottom-color: #333;
}

.post-option:last-child {
  border-bottom: none;
}

.post-option i {
  margin-right: 12px;
  width: 24px;
  text-align: center;
}

.delete-option {
  color: #ff4444;
}

.cancel-option {
  font-weight: bold;
  justify-content: center;
  margin-top: 8px;
  border-radius: 8px;
  background-color: #f0f2f5;
}

.dark-mode .cancel-option {
  background-color: #333;
}

/* Edit Post Styles */
.edit-post-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.edit-post-container {
  background-color: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dark-mode .edit-post-container {
  background-color: #0056b3;
  border: 1px solid #333;
}

.edit-post-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.edit-post-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: #0056b3;
}

.close-edit-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #0056b3;
}

.edit-post-textarea {
  width: 100%;
  min-height: 150px;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  resize: vertical;
  margin-bottom: 16px;
}

.dark-mode .edit-post-textarea {
  background-color: #111;
  border-color: #333;
  color: white;
}

.edit-post-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.edit-post-actions button {
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
}

.cancel-edit-btn {
  background: none;
  border: 1px solid #ddd;
}

.dark-mode .cancel-edit-btn {
  border-color: #333;
}

.save-edit-btn {
  background-color: #0056b3;
  color: white;
  border: none;
}

/* Toast notifications */
.post-deleted-toast,
.post-updated-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 3000;
  animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Update your media-grid styles */
.media-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  width: calc(100% - 65px);
  margin-left: 65px;
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

/* Add this new rule for the third photo in a 3-photo grid */
.media-grid .grid-media-container:nth-child(3):last-child {
  grid-column: span 2;
  aspect-ratio: 2/1; /* Make it wider than tall */
}

/* Ensure the third photo fills its container */
.media-grid .grid-media-container:nth-child(3):last-child .grid-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
