/* Modern Clean Design System (Circle.so inspired) */
:root {
    /* Theme-independent colors */
    --primary: #008C95;
    --primary-hover: #004C51;

    --accent: #F29E4C;
    --accent-hover: #D9822B;

    /* Status Colors */
    --success: #2A9D8F;
    --success-soft: rgba(42, 157, 143, 0.15);
    --warning: #FFD166;
    --error: #EF476F;
    --danger: #EF4444;
    --danger-light: rgba(239, 68, 68, 0.1);

    /* Spacing (theme-independent) */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Radius (theme-independent) */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme (Default) */
:root,
[data-theme="dark"] {
    /* Backgrounds */
    --bg-body: #121212;
    --bg-white: #1E2124;
    --bg-sidebar: #121212;
    --bg-input: #23272F;
    --bg-card: #181B21;
    --bg-hover: rgba(255, 255, 255, 0.08);

    /* Text Colors */
    --text-main: #F8F9FA;
    --text-muted: #9CA3AF;
    --text-light: #7A7A7A;
    --text-secondary: #B3DADB;
    --text-on-dark: #FFFFFF;
    --text-primary: #F8F9FA;
    --text-sidebar-muted: #9CA3AF;

    /* Primary variations for dark theme */
    --primary-light: #E6F5F6;
    --primary-soft: #B3DADB;
    --info: #B3DADB;

    /* Branding */
    --brand-dark: #002F31;
    --brand-medium: #004C51;

    /* Borders & Dividers */
    --border-color: rgba(255, 255, 255, 0.05);
    --divider: rgba(255, 255, 255, 0.05);
    --sidebar-divider: rgba(255, 255, 255, 0.05);

    /* Grays for dark theme */
    --gray-50: #181B21;
    --gray-100: #1F2937;
    --gray-200: #2D333B;
    --gray-300: #4B5563;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #9CA3AF;
    --gray-700: #D1D5DB;

    /* Shadows for dark theme */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

/* Light Theme */
[data-theme="light"] {
    /* Backgrounds */
    --bg-body: #FFFFFF;
    --bg-white: #F9FAFB;
    --bg-sidebar: #FFFFFF;
    --bg-input: #F3F4F6;
    --bg-card: #FFFFFF;
    --bg-hover: rgba(0, 0, 0, 0.04);

    /* Text Colors */
    --text-main: #111827;
    --text-muted: #6B7280;
    --text-light: #9CA3AF;
    --text-secondary: #008C95;
    --text-on-dark: #111827;
    --text-primary: #111827;
    --text-sidebar-muted: #6B7280;

    /* Primary variations for light theme */
    --primary-light: #E6F5F6;
    --primary-soft: #B3DADB;
    --info: #008C95;

    /* Branding */
    --brand-dark: #002F31;
    --brand-medium: #004C51;

    /* Borders & Dividers */
    --border-color: rgba(0, 0, 0, 0.1);
    --divider: rgba(0, 0, 0, 0.06);
    --sidebar-divider: rgba(0, 0, 0, 0.06);

    /* Grays for light theme */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;

    /* Shadows for light theme */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Logo Theme Switching */
/* Default (dark theme) - show dark logo */
.logo-light {
    display: none;
}

.logo-dark {
    display: block;
}

/* Light theme - show light logo */
[data-theme="light"] .logo-light {
    display: block !important;
}

[data-theme="light"] .logo-dark {
    display: none !important;
}

/* Dark theme - show dark logo */
[data-theme="dark"] .logo-light {
    display: none !important;
}

[data-theme="dark"] .logo-dark {
    display: block !important;
}

/* Theme Toggle Icons Logic */
#theme-icon-sun {
    display: block;
}

#theme-icon-moon {
    display: none;
}

[data-theme="light"] #theme-icon-sun {
    display: none !important;
}

[data-theme="light"] #theme-icon-moon {
    display: block !important;
}

[data-theme="dark"] #theme-icon-sun {
    display: block !important;
}

