/* ===================================================
   Channels Page Styles (channels.css)
   =================================================== */

/* --- General Discussion Header & Layout --- */

.discussion-header {
    /* Use padding to separate the header from the main content */
    padding-bottom: var(--space-8);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--space-8);
}

.discussion-header h1 {
    font-size: var(--text-4xl);
    font-weight: 700;
    color: var(--text-dark); /* Inherits from main.css's body/data-theme variables */
    margin-bottom: var(--space-6);
}

/* --- Channel Creation Form --- */

#channel-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-6);
    background-color: var(--bg-white); /* Light/Card background */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    
    /* Ensure form is not too wide on large screens */
    max-width: 600px;
}

#channel-form input[type="text"],
#channel-form textarea,
#channel-form input[type="file"],
#channel-form input:not([type="file"]) { /* Target all inputs except file */
    width: 100%;
    padding: var(--space-3);
    border-radius: var(--radius);
    border: 1px solid var(--border-medium);
    font-size: var(--text-base);
    background-color: var(--bg-white);
    color: var(--text-dark);
    transition: border-color 0.2s;
}

#channel-form input:focus,
#channel-form textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-light);
}

#channel-form textarea {
    resize: vertical;
    min-height: 80px;
}

#channel-form button {
    /* Apply primary button style */
    align-self: flex-start; /* Button only takes necessary width */
    @extend .primary-btn; /* Placeholder for extension, use the actual primary-btn CSS properties */
    background: var(--bg-gradient);
    color: var(--text-light);
    box-shadow: 0 4px 10px rgba(75, 108, 183, 0.3);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-xl);
    border: none;
    font-weight: 500;
}

/* Custom styling for file input (to make it look less generic) */
#channel-form input[type="file"] {
    border: 1px dashed var(--border-medium);
    padding: var(--space-3);
    cursor: pointer;
    background-color: var(--bg-light);
    color: var(--text-medium);
}


/* --- Channel Search Input --- */

#search-channel.input {
    width: 100%;
    max-width: 600px;
    padding: var(--space-3);
    border-radius: var(--radius);
    border: 1px solid var(--border-medium);
    font-size: var(--text-base);
    background-color: var(--bg-white);
    color: var(--text-dark);
    transition: border-color 0.2s;
    
    /* Match form input styling */
    margin-bottom: var(--space-8);
}

#search-channel.input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* --- Discussion List Container --- */

.discussion-list {
    margin-top: 50px;
    display: grid;
    /* Responsive grid: 1 column on small screens, 2 on medium, 3 on large */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-6);
    /* For the 'Loading channels...' text */
    text-align: center;
    color: var(--text-medium);
}

/* --- Channel Card Style --- */
/* --- Channel Card Style --- */

.channel-card {
    display: flex;
    align-items: center;
    padding: var(--space-4);
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    /* 👇 CHANGE 1: Use a super subtle shadow instead of a border */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.05); 
    /* 👇 CHANGE 2: Extremely light, almost transparent border */
    
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease, box-shadow 0.3s ease; 
    cursor: pointer;


}

.channel-card:hover {
    transform: translateY(-1px); /* Reduce hover lift */
    /* 👇 CHANGE 3: Lighter hover shadow for a gentle glow/lift */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07), 0 5px 15px rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.05); /* Keep border subtle on hover */
}

