@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700;800&display=swap');

/* --- THEME VARIABLES --- */
:root {
    --bg-app: #ffffff;
    --bg-hover: #f3f4f6;
    --bg-secondary: #f7f9fa;
    --text-primary: #0f1419;
    --text-muted: #536471;
    --brand-color: #000000;
    --brand-hover: #333333;
    --border-line: #eff3f4;
    --error: #f4212e;
}

[data-theme="dark"] {
    --bg-app: #000000;
    --bg-hover: #16181c;
    --bg-secondary: #16181c;
    --text-primary: #e7e9ea;
    --text-muted: #71767b;
    --brand-color: #ffffff;
    --brand-hover: #d7dbdc;
    --border-line: #2f3336;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Space Grotesk', sans-serif; }

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    overflow-y: scroll;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-layout {
    display: flex;
    max-width: 1260px;
    margin: 0 auto;
    min-height: 100vh;
}

/* --- Left Sidebar (Desktop Nav) --- */
.sidebar {
    width: 275px;
    position: sticky;
    top: 0; 
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;
    border-right: 1px solid var(--border-line);
}

.brand-logo h2 { font-size: 2.2rem; font-weight: 800; padding: 0.5rem 1rem; margin-bottom: 1rem; color: var(--text-primary); letter-spacing: -1px; }
.brand-logo { text-decoration: none; }

.nav-links { display: flex; flex-direction: column; gap: 0.5rem; }

.nav-item {
    display: flex; align-items: center; gap: 1.2rem; padding: 0.8rem 1.2rem;
    text-decoration: none; color: var(--text-primary); font-size: 1.25rem;
    border-radius: 2rem; transition: background-color 0.2s ease; cursor: pointer;
    background: none; border: none; width: fit-content;
}

.nav-item:hover { background-color: var(--bg-hover); }
.nav-item.active { font-weight: 700; }
.nav-icon { width: 26px; height: 26px; flex-shrink: 0; }

.logout-btn { color: var(--error); font-weight: 600; margin-top: 1rem; }
.logout-btn:hover { background-color: #fee2e2; color: #f4212e; }


/* ==========================================
   ANIMATED THEME TOGGLE (Desktop Only)
   ========================================== */
.theme-switch-container {
    padding-left: 0.8rem; /* slight adjustment to align the slider visually */
}

.theme-switch {
    width: 48px;
    height: 26px;
    background-color: var(--border-line);
    border-radius: 13px;
    position: relative;
    display: flex;
    align-items: center;
    border: 0px solid var(--text-muted);
}

.switch-handle {
    width: 20px;
    height: 20px;
    background-color: var(--bg-app);
    border-radius: 50%;
    position: absolute;
    left: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    /* The sliding animation */
    transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1), background-color 0.3s;
}

/* Move the slider to the right when dark mode is active */
[data-theme="dark"] .switch-handle {
    transform: translateX(22px);
    background-color: var(--brand-color);
}

/* Icon Animations */
.icon-sun, .icon-moon {
    width: 12px;
    height: 12px;
    position: absolute;
    transition: opacity 0.4s, transform 0.4s;
}

.icon-sun {
    color: #f59e0b; /* Yellow */
    opacity: 1;
    transform: rotate(0deg);
}

.icon-moon {
    color: #000000; /* Dark for contrast against white slider */
    opacity: 0;
    transform: rotate(-90deg);
}

/* When dark mode active: fade sun out, fade moon in, spin them */
[data-theme="dark"] .icon-sun {
    opacity: 0;
    transform: rotate(90deg);
}

[data-theme="dark"] .icon-moon {
    opacity: 1;
    transform: rotate(0deg);
}


/* --- Central Feed --- */
.feed-main { flex: 1; max-width: 600px; border-right: 1px solid var(--border-line); }

.mobile-top-bar {
    display: none; padding: 1rem; border-bottom: 1px solid var(--border-line);
    position: sticky; top: 0; background: var(--bg-app); opacity: 0.95;
    backdrop-filter: blur(12px); z-index: 10;
}

/* Post Composer */
.composer-widget { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-line); }
.composer-top { display: flex; gap: 1rem; }
.avatar-placeholder {
    width: 40px; height: 40px; border-radius: 50%; background-color: var(--brand-color);
    color: var(--bg-app); display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 1.2rem; flex-shrink: 0;
}