[data-theme="dark"] #theme-icon-moon {
    display: none !important;
}


body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

ul {
    list-style: none;
}

/* Custom Scrollbars - Minimalist Premium Style */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Firefox Support */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* =========================================
   LAYOUT STYLES
   ========================================= */

/* Layout Grid */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    color: var(--text-on-dark);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: var(--spacing-md);
    height: calc(100vh - 32px);
    /* Floating height */
    margin-left: var(--spacing-md);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg) var(--spacing-md);
    transition: width 0.3s ease,
        padding 0.3s ease,
        border-width 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.app-sidebar.collapsed {
    width: 0;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-right-width: 0;
}

[data-theme="light"] .app-sidebar {
    background-color: #FFFFFF !important;
    border-right: 1px solid var(--border-color);
}

/* Preload State to prevent Flash of Unstyled Content (FOUC) */
html.preload-sidebar-collapsed .app-sidebar {
    width: 0 !important;
    padding: 0 !important;
    border: none !important;
    transition: none !important;
    visibility: hidden;
}

/* Responsive Layout */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    }

    .app-sidebar.mobile-open {
        width: 280px;
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(4px);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .app-main {
        padding: var(--spacing-md) !important;
    }
}

.sidebar-header {
    margin-bottom: var(--spacing-xl);
    padding: 0 var(--spacing-xs);
}

.community-name {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-on-dark);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section {
    margin-bottom: var(--spacing-lg);
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary) !important;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    padding: 0 var(--spacing-xs);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-md);
    margin-bottom: 2px;
    border-radius: var(--radius-md);
    color: var(--text-sidebar-muted);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: none;
    position: relative;
    border-radius: var(--radius-md);
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: var(--spacing-sm);
    /* Simple grey box placeholder for verification, or actual svg later */
    display: inline-block;
    vertical-align: middle;
}

/* Main Content */
.app-main {
    flex: 1;
    width: 100%;
    padding: var(--spacing-xl);
    overflow-x: auto;
}

.page-header {
    margin-bottom: var(--spacing-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Components: Card */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: none;
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

/* Utility: Desktop Only */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* =========================================
   COMPONENT STYLES
   ========================================= */

/* Post Card */
/* Post Card */
.post-card {
    cursor: default;
    transition: box-shadow 0.2s, transform 0.2s;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    /* Deep shadow */
    border: none;
    margin-bottom: var(--spacing-lg);
    overflow: hidden;
}

.post-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.post-header {
    display: flex;
    align-items: center;
    /* Changed from flex-start to center for better alignment */
    padding: var(--spacing-md);
    padding-bottom: var(--spacing-xs);
    /* Less bottom padding */
    position: relative;
    /* margin-bottom removed, spacing handled by padding */
}

.post-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--divider);
    margin-right: var(--spacing-xs);
    /* Reduced spacing */
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    overflow: hidden;
}

.post-avatar img {
    transition: opacity 0.2s;
}

.post-avatar:hover img {
    opacity: 0.9;
}

