/* ======================================= */
/* 1. Theme Variables (Dual-Theme Setup)   */
/* ======================================= */

/* Define the colors for the channel page using your main.css variables (Light Theme) */
:root, .light-theme {
    --channel-text: var(--text-dark, #1F2937); /* Default to dark text */
    --channel-bg: var(--bg-light, #F9FAFB); /* Default to light background */
    --channel-card-bg: var(--bg-white, #FFFFFF); /* Default to white card background */
    --channel-border: var(--border-light, #E5E7EB); /* Default to light border */
    --channel-secondary-text: var(--text-medium, #6B7280); /* Secondary text color */
}

/* Dark Theme Overrides - Activated by body.dark-theme or html[data-theme="dark"] */
.dark-theme {
    --channel-text: var(--text-light, #F9FAFB);
    --channel-bg: var(--bg-dark, #111827);
    --channel-card-bg: #1F2937; /* A slightly lighter dark for contrast/elevation */
    --channel-border: #374151;
    --channel-secondary-text: #9CA3AF;
}

/* Apply theme colors to the main content area */
.channel-page {
    background-color: var(--channel-bg);
    color: var(--channel-text);
    min-height: 100vh;
    padding: 20px; 
    transition: background-color 0.3s, color 0.3s; /* Smooth theme transition */
}

/* ======================================= */
/* 2. Channel Header Layout (Flexbox)      */
/* ======================================= */

.channel-header {
    margin-bottom: 20px;
}

/* Banner Area */
.channel-banner {
    width: 100%;
    height: 200px;
    background-color: var(--channel-border); 
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    margin-bottom: -60px; /* Overlap for avatar */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Profile Info - Using Flexbox for Clean Alignment */
.profile-info {
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    flex-wrap: wrap; 
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--channel-card-bg); 
    object-fit: cover;
    z-index: 10;
}

.channel-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0; 
}

.channel-name {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.channel-stats {
    color: var(--channel-secondary-text);
    font-size: 0.9rem;
    margin: 4px 0 10px;
}

.subscribe-btn {
    background-color: var(--primary-color);
    color: var(--text-light, white);
    border: none;
    padding: 20px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    align-self: flex-start;
}

.subscribe-btn:hover {
    
    background-color: var(--primary-dark, #047857);
}

/* ======================================= */
/* 3. Navigation/Tabs Layout               */
/* ======================================= */

.channel-nav {
    border-bottom: 1px solid var(--channel-border);
    margin-top: 20px;
    padding: 0 20px;
}

.nav-list {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-x: auto; /* Enables horizontal scrolling for many tabs on mobile */
    scrollbar-width: none; 
    -ms-overflow-style: none;
}

.nav-list::-webkit-scrollbar {
    display: none; 
}

.nav-link {
    display: block;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--channel-secondary-text);
    font-weight: 500;
    transition: color 0.3s, border-bottom 0.3s;
    border-bottom: 3px solid transparent;
    margin-right: 1px;
    white-space: nowrap; 
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

/* ======================================= */
/* 4. Content Grid (Videos/Quizzes)        */
/* ======================================= */

.content-section {
    padding: 20px;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 20px 0 15px;
}

/* Using CSS Grid for a robust, responsive video layout */
.video-grid {
    display: grid;
    /* Responsive grid: Min-max to ensure videos are at least 250px wide, and fill the container */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.video-card {
    background-color: var(--channel-card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.video-thumbnail {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9; /* Standard video ratio */
    object-fit: cover;
    display: block;
}

.video-details {
    padding: 10px 12px;
}

.video-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 4px;
    /* Truncate long titles to two lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    font-size: 0.85rem;
    color: var(--channel-secondary-text);
}


/* ======================================= */
/* 5. Responsiveness (Mobile First)        */
/* ======================================= */

/* Styles for screens up to 768px (Mobile) */
@media (max-width: 768px) {
    .channel-page {
        padding: 10px;
    }
    
    .profile-info {
        flex-direction: column; /* Stack avatar and details vertically */
        align-items: flex-start;
        padding: 0 10px;
    }

    .profile-avatar {
        width: 90px;
        height: 90px;
        border: 3px solid var(--channel-card-bg);
    }
    
    .channel-details {
        margin-top: 10px;
    }

    .channel-name {
        font-size: 1.5rem;
    }
    
    .subscribe-btn {
        margin-top: 10px;
        align-self: stretch; /* Make the button full width on mobile */
        text-align: center;
    }
    
    .video-grid {
        /* Single column for video cards on small screens */
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* Styles for screens between 769px and 1024px (Tablet) */
@media (min-width: 769px) and (max-width: 1024px) {
    .video-grid {
        /* Ensure a minimum of two columns on tablets */
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

/* ======================================= */
/* 2.5. Channel Owner Actions Styling      */
/* ======================================= */

.channel-actions {
    /* Use flexbox to align the buttons next to each other */
    display: flex;
    /* Create a small gap between the buttons */
    gap: var(--space-3); 
    margin-top: var(--space-4); /* Add space above the buttons, separating them from the description */
    margin-bottom: var(--space-6); /* Add space below the buttons before posts start */
    
    /* Ensure buttons stay neatly packed on one line */
    flex-wrap: wrap; 
}

/* Style the buttons specifically for the channel page */
.channel-actions .btn {
    /* Apply a clean, rounded, slightly elevated style */
    padding: 10px 18px;
    border-radius: 25px; /* Highly rounded pill shape */
    font-weight: 500;
    font-size: var(--text-base);
    transition: all 0.2s ease;
    text-decoration: none;
}

/* Style for the "Edit Channel" button (secondary-btn) */
.channel-actions .secondary-btn {
    background-color: var(--channel-card-bg);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.channel-actions .secondary-btn:hover {
    background-color: var(--primary-lightest);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}



.channel-actions .danger-btn:hover {
    background-color: var(--danger-dark);
    box-shadow: 0 4px 8px rgba(255, 0, 0, 0.3);
}

/* Dark Theme Overrides for Channel Actions */
[data-theme="dark"] .channel-actions .secondary-btn {
    background-color: var(--channel-card-bg);
    color: var(--primary-color); /* Keep the primary color visible */
    border-color: var(--primary-color);
}

[data-theme="dark"] .channel-actions .secondary-btn:hover {
    background-color: var(--primary-darkest); /* Darker background on hover */
}


.back-btn {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.back-btn:hover {
  text-decoration: underline;
}

/* ======================================= */
/* CHANNEL POSTS GRID                      */
/* ======================================= */

#channel-posts {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* ✅ 4 posts per row */
    gap: 20px;
    margin-top: 20px;
}

/* Large laptops */
@media (max-width: 1200px) {
    #channel-posts {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablets */
@media (max-width: 900px) {
    #channel-posts {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile */
@media (max-width: 600px) {
    #channel-posts {
        grid-template-columns: 1fr;
    }
}
.video-card {
    height: 100%;              /* ✅ keeps cards equal height */
    display: flex;
    flex-direction: column;
}

.profile-info {
    display: flex;
    align-items: center;        /* ✅ vertical center */
    gap: 24px;
}

.profile-avatar {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    flex-shrink: 0;             /* ✅ never squish */
}

.channel-details {
    display: flex;
    flex-direction: column;
    justify-content: center;    /* ✅ fixes top/bottom gap */
    gap: 12px;
}

.channel-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.channel-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.channel-actions .secondary-btn {
    padding: 10px 18px;
    border-radius: 20px;
}

@media (max-width: 768px) {
    .profile-info {
        align-items: flex-start;
    }

    .channel-actions {
        width: 100%;
    }

    .channel-actions button,
    .channel-actions a {
        width: 100%;
        text-align: center;
    }
}

/* A. FIX: Avatar & Heading Alignment */
.profile-info {
    display: flex;
    align-items: center;        /* Vertically centers all children (Avatar, Text, Buttons) */
    /* Distributes space: Pushes the action buttons block to the far right */
    justify-content: space-between; 
    gap: 32px;                  /* Consistent space between the main blocks */
    padding: 20px 0;            /* Adds vertical padding */
    border-bottom: 1px solid var(--channel-border); /* Optional: A clean separation line */
}

/* Ensure avatar size is consistent */
.profile-avatar {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    flex-shrink: 0;             /* Prevents the avatar from shrinking */
}

/* Text alignment fix (Removes default browser margins on h1) */
.channel-text-details {
    flex-grow: 1;               /* Allows text block to take up available space in the middle */
}

.channel-text-details h1,
.channel-text-details .channel-stats {
    margin: 0;                  /* Crucial: Removes default margins on H1/P for perfect vertical centering */
    line-height: 1.2;
}

.channel-stats {
    margin-top: 4px;            /* Small, clean gap between name and stats */
    color: var(--channel-secondary-text);
}
/* B. FIX: Gap for Primary Buttons (Subscribe/Create Post) */
.channel-actions {
    display: flex;
    gap: 10px;                  /* Fixes the gap between the two buttons */
    flex-shrink: 0;
}

.posts-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 10px;
    max-width: 900px;       /* change value to taste (900-1000 is nice) */
    width: 100%;
    margin: 0 auto;         /* center it */
    /* if its parent (#channel-posts) is a grid, span all columns */
    grid-column: 1 / -1;
}



.tg-post {
    background-color: var(--channel-card-bg);
    color: var(--channel-text);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: 0.2s ease, background-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tg-post:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}


.tg-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--channel-text);
}

.tg-text {
    font-size: 14px;
    line-height: 1.45;
    color: var(--channel-secondary-text);
    margin-top: 10px;
    white-space: pre-line;
}

.tg-comments {
    font-size: 13px;
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    margin-top: 6px;
}

.comments-container {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--channel-border);
}


.tg-image {
    width: 100%;
    max-height: 360px;
    object-fit: cover;
    border-radius: 10px;
    margin-top: 8px;
}

.tg-time {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    text-align: right;
}

.comments-modal {
    position: fixed;
    top:0; left:0;
    width:100%; height:100%;
    background: rgba(0,0,0,0.3); /* dim behind glass */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 10px;
}

.comments-modal-content {
    background: rgba(255, 255, 255, 0.15); /* translucent glass */
    backdrop-filter: blur(12px) saturate(180%);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.25);
    width: 100%;
    max-width: 650px;  /* wider modal for comments */
    height: 500px; /* taller for better scroll */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.comments-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.3);
    font-weight: 600;
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Input area + reaction emojis */
.comments-input {
    display: flex;
    padding: 10px 16px;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.3);
}

.comments-input input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(68, 67, 67, 0.25);
    background: rgba(41, 39, 39, 0.1);
    color: var(--channel-text);
    outline: none;
}

.comments-input button {
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    background: var(--primary-color);
    color: #fff;
    cursor: pointer;
    font-weight: 500;
}



.tg-like-btn {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--primary-color);
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tg-like-btn.liked i {
    color: red;
}

.modal-comment-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    padding: 6px 0;
}

.modal-comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.modal-comment-content span {
    display: block;
    margin-top: 2px;
    color: var(--channel-secondary-text);
}

:root {
  --surface-color: #ffffff;
  --surface-alt-color: #f3f4f6;
  --text-color: #111827;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --hover-color: rgba(0,0,0,0.06);
  --primary-color: #10B981;
}

[data-theme="dark"] {
  --surface-color: #121212;
  --surface-alt-color: #1e1e1e;
  --text-color: #e5e7eb;
  --text-muted: #9ca3af;
  --border-color: #2a2a2a;
  --hover-color: rgba(255,255,255,0.08);
  --primary-color: #4ADFB8;  
}






/* ===============================
   PROFILE POPUP (LIGHT + DARK)
   =============================== */

.profile-popup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 12000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.profile-popup.active {
  display: flex;
  opacity: 1;
}

/* Overlay */
.profile-popup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

/* Card */
.profile-popup-card {
  position: relative;
  width: 90%;
  max-width: 420px;
  background: var(--surface-color, #ffffff);
  color: var(--text-color, #111);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 35px rgba(0,0,0,0.35);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s ease;
  z-index: 12010;
}

.profile-popup.active .profile-popup-card {
  transform: translateY(0) scale(1);
}

/* Close button */
.profile-popup-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted, #888);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  font-size: 18px;
  transition: background 0.2s ease, color 0.2s ease;
}

.profile-popup-close:hover {
  background: var(--hover-color, rgba(0,0,0,0.08));
  color: var(--text-color, #111);
}

/* Body layout */
.profile-popup-body {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

/* Avatar */
.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--primary-color, #6366f1);
  padding: 3px;
  object-fit: cover;
}

/* Info */
.profile-info {
  flex: 1;
}

/* Name */
.profile-name {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-color, #111);
}

/* Status badge */
.profile-status {
  display: inline-block;
  padding: 4px 14px;
  font-size: 0.8rem;
  border-radius: 999px;
  background: var(--primary-color, #6366f1);
  color: #fff;
  margin-bottom: 10px;
}

/* Meta grid */
.profile-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 1.2rem;
  font-size: 0.85rem;
}

.profile-meta strong {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted, #777);
  margin-bottom: 2px;
}

.profile-meta span {
  font-weight: 600;
  color: var(--text-color, #111);
}

/* Bio */
.profile-bio {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted, #777);
  line-height: 1.4;
}

/* ===============================
   DARK THEME SUPPORT
   =============================== */

[data-theme="dark"] .profile-popup-overlay {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .profile-popup-card {
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

[data-theme="dark"] .profile-popup-close:hover {
  background: rgba(255,255,255,0.08);
}
/* channel.css */

/* 1. REPLACE your existing @media (max-width: 768px) block with this: */
@media (max-width: 768px) {
    .channel-page {
        padding: 10px;
    }
    
    .profile-info {
        flex-direction: column;
        align-items: center; /* Center for mobile */
        text-align: center;
        padding: 0 10px;
    }

    .profile-avatar {
        width: 90px;
        height: 90px;
    }
    
    .channel-actions {
        width: auto;         /* Changed from 100% */
        justify-content: center;
        margin-top: 15px;
    }
    
    /* This stops the Subscribe button from taking full screen width */
    .subscribe-btn {
        width: auto !important; 
        min-width: 150px;
        align-self: center;
    }
}

/* 2. UPDATE the Floating Button to ensure visibility and position */
#create-post-btn {
    position: fixed !important; 
    bottom: 90px; /* Elevated to stay above the mobile bottom nav */
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999 !important; /* Forces it to the top layer */
    
    display: flex; 
    justify-content: center;
    align-items: center;
    
    background-color: var(--primary-color);
    color: #fff !important;
    width: 200px; /* Fixed width so it doesn't stretch */
    padding: 12px 24px;
    border-radius: 50px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

/* FIXED MOBILE SPACING AND BUTTON WIDTH */
@media (max-width: 768px) {
    .channel-page {
        padding: 10px;
    }
    
    .profile-info {
        flex-direction: column;
        align-items: center; 
        text-align: center;
        padding: 0 10px;
        gap: 10px !important; /* Reduces gap between avatar and text */
    }

    .channel-text-details {
        margin-bottom: 5px; /* Reduces gap between text and action buttons */
    }
    
    .channel-actions {
        width: 100%;
        justify-content: center;
        margin-top: 5px !important; /* Reduces space above Edit/Delete buttons */
        margin-bottom: 10px !important; /* Reduces space below Edit/Delete buttons */
        display: flex;
        flex-direction: column; /* Stacks buttons to prevent overlapping */
        gap: 8px !important; /* Small, clean gap between Edit and Delete */
    }

    /* Target Edit and Delete buttons to ensure they don't look "blended" */
    .channel-actions .btn, 
    .channel-actions a,
    .channel-actions button {
        width: 90% !important; /* Slightly less than full width for better look */
        max-width: 300px;
        margin: 0 auto;
        padding: 10px;
    }
    
    /* FIX: The Subscribe button gap */
    .subscribe-btn {
        width: auto !important; 
        min-width: 160px;
        margin-top: 5px !important; /* Brings it closer to the buttons above */
        padding: 12px 24px;
        align-self: center;
    }

    /* Floating button position for mobile */
    #create-post-btn {
        bottom: 80px !important; 
    }
}
/* channel.css */

@media (max-width: 768px) {
    /* Tighten the header container */
    .profile-info {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 12px !important; /* Reduced gap between avatar and text */
        padding: 10px 0 !important;
    }

    /* Reduce vertical space in the details block */
    .channel-text-details {
        margin-bottom: 5px !important;
    }

    /* FIX: Button Gaps and "Blended" look */
    .channel-actions {
        width: 100% !important;
        justify-content: center !important;
        margin-top: 10px !important; /* Move buttons closer to text */
        margin-bottom: 0 !important; /* Remove bottom margin to close gap with subscribe */
        display: flex !important;
        flex-direction: column !important; /* Stack Edit/Delete to prevent overlapping */
        gap: 8px !important; /* Clean, small gap between Edit and Delete */
    }

    /* Ensure buttons don't stretch fully but look unified */
    .channel-actions button,
    .channel-actions a,
    .subscribe-btn {
        width: 85% !important; /* Balanced width */
        max-width: 280px;
        margin: 0 auto !important;
        padding: 10px 18px !important;
    }

    /* Tighten Subscribe button gap */
    .subscribe-btn {
        margin-top: 8px !important; /* Brings it right below the Edit/Delete stack */
        display: block !important;
    }

    /* FIX: Gap between horizontal line and "No posts yet" */
    .posts-section {
        margin-top: 10px !important; /* Pull section up closer to line */
        padding-top: 0 !important;
    }

    .empty-text, #no-posts {
        margin-top: 30px !important; /* Pushes the text away from the line so it doesn't touch */
        font-size: 0.95rem;
    }

    /* Adjust floating button for mobile menu */
    #create-post-btn {
        bottom: 80px !important;
        width: auto !important;
    }
}





/* ======================================= */
/* 7. Responsive Styles                    */
/* ======================================= */

/* Desktop Actions (Side by Side) */
.channel-actions {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
}

.channel-actions .btn {
    padding: 10px 20px;
    height: 42px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .channel-header {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }

    /* Grid layout is much more stable for mobile buttons */
    .channel-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr; /* Two equal columns */
        gap: 10px;
        width: 100%;
        max-width: 350px;
        margin: 15px auto !important;
    }

    /* Make Copy Link span both columns */
    #copy-link-btn {
        grid-column: span 2;
        width: 100%;
    }

    /* Reset widths for small buttons so they fit the grid */
    .channel-actions .btn {
        width: 100% !important;
        margin: 0 !important;
    }

    /* Make Subscribe button its own row below the grid */
    .subscribe-btn {
        width: 100% !important;
        max-width: 350px;
        margin: 10px auto 0 !important;
        display: flex !important;
        justify-content: center;
    }

    .posts-section { margin-top: 10px; padding-top: 0; }
    #create-post-btn { bottom: 80px; }
}

@media (max-width: 768px) {
    /* 1. Header Centering */
    .channel-header {
        flex-direction: column;
        text-align: center;
        align-items: center;
        gap: 15px;
    }

    /* 2. Unified Container for ALL buttons */
    .channel-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr; /* Two columns */
        gap: 12px;
        width: 100%;
        max-width: 340px; /* Keeps buttons from getting too wide on tablets */
        margin: 15px auto !important;
    }

    /* 3. Make the "Big" buttons span both columns (Centered & Full Width) */
    #copy-link-btn, 
    .subscribe-btn {
        grid-column: span 2;
        width: 100% !important;
        margin: 0 !important;
        display: flex !important;
        justify-content: center;
        align-items: center;
    }

    /* 4. Small Buttons (Edit/Delete) stay side-by-side */
    .channel-actions .btn:not(#copy-link-btn):not(.subscribe-btn) {
        width: 100% !important;
        grid-column: span 1;
        font-size: 0.9rem;
    }

    /* 5. Fix spacing for the posts section */
    .posts-section {
        margin-top: 20px;
    }
}




/* Target the popup specifically when in light mode */
html[data-theme="light"] .profile-popup-card:not([data-has-custom-bg="true"]),
body.light-theme:not(.dark-theme) .profile-popup-card:not([data-has-custom-bg="true"]) {
    background-color: var(--channel-card-bg, #FFFFFF) !important;
    color: var(--channel-text, #1F2937) !important;
    border: 1px solid var(--channel-border, #E5E7EB);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Fix text clarity in Light Mode */
html[data-theme="light"] .profile-popup-card:not([data-has-custom-bg="true"]) .profile-name,
body.light-theme:not(.dark-theme) .profile-popup-card:not([data-has-custom-bg="true"]) .profile-name {
    color: var(--channel-text, #1F2937) !important;
}

html[data-theme="light"] .profile-popup-card .profile-meta,
html[data-theme="light"] .profile-popup-card .profile-status,
html[data-theme="light"] .profile-popup-card .muted,
body.light-theme:not(.dark-theme) .profile-popup-card .profile-meta,
body.light-theme:not(.dark-theme) .profile-popup-card .profile-status,
body.light-theme:not(.dark-theme) .profile-popup-card .muted {
    color: var(--channel-secondary-text, #6B7280) !important;
}

/* Ensure the close button (X) is visible */
html[data-theme="light"] .profile-popup-close,
body.light-theme:not(.dark-theme) .profile-popup-close {
    color: var(--channel-text, #1F2937) !important;
}

/* Secondary Action Buttons (e.g., View Profile) */
html[data-theme="light"] .profile-actions .btn-secondary,
body.light-theme:not(.dark-theme) .profile-actions .btn-secondary {
    background-color: var(--channel-bg, #F9FAFB);
    color: var(--channel-text, #1F2937);
    border: 1px solid var(--channel-border, #E5E7EB);
}

/* This targets the image inside your posts */
.tg-image {
    width: 100%;            /* Keeps the image filling the width of the post */
    height: auto !important; /* Allows the height to grow naturally based on the image */
    max-height: none !important; /* Removes any fixed height limit causing the crop */
    object-fit: contain;    /* Ensures the full image is shown */
    display: block;         /* Removes bottom spacing/gaps */
    border-radius: 8px;     /* Optional: matches your existing UI style */
    margin: 10px 0;         /* Adds some breathing room around the image */
}


[data-theme="light"] .message-bar-container {
    background: var(--surface-color, #ffffff); /* Dark surface */
    border-top-color: var(--border-color, #374151);
}

/* In styles/channel.css */

@media (max-width: 600px) {
    /* Force the container to center its children */
    #channel-posts {
        display: flex !important;
        flex-direction: column;
        align-items: center !important; /* CRITICAL: Centers items horizontally */
        width: 100%;
    }

    /* Ensure the post card itself has a reasonable width */
    .tg-post {
        width: 100% !important;
        max-width: 100% !important; /* Ensures it uses available space but stays centered */
        box-sizing: border-box; /* Prevents padding from pushing it off-center */
    }
}
/* In styles/channel.css - Update the mobile media query */

@media (max-width: 768px) {
    /* ... existing header styles ... */

    /* 1. FORCE GRID LAYOUT */
    .channel-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important; /* Exactly two equal columns */
        gap: 10px !important;
        width: 100% !important;
        max-width: 400px; /* Prevents them from getting too wide */
        margin: 15px auto !important;
    }

    /* 2. RESET BUTTON SIZING TO FIT 1 COLUMN EACH */
    .channel-actions .btn,
    .channel-actions button,
    .channel-actions a,
    #copy-link-btn,
    .subscribe-btn {
        grid-column: span 1 !important; /* Force every button to take 1 slot */
        width: 100% !important;
        margin: 0 !important;
        display: flex !important;
        justify-content: center;
        align-items: center;
        padding: 10px 5px !important; /* Reduce padding slightly to fit text */
        font-size: 0.85rem !important; /* Adjust font if text is too long */
    }

    /* 3. ENSURE ORDERING (Optional, but good for consistency) */
    /* If you want Subscribe first, give it order: 1, etc. */
}

@media (max-width: 992px) {
    .container {
        padding-top: 1px;
        flex-direction: column;
        min-height: auto;
        overflow: visible;
    }
}
/* Update this section in your channel.css */
.tg-text {
    font-size: 14px;
    line-height: 1.45;
    color: var(--channel-secondary-text);
    margin-top: 10px;
    white-space: pre-line;
    
    /* --- ADD THESE THREE LINES --- */
    inline-size: 100%;         /* Ensures it respects container width */
    overflow-wrap: break-word; /* Modern way to break long words */
    word-break: break-word;    /* Compatibility for older browsers */
}

/* Add this to ensure links specifically don't overflow */
.tg-text a {
    word-break: break-all;     /* Forces the URL to wrap anywhere */
    display: inline-block;     /* Helps with proper wrapping alignment */
    max-width: 100%;           /* Prevents the link from ever being wider than the card */
}

/* Banned Post Card Styling */
.banned-post-card {
    /* Automatic Theme Switching using main.css variables */
    background-color: var(--banned-bg, #FEF2F2) !important; 
    border: 1px solid var(--banned-border, #EF4444) !important;
    opacity: 1 !important;
    cursor: default;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 14px; /* Maintain row spacing */
}

.banned-content-wrapper {
    display: flex;
    align-items: flex-start; /* Align to top in case text is long */
    gap: 15px;
}

.banned-icon-area {
    font-size: 24px;
    color: var(--banned-icon, #DC2626);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    margin-top: 2px; /* Visual alignment with title */
}

.banned-text-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.banned-text-area strong {
    color: var(--banned-icon, #DC2626);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.banned-text-area p {
    margin: 0;
    color: var(--banned-text, #991B1B);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Specific Dark Mode Overrides (in case variables are missing) */
[data-theme="dark"] .banned-post-card {
    background-color: rgba(69, 10, 10, 0.6) !important;
    border-color: #7f1d1d !important;
}
[data-theme="dark"] .banned-text-area p {
    color: #fca5a5 !important;
}


/* --- ADMIN MODAL STYLES --- */
.large-modal {
    max-width: 600px;
    width: 95%;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 80vh; /* Fixed height for easier scrolling */
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
}

.modal-header h3 { margin: 0; }
.close-modal-btn { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; }

/* Tabs */
.admin-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-body);
}
.tab-btn {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 600;
    transition: 0.2s;
    border-bottom: 3px solid transparent;
}
.tab-btn.active { color: var(--primary-color); border-bottom-color: var(--primary-color); background: var(--bg-card); }
.tab-btn.danger.active { color: #ef4444; border-bottom-color: #ef4444; }

/* Content Areas */
.tab-content { display: none; padding: 20px; flex: 1; overflow-y: auto; text-align: left; }
.tab-content.active { display: block; }

/* Lists & Items */
.add-admin-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.add-admin-bar input, .full-width-input {
    flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border-color);
    background: var(--bg-body); color: var(--text-main);
}

.admin-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px; background: var(--bg-body); margin-bottom: 8px; border-radius: 8px;
    border: 1px solid var(--border-color);
}
.admin-info strong { display: block; font-size: 0.95rem; }
.admin-info span { font-size: 0.8rem; color: var(--text-muted); }
.admin-actions { display: flex; gap: 8px; }
.admin-actions .icon-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 5px; }
.admin-actions .icon-btn:hover { color: var(--primary-color); }
.admin-actions .icon-btn.delete:hover { color: #ef4444; }

/* Permissions Grid */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; text-align: left; margin: 20px 0; }
.perm-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.perm-toggle input { transform: scale(1.2); }

.warning-box {
    background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444; padding: 15px; border-radius: 8px; display: flex; align-items: center; gap: 15px;
}
.full-width-btn { width: 100%; margin-top: 10px; }



/* --- SEARCH DROPDOWN STYLES --- */
.search-wrapper {
    position: relative;
    flex: 1;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none; /* Hidden by default */
}

.user-dropdown.active {
    display: block;
}

.user-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
}

.user-dropdown-item:last-child {
    border-bottom: none;
}

.user-dropdown-item:hover {
    background: var(--hover-color, rgba(0,0,0,0.05));
}

.user-dropdown-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.user-dropdown-info {
    display: flex;
    flex-direction: column;
}

.user-dropdown-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-dropdown-username {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- SMART SEARCH DROPDOWN --- */
.search-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--channel-card-bg);
    border: 1px solid var(--channel-border);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 10000;
    max-height: 220px;
    overflow-y: auto;
    display: none;
}

.user-dropdown.active {
    display: block;
}

.user-dropdown-item {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--channel-border);
    transition: background 0.1s;
}

.user-dropdown-item:hover {
    background: rgba(0,0,0,0.05);
}

[data-theme="dark"] .user-dropdown-item:hover {
    background: rgba(255,255,255,0.05);
}

.user-dropdown-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-dropdown-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.user-dropdown-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--channel-text);
}

.user-dropdown-username {
    font-size: 0.75rem;
    color: var(--channel-secondary-text);
}
/* --- MESSAGE BAR STYLES (Fixed) --- */
.message-bar-container {
    position: fixed; 
    bottom: 70px; /* Elevated for mobile nav */
    left: 0; 
    right: 0;
    padding: 10px 15px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    
    /* Flex Setup for Centering */
    display: flex; 
    flex-direction: column; /* Stack preview on top of input */
    align-items: center;    /* CRITICAL: Centers the input box horizontally */
    gap: 10px;
}

.message-bar-input-wrapper {
    display: flex; 
    align-items: flex-end;
    background: var(--bg-body);
    border-radius: 20px;
    padding: 8px 15px;
    width: 100%; 
    max-width: 800px; /* Controls the width of the bar */
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.rich-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    max-height: 120px;
    overflow-y: auto;
    padding: 8px 5px;
    min-height: 24px;
    white-space: pre-wrap;
    word-break: break-word;
}

.rich-input:empty:before {
    content: attr(placeholder);
    color: var(--text-muted);
    display: block; 
}

.message-bar-actions {
    display: flex; 
    gap: 12px; 
    margin-left: 10px; 
    align-items: center; 
    padding-bottom: 6px;
}

.message-bar-actions button {
    background: none; 
    border: none; 
    color: var(--text-muted);
    cursor: pointer; 
    font-size: 1.2rem; 
    transition: color 0.2s, transform 0.2s;
    padding: 5px;
}

.message-bar-actions button:hover { 
    color: var(--primary-color); 
    transform: scale(1.1);
}

.message-bar-actions .send-btn { 
    color: var(--primary-color); 
}

/* Image Preview Styles */
.image-preview-container {
    display: none; /* Hidden by default */
    gap: 10px;
    overflow-x: auto;
    padding: 10px;
    background: var(--bg-body);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 800px;
    margin-bottom: 5px;
}

.preview-thumb-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.preview-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.remove-thumb-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    border: 2px solid var(--bg-card); /* White border for contrast */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Desktop Adjustment */
@media (min-width: 769px) {
    .message-bar-container { 
        left: 260px; /* Offset for sidebar */
        bottom: 0; 
    }
}

/* ======================================= */
/* MULTI-IMAGE GRID LAYOUT (Telegram Style) */
/* ======================================= */

.tg-image-grid {
    display: grid;
    gap: 2px;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 10px;
}

.tg-image-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    transition: opacity 0.2s;
}

.tg-image-grid img:hover {
    opacity: 0.9;
}

/* 1 Image: Full width, natural height (constrained) */
.tg-image-grid[data-count="1"] {
    grid-template-columns: 1fr;
}
.tg-image-grid[data-count="1"] img {
    max-height: 450px;
    height: auto;
}

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

/* 3 Images: One big on top, two small below */
.tg-image-grid[data-count="3"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 2fr 1fr;
    aspect-ratio: 3 / 4;
}
.tg-image-grid[data-count="3"] img:first-child {
    grid-column: span 2;
}

/* 4 Images: 2x2 Grid */
.tg-image-grid[data-count="4"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    aspect-ratio: 1 / 1;
}

/* 5+ Images: 3 Columns */
.tg-image-grid[data-count="5"],
.tg-image-grid[data-count="6"],
.tg-image-grid[data-count="7"],
.tg-image-grid[data-count="8"],
.tg-image-grid[data-count="9"] {
    grid-template-columns: repeat(3, 1fr);
    aspect-ratio: 1 / 1; 
}

/* Owner Message Bar Preview Area */
.preview-thumb-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}
.preview-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.remove-thumb-btn {
    position: absolute;
    top: -5px; right: -5px;
    width: 20px; height: 20px;
    background: #ef4444; color: white;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 12px;
}

/* --- 3-Dot Menu & Dropdown --- */
.channel-menu-container {
    position: relative;
    margin-left: auto; /* Pushes to right */
}

.menu-trigger {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-main);
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.menu-trigger:hover {
    background: rgba(0,0,0,0.05);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 150px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    z-index: 100;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
    animation: fadeIn 0.1s ease-out;
}

.dropdown-menu button {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--danger, #e74c3c); /* Red for report */
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-menu button:hover {
    background: rgba(0,0,0,0.05);
}

/* --- Report Modal Styles --- */
.report-box {
    text-align: left !important;
    max-width: 450px !important;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.report-header h3 { margin: 0; }

.report-header .close-modal {
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

.report-subtitle {
    font-weight: 600;
    margin-bottom: 15px;
}

.report-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.1s;
}

.radio-item:hover {
    background: rgba(0,0,0,0.03);
}

.report-comment-area textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Dark Mode Overrides */
[data-theme="dark"] .menu-trigger:hover,
[data-theme="dark"] .dropdown-menu button:hover,
[data-theme="dark"] .radio-item:hover {
    background: rgba(255,255,255,0.05);
}

/* Fix Menu Positioning */
.profile-info {
    position: relative; /* Acts as anchor */
    display: flex;
    align-items: center;
    justify-content: space-between; /* Pushes menu to far right */
}

.channel-menu-container {
    position: relative; /* Important for dropdown anchoring */
    margin-left: auto; /* Ensures it pushes to the right */
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%; 
    right: 0; /* Aligns right edge of dropdown with right edge of dots */
    width: 160px; /* Fixed width prevents squishing */
    background: var(--channel-card-bg);
    border: 1px solid var(--channel-border);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-top: 8px; /* Slight gap */
    z-index: 9999;
}
/* ============================================================ */
/* FINAL TOAST FIX (Paste at the VERY BOTTOM of channel.css)    */
/* ============================================================ */

#toast-container {
    visibility: hidden; /* Hidden by default */
    min-width: 280px;
    background-color: #333; /* Dark background */
    color: #fff;
    text-align: center;
    border-radius: 50px;
    padding: 14px 24px;
    position: fixed;
    z-index: 2147483647 !important; /* MAX Z-Index: Top of everything */
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 15px;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, bottom 0.3s ease;
    white-space: nowrap;
}

/* When the .show class is added via JS */
#toast-container.show {
    visibility: visible !important;
    opacity: 1 !important;
    bottom: 80px !important; /* Slide up */
    pointer-events: auto;
}

/* Error Variation */
#toast-container.error {
    background-color: #ef4444 !important; /* Red */
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4);
}
#toast-container.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px; /* Slight move up animation */
}


#toast-container.show {
    visibility: visible !important;
    opacity: 1;
    bottom: 50px;
    pointer-events: auto;
}


/* =======================================================
   RESPONSIVE SIZE & REMOVE AUTHOR
   ======================================================= */

/* 1. Remove the "By User" author line */
.tg-post div[onclick*="openUserProfile"] {
    display: none !important;
}

/* 2. Responsive width: Perfect on laptop, stays clean on large screens */
#posts-container {
    width: 100%;
    /* clamp(minimum, preferred, maximum) 
       This keeps it 95% wide on mobile, but stops growing after 650px 
    */
    max-width: clamp(300px, 95%, 650px) !important;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 3. Ensure the parent doesn't force a weird grid stretch */
#channel-posts {
    display: block !important;
    width: 100%;
    padding: 0 10px;
}

/* =======================================================
   FIXES: Layout, Remove Author, and Toasts
   ======================================================= */

/* 1. Responsive Feed Size (Perfect on Laptop & Huge screens) */
#posts-container {
    width: 100% !important;
    max-width: clamp(300px, 95%, 650px) !important; /* Prevents "Presentation Mode" stretch */
    margin: 0 auto !important;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#channel-posts {
    display: block !important; /* Overrides grid layouts that cause stretching */
}

/* 2. Remove "By User" Author Line */
.tg-post div[onclick*="openUserProfile"], 
.tg-post .post-author-info {
    display: none !important;
}

/* --- CRITICAL TOAST FIX --- */
#toast-container {
    visibility: hidden;
    min-width: 280px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 50px;
    padding: 14px 24px;
    position: fixed;
    /* 2147483647 is the maximum Z-Index integer allowed by browsers */
    z-index: 2147483647 !important; 
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 15px;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, bottom 0.3s ease;
}

#toast-container.show {
    visibility: visible !important;
    opacity: 1 !important;
    bottom: 80px !important; /* Moves up slightly */
    pointer-events: auto;
}

#toast-container.error {
    background-color: #ef4444 !important;
}

/* styles/channel.css */

/* ... (keep existing styles) ... */

/* ======================================= */
/* LEFT ALIGN FIX FOR CHANNELS             */
/* ======================================= */

#posts-container {
    width: 100% !important;
    /* Removed margin: 0 auto; to stop centering */
    margin: 0 !important; 
    margin-left: 0 !important; /* Force left alignment */
    
    /* Keep max-width if you want them to not stretch infinitely, 
       or remove it if you want full width. Keeping it for readability 
       but aligned left. */
    max-width: 650px !important; 
    
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Ensure the wrapper doesn't force centering either */
#channel-posts {
    display: block !important;
    width: 100%;
    padding: 0 10px;
    text-align: left !important; /* Ensure content flows left */
}

/* Mobile check: ensure it stays left there too */
@media (max-width: 600px) {
    #channel-posts {
        align-items: flex-start !important; /* Align flex items to start (left) */
    }
}

/* channel.css - Add at bottom */

.perm-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}
.perm-toggle:last-child { border-bottom: none; }

.perm-info { display: flex; flex-direction: column; text-align: left; }
.perm-info strong { font-size: 0.95rem; color: var(--text-main); }
.perm-info span { font-size: 0.8rem; color: var(--text-muted); }

/* Ensure scrollable permissions area */
.perm-scroll-area {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

/* User item hover effect for Right Click context */
.user-search-result, .admin-item {
    transition: background-color 0.2s;
}
.user-search-result:hover { background-color: var(--hover-color); }

/* Ban Reason Display in Banned List */
.ban-reason-text {
    font-size: 0.75rem; 
    color: #ef4444; 
    display: block; 
    margin-top: 2px;
}
/* Hide mobile bottom navigation on channel detail view */
body:has(.channel-slug-container) .mobile-bottom-nav,
.channel-slug-container ~ .mobile-bottom-nav,
body.channel-view-active .mobile-bottom-nav {
    display: none !important;
}



/* Desktop Sticky Channel Header */
@media (min-width: 993px) {
  .channel-header-card {
    position: sticky !important;
    top: 16px !important;
    z-index: 100 !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
  }
}


/* ========================================================================= */
/* --- TELEGRAM-STYLE LOCKED CHANNEL HEADER & FLOATING SUBSCRIBE BAR --- */
/* ========================================================================= */

/* Lock Channel Top Bar fixed at top on mobile */
.channel-mobile-bar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  height: 58px !important;
  min-height: 58px !important;
  max-height: 58px !important;
  z-index: 10000 !important;
  box-sizing: border-box !important;
  padding: 0 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

/* Ensure mobile header content respects spacing and doesn't get squished */
.channel-mobile-bar .channel-header-info {
  min-width: 0 !important;
  flex: 1 1 auto !important;
}

.channel-mobile-bar .channel-header-title {
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* Telegram-style Top Right Compact Subscribe Button */
.channel-header-sub-btn {
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  padding: 6px 12px !important;
  border-radius: 20px !important;
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

/* Hide desktop sticky card on mobile screens so ONLY the locked top bar exists */
@media (max-width: 992px) {
  .channel-header-card {
    display: none !important;
  }
  .channel-desktop-back {
    display: none !important;
  }
  .channel-stream-container {
    padding-top: 66px !important;
    margin-top: 0 !important;
    padding-bottom: 90px !important;
  }
}

/* Telegram-style Floating Subscriber/Guest Bottom Pill Bar */
.channel-subscriber-bottom-bar {
  position: fixed !important;
  bottom: max(14px, env(safe-area-inset-bottom)) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: min(calc(100% - 24px), 480px) !important;
  max-width: 480px !important;
  padding: 8px 14px !important;
  border-radius: 9999px !important;
  border-width: 1px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  box-sizing: border-box !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25) !important;
  z-index: 9999 !important;
}

.channel-subscriber-bottom-bar .bottom-sub-label {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font-size: 0.88rem !important;
  font-weight: 600 !important;
}

.channel-subscriber-bottom-bar .bottom-sub-btn {
  flex-shrink: 0 !important;
  border-radius: 9999px !important;
  padding: 8px 18px !important;
  font-size: 0.86rem !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

/* Ensure mobile bottom nav is strictly hidden inside channels */
body:has(.channel-slug-container) .mobile-bottom-nav,
body.channel-view-active .mobile-bottom-nav {
  display: none !important;
}

/* Pinned flush bottom bar for channel broadcast message bar on mobile */
@media (max-width: 768px) {
  .channel-broadcast-bottom-bar {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    transform: none !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-top: 1.5px solid var(--primary-color, #10b981) !important;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 8px)) 12px !important;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25) !important;
  }
}