textarea {
    width: 100%; border: none; resize: none; font-size: 1.2rem; padding-top: 0.5rem;
    outline: none; font-family: inherit; color: var(--text-primary); background: transparent; min-height: 50px;
}

.composer-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; padding-left: calc(40px + 1rem); }
.char-count { font-size: 0.85rem; color: var(--text-muted); }

.btn-primary {
    background-color: var(--brand-color); color: var(--bg-app); border: none;
    padding: 0.6rem 1.5rem; border-radius: 2rem; font-weight: 600; font-size: 0.95rem;
    cursor: pointer; transition: all 0.2s;
}
.btn-primary:hover:not(:disabled) { background-color: var(--brand-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Generated Posts Feed */
.post { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-line); display: flex; gap: 1rem; cursor: pointer; transition: background-color 0.2s; }
.post:hover { background-color: var(--bg-secondary); }
.post-header { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.25rem; }
.post-name { font-weight: 700; font-size: 1rem; }
.post-username, .post-time { color: var(--text-muted); font-size: 0.9rem; }
.post-content { font-size: 0.95rem; line-height: 1.4; color: var(--text-primary); margin-bottom: 0.8rem; word-wrap: break-word;}

/* --- Right Sidebar --- */
.right-panel { width: 350px; padding: 1rem 1.5rem; position: sticky; top: 0; height: 100vh; }
.search-bar { display: flex; align-items: center; background-color: var(--bg-secondary); padding: 0.8rem 1rem; border-radius: 2rem; margin-bottom: 1.5rem; border: 1px solid transparent; }
.search-bar:focus-within { border-color: var(--brand-color); background: transparent; }
.search-bar svg { width: 18px; height: 18px; color: var(--text-muted); margin-right: 0.8rem; }
.search-bar input { border: none; background: transparent; outline: none; font-size: 0.95rem; width: 100%; color: var(--text-primary); }

.trending-widget { background-color: var(--bg-secondary); border-radius: 1rem; padding: 1rem 0; }
.trending-widget h3 { padding: 0 1rem 1rem 1rem; font-size: 1.25rem; font-weight: 800; }
.trend-item { padding: 0.8rem 1rem; cursor: pointer; transition: background 0.2s; }
.trend-item:hover { background-color: var(--bg-hover); }
.trend-category, .trend-stats { font-size: 0.8rem; color: var(--text-muted); }
.trend-title { font-weight: 700; margin: 0.2rem 0; }


/* ==========================================
   MOBILE RESPONSIVENESS - FIXED BOTTOM NAV
   ========================================== */
@media (max-width: 1024px) {
    .right-panel { display: none; } 
    .sidebar { width: 80px; align-items: center; } 
    .brand-logo h2, .nav-text { display: none; }
    .nav-item { padding: 0.8rem; }
}

@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    
    .sidebar {
        top: auto; 
        position: fixed; 
        bottom: 0; 
        left: 0;
        width: 100%; 
        height: 60px;
        flex-direction: row; 
        justify-content: space-around; 
        align-items: center;
        background: var(--bg-app); 
        border-top: 1px solid var(--border-line); 
        border-right: none;
        z-index: 1000; 
        padding: 0;
    }
    
    /* Completely hide Settings, Theme, and Logout on mobile */
    .sidebar-bottom { display: none !important; }

    /* Expand main links to fill the whole bottom bar evenly */
    .sidebar-top { flex: 1; display: flex; width: 100%; }
    .nav-links { 
        display: flex; flex-direction: row; 
        width: 100%; justify-content: space-around; align-items: center; 
        gap: 0;
    }
    
    /* Clean up mobile icons */
    .nav-item { border-radius: 50%; padding: 0.6rem; margin: 0; }
    .nav-icon { width: 24px; height: 24px; }
    
    .feed-main { max-width: 100%; border-right: none; padding-bottom: 70px; }
    .mobile-top-bar { display: block; }
    .mobile-top-bar h2 { font-weight: 800; letter-spacing: -1px; }
}