.post-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.post-author {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* "Follow" link style */
.follow-link {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
}

.follow-link:hover {
    text-decoration: underline;
}

.post-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.globe-icon {
    font-size: 0.75rem;
    /* Tiny globe */
    opacity: 0.7;
}

.post-content-area {
    padding: 0 var(--spacing-md) var(--spacing-md);
}

.post-title {
    font-size: 1rem;
    font-weight: 400;
    /* Normal weight, Facebook style usually just bolding snippets or hashtags */
    margin-bottom: var(--spacing-xs);
    color: var(--text-main);
}

.post-preview {
    color: var(--text-main);
    /* Darker text */
    font-size: 0.95rem;
    line-height: 1.5;
    /* Remove line clamp for full content feel on feed or keep it? FB collapses long posts. Let's keep clamp but larger */
    display: -webkit-box;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    /* More lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Post Actions / Stats Bar */
/* Post Actions / Stats Bar */
.post-stats {
    padding: var(--spacing-xs) var(--spacing-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    justify-content: flex-start;
    /* Aligned left */
    gap: var(--spacing-md);
    align-items: center;
    /* No border here, stats sit above actions */
}

.post-actions {
    margin: 0 var(--spacing-md);
    padding: 4px 0;
    border-top: 1px solid var(--divider);
    border-bottom: 1px solid transparent;
    /* Optional */
    display: flex;
    justify-content: flex-start;
    /* Aligned left */
    gap: var(--spacing-xs);
    /* Use flex-gap for spacing */
}

.action-btn {
    /* flex: 1; Removed */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 16px;
    /* Adjusted padding */
    color: #65676b;
    /* FB Gray */
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
    background: transparent;
    border: none;
}

.action-btn:hover {
    background-color: var(--divider);
}

.action-btn.active {
    color: var(--primary);
}

.footer-icon {
    font-size: 1.1rem;
}

/* Post Input Area */
.create-post-placeholder {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    cursor: text;
}

.input-fake {
    flex: 1;
    background: var(--bg-input);
    /* Darker input background */
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    /* Less rounded, more modern */
    color: var(--text-muted);
    font-size: 0.95rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.input-fake:hover {
    background: var(--bg-hover);
    /* Slightly lighter on hover */
    border-color: var(--border-color);
}

/* Space Header */
.space-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    height: 120px;
    border-radius: var(--radius-lg);
    margin-bottom: -40px;
    /* Overlap effect */
    position: relative;
    z-index: 0;
}

.space-info {
    position: relative;
    z-index: 1;
    padding: 0 var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    display: flex;
    align-items: flex-end;
}

.space-icon-large {
    width: 80px;
    height: 80px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-right: var(--spacing-lg);
}

.space-details {
    padding-bottom: var(--spacing-xs);
}

.space-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
}

.space-desc {
    color: var(--text-muted);
}

/* =========================================
   ADMIN STYLES
   ========================================= */

/* Modern Card Styles */
.admin-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.admin-card:hover {
    box-shadow: var(--shadow-md);
}

.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.admin-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Stat Cards */
.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    color: white;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card.success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, var(--warning) 0%, #D97706 100%);
}

.stat-card.danger {
    background: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%);
}

.stat-card-label {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: var(--spacing-xs);
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.stat-card-change {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-top: var(--spacing-xs);
}

/* Modern Table */
.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.admin-table thead {
    background: var(--gray-50);
}

.admin-table th {
    padding: var(--spacing-md);
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
}

.admin-table td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.admin-table tbody tr {
    transition: background-color 0.15s ease;
}

.admin-table tbody tr:hover {
    background: var(--gray-50);
}

/* Modern Buttons */
.btn-modern {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--border-radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary) !important;
    color: white !important;
}

.btn-primary:hover {
    filter: brightness(0.92);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--gray-50);
}

/* Icon Buttons */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn-primary {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

.icon-btn-primary:hover {
    background: var(--primary);
    color: white;
}

.icon-btn-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.icon-btn-danger:hover {
    background: var(--danger);
    color: white;
}

/* Modern Input Fields */
.input-modern {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background: var(--gray-50);
    color: var(--text-main) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color-scheme: dark;
}

.input-modern:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--spacing-lg);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {

    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Page Header */
.page-header-modern {
    margin-bottom: var(--spacing-xl);
}

.page-title-modern {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--spacing-xs) 0;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
}

/* List Items */
.list-item-modern {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
}

.list-item-modern:hover {
    background: var(--gray-50);
}

.list-item-modern:last-child {
    border-bottom: none;
}

/* Course Player - Light Theme Adjustments */
[data-theme="light"] .module-header span:first-of-type {
    color: var(--text-main) !important;
}

/* Light theme: lesson titles should be dark by default */
[data-theme="light"] .lesson-title-text {
    color: var(--text-main) !important;
}