.channel-avatar {
    width: 56px; /* Slightly smaller for a cleaner look */
    height: 56px;
    min-width: 56px;
    border-radius: 18px; /* Square with rounded corners (iOS icon style) */
    object-fit: cover;
    margin-right: var(--space-4);
    border: 1px solid var(--border-light); /* Softer border */
    flex-shrink: 0;
    /* NEW: Subtle inset shadow for depth */
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.channel-info {
    flex-grow: 1;
    overflow: hidden;
}

.channel-name {
    font-size: var(--text-lg);
    font-weight: 550; /* Slightly lighter weight for the name */
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--space-1);
    line-height: 1.2; /* Tighten line height */
}
.channel-description {
    font-size: var(--text-sm);
    color: var(--text-medium);
    /* Limit to two lines for clean look */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-meta {
    margin-left: var(--space-4);
    text-align: right;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.member-count {
    font-size: var(--text-xs); /* Smaller font for badge effect */
    font-weight: 700;
    color: var(--primary-color);
    background-color: var(--primary-lightest); /* Light background for badge */
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-lg); /* Rounded badge */
    display: flex;
    align-items: center;
    gap: var(--space-1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Optional: Add a visual cue to the icon in the member count */
.member-count i {
    color: var(--primary-dark);
}

.member-count i {
    color: var(--accent-color);
}

/* --- Dark Theme Overrides for Channel Elements --- */

[data-theme="dark"] .discussion-header {
    border-bottom-color: var(--color-border);
}

[data-theme="dark"] .discussion-header h1 {
    color: var(--color-text-primary) !important;
}

[data-theme="dark"] #channel-form {
    background-color: var(--color-sidebar-bg);
    border-color: var(--color-border);
    box-shadow: var(--color-card-shadow);
}

/* Dark theme form input fixes */
[data-theme="dark"] #channel-form input:not([type="file"]),
[data-theme="dark"] #channel-form textarea,
[data-theme="dark"] #search-channel.input {
    background-color: var(--color-sidebar-bg) !important;
    color: var(--color-text-primary) !important;
    border-color: var(--color-border) !important;
}

[data-theme="dark"] #channel-form input[type="file"] {
    background-color: #273040; /* Slightly lighter than sidebar-bg for contrast */
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}

[data-theme="dark"] .channel-card {
    background-color: var(--color-sidebar-bg);
    border-color: var(--color-border);
    box-shadow: var(--color-card-shadow);
}

[data-theme="dark"] .channel-card:hover {
    border-color: var(--primary-color); /* Use bright green border on hover */
    box-shadow: var(--shadow-glow);
}

[data-theme="dark"] .channel-name {
    color: var(--color-text-primary) !important;
}

[data-theme="dark"] .channel-description {
    color: var(--color-text-secondary) !important;
}

[data-theme="dark"] .member-count {
    color: var(--primary-color) !important; /* Use vibrant green */
}

/* --- Mobile Responsiveness --- */

@media (max-width: 600px) {
    .discussion-list {
        /* Force single column layout on very small screens */
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .channel-card {
        padding: var(--space-3);
    }
    
    .channel-avatar {
        width: 48px;
        height: 48px;
        min-width: 48px;
    }
    
    .channel-name {
        font-size: var(--text-base);
    }
    
    .channel-description {
        font-size: var(--text-xs);
        -webkit-line-clamp: 1; /* Limit description to one line on tiny screens */
    }
    
    .discussion-header h1 {
        font-size: var(--text-3xl);
    }
    
    #channel-form {
        padding: var(--space-4);
        max-width: 100%;
    }
    
    /* Simplify button on mobile */
    #channel-form button {
        font-size: var(--text-sm);
        padding: var(--space-2) var(--space-4);
    }
}

/* --- General Discussion Header & Layout --- */

.discussion-header {
    /* Use padding to separate the header from the main content */
    padding-bottom: var(--space-8);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--space-8);
    /* NEW: Use flex to align H1 and Create Channel Link */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.discussion-header h1 {
    /* 👇 CHANGE 4: Reduce font size drastically */
    font-size: var(--text-2xl); 
    font-weight: 600; /* Slightly less bold */
    color: var(--text-dark);
    margin: 0; 
}

/* NEW: Style the 'Create Channel' link as a button */
#channel-form a {
    /* Inherit/mimic the primary button style */
    background: var(--bg-gradient);
    color: var(--text-light);
    box-shadow: 0 4px 10px rgba(75, 108, 183, 0.3);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-xl);
    font-weight: 500;
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-size: var(--text-sm);
    letter-spacing: 0.5px;
}

#channel-form a:hover {
    box-shadow: 0 6px 15px rgba(75, 108, 183, 0.4);
    transform: translateY(-1px);
}


/* --- Discussion Card - Glassmorphism & Centered Column Layout --- */

.discussion-card {
    /* 1. Glassmorphism Effect */
    background-color: rgba(255, 255, 255, 0.5); 
    backdrop-filter: blur(8px); 
    -webkit-backdrop-filter: blur(8px); 

    /* 2. Layout Fix: Stack vertically and align items to the center */
    display: flex;
    flex-direction: column; 
    /* ⭐ KEY CHANGE 1: Center all child items horizontally (content div and button) */
    align-items: center; 
    
    /* 3. Appearance (iOS Vibe) */
    padding: var(--space-5);
    border-radius: 20px;
    box-shadow: 
        0 1px 1px rgba(0, 0, 0, 0.04), 
        0 8px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.4); 
    
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94); 
    text-decoration: none; 
    color: inherit;
}

.discussion-card:hover {
    transform: translateY(-2px); 
    box-shadow: 
        0 3px 8px rgba(0, 0, 0, 0.08), 
        0 10px 25px rgba(0, 0, 0, 0.1); 
}

/* 4. Target the Inner Content Div */
/* Ensure the content div still spans 100% width and center its text */
.discussion-card > div:first-child {
    width: 100%;
    margin-bottom: var(--space-4); 
    padding: 0; 
    /* ⭐ KEY CHANGE 2: Center the text inside the content div */
    text-align: center;
}

/* 5. Target the Button for Alignment */
.discussion-card .btn.danger-btn {
    /* ⭐ KEY CHANGE 3: Remove the auto margin that was pushing it right */
    margin-left: initial; 
    margin-right: initial;
    
    /* Styling the button for a cleaner look */
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-lg);
    font-weight: 500;
    font-size: var(--text-sm);
    border: none;
    background-color: var(--bg-light); 
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --- Content Styling --- */

.discussion-card h3 {
    margin: 0;
    font-size: var(--text-lg); 
    font-weight: 600; 
    color: var(--text-dark);
}

.discussion-card p {
    margin: 4px 0 0;
    font-size: var(--text-sm);
    color: var(--text-medium);
    opacity: 0.8;
}

/* --- Dark Theme Overrides --- */

[data-theme="dark"] .discussion-card {
    background-color: rgba(39, 48, 64, 0.6); 
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .discussion-card .btn.danger-btn {
    background-color: var(--color-bg-dark-secondary);
    color: var(--color-text-primary);
}

.channel-card {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--channel-card-bg, #fff);
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    margin-bottom: 14px;
    gap: 14px;
    cursor: pointer;
    transition: 0.2s ease;
}

.channel-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.channel-card-avatar {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.channel-card-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.channel-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.channel-card-desc {
    font-size: 0.85rem;
    margin-top: 4px;
    color: var(--channel-secondary-text);
}

.channel-card-delete {
    padding: 6px 12px;
    border-radius: 8px;
}

/* ===================================================
   Channels Page Styles (channels.css)
   =================================================== */

/* --- General Discussion Header & Layout --- */

.discussion-header {
    /* Use padding to separate the header from the main content */
    padding-bottom: var(--space-8);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--space-8);
    /* NEW: Use flex to align H1 and Create Channel Link */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.discussion-header h1 {
    /* ЁЯСЗ CHANGE 4: Reduce font size drastically */
    font-size: var(--text-2xl); 
    font-weight: 600; /* Slightly less bold */
    color: var(--text-dark);
    margin: 0; 
}

/* --- Channel Creation Form --- */

#channel-form {
    /* REMOVED/OVERRIDDEN CARD STYLING FOR CHANNELS PAGE */
    /* Only keeping necessary display settings for layout */
    display: flex; /* Kept for alignment if needed later */
    flex-direction: row; /* Changed to row to contain the single link properly */
    gap: 0; /* No gap needed */
    padding: 0; /* Remove unwanted padding */
    background-color: transparent; /* Remove unwanted background */
    border-radius: 0;
    box-shadow: none;
    border: none; /* Remove unwanted border */
    max-width: none;
}
/* ... (Keep form input styles below this block if you use the form elsewhere) */


/* NEW: Style the 'Create Channel' link as a button */
#channel-form a {
    /* Inherit/mimic the primary button style */
    background: var(--bg-gradient);
    color: var(--text-light);
    box-shadow: 0 4px 10px rgba(75, 108, 183, 0.3);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-xl);
    font-weight: 500;
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-size: var(--text-sm);
    letter-spacing: 0.5px;
}
/* ... (Other CSS sections remain the same until mobile responsiveness) */

/* --- Mobile Responsiveness --- */

@media (max-width: 600px) {
/* ... (other mobile styles) */

    .discussion-header h1 {
        font-size: var(--text-3xl);
    }
    
    /* NEW FIX: Target the button link inside the form on mobile */
    #channel-form a {
        font-size: var(--text-xs); /* Make the font even smaller */
        padding: var(--space-2) var(--space-3); /* Reduce padding */
    }
}

/* --- Channels List (Grid) --- */

#channels-list {
    display: grid;
    /* Responsive Grid: Cards min-width 280px, fills available space */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding-bottom: 40px;
}

.channel-card {
    background-color: var(--surface-color, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    padding: 16px 18px;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    text-align: left !important;
    gap: 16px !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;
    min-height: 100px;
    box-sizing: border-box;
}

.channel-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-color: var(--primary-color);
}

.channel-card-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-light);
    flex-shrink: 0; /* Prevents image from squishing */
}

.channel-card-details {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1; /* Pushes content to fill space evenly */
}

.channel-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
    
    /* Limit Title to 1 line */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.channel-card-desc {
    font-size: 0.9rem;
    color: var(--text-gray);
    margin: 0;
    line-height: 1.5;
    
    /* Limit Description to 3 lines (The "Limited" Fix) */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Delete button positioning */
.channel-card-delete {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 4px 10px;
    font-size: 0.75rem;
    z-index: 2;
    opacity: 0.7;
}

.channel-card-delete:hover {
    opacity: 1;
}


/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
}
.modal-box {
    background: var(--bg-card);
    color: var(--text-main);
    padding: 25px;
    border-radius: 15px;
    width: 90%; max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    animation: popIn 0.2s ease-out;
}
/* Light Mode Grayish Override */
[data-theme="light"] .modal-box {
    background: #f4f4f4;
    border-color: #ddd;
}
.modal-box h3 { margin-top: 0; margin-bottom: 10px; }
.modal-actions { margin-top: 20px; display: flex; gap: 10px; justify-content: center; }
@keyframes popIn { from {transform: scale(0.9); opacity: 0;} to {transform: scale(1); opacity: 1;} }

@media (max-width: 992px) {
    .container {
        padding-top: 1px;
        flex-direction: column;
        min-height: auto;
        overflow: visible;
    }
}

.section-title-small {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-light);
}

[data-theme="dark"] .section-title-small {
    color: var(--text-light);
    border-bottom-color: var(--border-color);
}

/* --- Split Section Headers --- */
.section-title-small {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--border-light);
    width: 100%;
}

[data-theme="dark"] .section-title-small {
    color: var(--color-text-primary);
    border-bottom-color: var(--border-color);
}

/* --- BANNED CHANNEL CARD (For channels.html) --- */
.channel-card.banned-card {
    background-color: #fee2e2; /* Light Red */
    border: 1px solid #ef4444;
    cursor: not-allowed;
    opacity: 0.8;
}

[data-theme="dark"] .channel-card.banned-card {
    background-color: rgba(127, 29, 29, 0.4);
    border-color: #991b1b;
}

.channel-card.banned-card:hover {
    transform: none;
    box-shadow: none;
}

.banned-badge {
    color: #dc2626;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
}


/* --- CRITICAL MOBILE FIXES --- */
@media (max-width: 992px) {
    /* 1. Hide Desktop Sidebar on Mobile to prevent it from pushing content down */
    .sidebar {
        display: none !important;
    }

    /* 2. Reset Container to ensure full width usage */
    .container {
        display: block !important; /* Removes flex complications on mobile */
        padding: 10px !important;
        padding-bottom: 80px !important; /* Space for bottom nav */
    }

    /* 3. Ensure Main Content takes full width */
    .main-content {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* 4. Fix Grid Collapse on small screens */
    .discussion-list {
        display: grid !important;
        /* Ensure cards have a minimum width but can shrink if needed */
        grid-template-columns: 1fr !important; 
        gap: 15px !important;
        margin-top: 20px !important;
    }
}

/* Fix Channel Name Color in Dark Mode */
.channel-card-title {
    color: var(--text-dark); /* Default for light mode */
    transition: color 0.3s ease;
}

/* Ensure title switches to light color in dark mode */
[data-theme="dark"] .channel-card-title {
    color: #FFFFFF !important;
}

/* Fix Banned Card Title specifically */
.channel-card.banned-card h3 {
    color: #b91c1c !important; /* Keep red even in dark mode for visibility */
}

[data-theme="dark"] .channel-card.banned-card h3 {
    color: #fca5a5 !important; /* Lighter red for dark mode contrast */
}