/* 
   PREMIUM MODERN THEME OVERHAUL
   v3.0 - Designed for High Contrast, Glassmorphism, and Slick Interactions
*/

:root {
    /* Core Colors - Slightly softer black for less contrast strain */
    --bg-body: #080808;
    --bg-card: #121212;
    --bg-glass: rgba(18, 18, 18, 0.75);

    /* Text */
    --text-main: #f0f0f0;
    /* Soft White */
    --text-muted: #8899a6;
    --text-dim: #5c6b79;

    /* Accents - Adjusted Red to be premium but less aggressive */
    --primary: #D32F2F;
    /* Deep Premium Red */
    --primary-glow: rgba(211, 47, 47, 0.25);
    /* Subtle Glow */
    --primary-hover: #b71c1c;

    /* Borders */
    --border-color: #2f3336;
    --border-subtle: rgba(255, 255, 255, 0.05);

    /* Layout */
    --sidebar-width: 275px;
    --rightbar-width: 350px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;

    /* Effects */
    --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.5);
    --glass-blur: blur(12px);
}

/* --- RESET & GLOBAL --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- MAIN LAYOUT GRID --- */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--rightbar-width);
    gap: 0;
    /* Removing gap to prevent bleed */
    max-width: 1300px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
}

.app-layout.no-rightbar {
    grid-template-columns: var(--sidebar-width) 1fr;
    max-width: 1000px;
    /* Slimmer layout for 2 columns */
}

/* --- LEFT SIDEBAR (PREMIUM) --- */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px 10px;
    /* Reduced top padding from 30px to 20px */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0;
    /* Remove gap entirely, handle with margins for precision */
}

/* Sidebar Logo - CRISP WHITE */
.sidebar .logo {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    padding-left: 15px;
    margin-bottom: 12px;
    /* Increased spacing under logo */
    color: #ffffff;
    background: none;
    -webkit-text-fill-color: initial;
    display: flex;
    align-items: center;
    gap: 2px;
}

.highlight {
    color: var(--primary);
    -webkit-text-fill-color: initial;
}

/* Sidebar Menu - Fix Dots and Add Fluidity */
.menu-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none !important;
    padding: 0;
    margin-top: 15px;
    /* Spacing between user card and menu */
}


.menu-list li {
    list-style: none;
}

.menu-list a {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 24px;
    border-radius: 40px;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    text-decoration: none !important;
    /* Force remove underlines */
}

.menu-list a:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(6px);
    color: #fff;
}

.menu-list li.active a {
    font-weight: 700;
    color: var(--primary);
    background: rgba(211, 47, 47, 0.08);
}

.btn-create-post {
    margin-top: 25px;
    /* Balanced spacing */
    width: 90%;
    margin-left: auto;
    margin-right: auto;
    padding: 16px;
    border-radius: 50px;
    background: var(--primary);
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 20px var(--primary-glow);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-create-post:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 12px 30px var(--primary-glow);
}

/* Sidebar User Profile Pill */
.user-card-sm {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: transparent;
    border-radius: 50px;
    transition: 0.2s;
    cursor: pointer;
    margin-top: 10px;
    /* Balanced distance from logo */
    margin-bottom: 10px;
    border: 1px solid transparent;
}

.user-card-sm:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-subtle);
}

.user-card-sm img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.user-card-sm .name {
    font-weight: 700;
    font-size: 1rem;
}

.user-card-sm .role {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-logout {
    margin-top: auto;
    /* Push to bottom */
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-logout:hover {
    color: var(--primary);
}

/* --- CENTER FEED AREA --- */
.feed-container {
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    max-width: 650px;
    width: 100%;
}

/* Sticky Header */
.feed-header {
    position: sticky;
    top: 0;
    z-index: 999;
    background: rgba(5, 5, 5, 0.85);
    /* Matches bg-body */
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
}

.feed-header .tab {
    flex: 1;
    text-align: center;
    padding: 18px 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: color 0.3s;
}

.feed-header .tab:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.feed-header .tab.active {
    color: var(--text-main);
}

.feed-header .tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Create Post Box */
.new-post-box {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
}

.new-post-box img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.new-post-box textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: white;
    resize: none;
    outline: none;
    font-size: 1.25rem;
    min-height: 50px;
    margin-top: 10px;
}

.new-post-box textarea::placeholder {
    color: var(--text-dim);
}

/* Post Actions Bar */
.post-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.btn-upload {
    background: none;
    border: none;
    color: var(--primary);
    /* Maintain primary color accent */
    font-size: 1.4rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-upload:hover {
    background: rgba(244, 42, 53, 0.1);
}

.btn-primary-sm {
    padding: 10px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.btn-primary-sm:hover {
    background: var(--primary-hover);
    box-shadow: 0 5px 15px var(--primary-glow);
}

.btn-primary-sm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

/* Image Preview */
.image-preview-container {
    position: relative;
    margin-top: 15px;
    display: none;
}

.image-preview-container img {
    max-height: 280px;
    width: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.btn-close-preview {
    position: absolute;
    top: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Second definition removed */

/* --- STREAM POST --- */
.post {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    cursor: pointer;
    transition: background 0.2s ease;
    position: relative;
    animation: fadeIn 0.5s ease backwards;
}

.post:hover {
    background: rgba(255, 255, 255, 0.015);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.post-body {
    flex: 1;
    min-width: 0;
    /* Prevents flex overflow */
}

.post-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    /* Safety for small screens */
}

.post-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
}

.post-name:hover {
    color: var(--primary);
}

.post-handle {
    color: var(--text-dim);
    font-size: 0.95rem;
}

.post-time {
    margin-left: auto;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.post-role {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 6px;
    background: #1d1f23;
    color: var(--text-muted);
    border: 1px solid #333;
    font-weight: 600;
    text-transform: uppercase;
}

/* Post Header Layout - Logic for Mobile Lines */
.post-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.header-row-top {
    display: flex;
    align-items: baseline;
    gap: 6px;
    width: 100%;
}

.header-row-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Indent slightly on mobile for hierarchy? Optional */
}

/* Desktop Unwrapping */
@media (min-width: 600px) {
    .post-header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 6px;
    }

    .header-row-top,
    .header-row-bottom {
        display: contents;
        /* Unwrap the divs to let children sit together */
    }

    .post-time {
        order: 99;
        /* Force time to end */
        margin-left: auto;
    }
}

.post-text {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #e7e9ea;
    white-space: pre-wrap;
    margin-bottom: 12px;
}

.post-image {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-top: 10px;
    border: 1px solid var(--border-color);
    background-color: #000;
}

/* Post Actions (Like, Comment, etc) */
.post-actions {
    display: flex;
    justify-content: space-between;
    max-width: 450px;
    margin-top: 12px;
}

.action {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    padding: 8px;
    border-radius: 50px;
}

.action:hover {
    color: var(--primary);
    background: rgba(244, 42, 53, 0.1);
}

.action ion-icon {
    font-size: 1.25rem;
}

.action.liked {
    color: #F91880;
}

.action.liked ion-icon {
    color: #F91880;
}

.action.reposted {
    color: #00ba7c;
}

/* Comments */
.comments-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    display: none;
}

.comment {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.comment-content {
    background: #16181c;
    padding: 10px 15px;
    border-radius: var(--radius-md);
    flex: 1;
}

.comment-input-box {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.comment-input-box input {
    flex: 1;
    background: #16181c;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 10px 20px;
    color: white;
    outline: none;
}

.comment-input-box input:focus {
    border-color: var(--primary);
}

.comment-input-box button {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
}

/* --- RIGHT SIDEBAR --- */
.rightbar {
    padding: 30px;
    height: 100vh;
    position: sticky;
    top: 0;
}

.rightbar h3 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 20px;
    padding-left: 5px;
}

.trend-list {
    background: #16181c;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 25px;
}

.trend-item {
    padding: 15px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.trend-item:last-child {
    border-bottom: none;
}

.trend-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.trend-item .tag {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.promo-box {
    background: #16181c;
    padding: 20px;
    border-radius: var(--radius-lg);
}

/* --- MOBILE BOTTOM NAV (Glass Dock) --- */
.mobile-nav {
    display: none;
}

@media (max-width: 1024px) {
    .app-layout {
        grid-template-columns: 80px 1fr 300px;
        gap: 0;
    }

    .sidebar {
        align-items: center;
    }

    .sidebar .logo span,
    .sidebar .menu-list a span,
    .sidebar .user-card-sm .name,
    .sidebar .user-card-sm .role {
        display: none;
    }

    .btn-create-post {
        width: 50px;
        height: 50px;
        padding: 0;
        border-radius: 50%;
    }

    .btn-create-post ion-icon {
        font-size: 1.5rem;
    }

    .btn-logout span {
        display: none;
    }
}

@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 88px 1fr;
    }

    .rightbar {
        display: none;
    }
}

@media (max-width: 600px) {
    .app-layout {
        display: block;
        padding-top: 60px;
        /* Header space */
        padding-bottom: 80px;
        /* Nav space */
    }

    .sidebar {
        display: none !important;
    }

    /* Mobile Header */
    .feed-header {
        position: fixed;
        left: 0;
        width: 100%;
        top: 0;
        height: 60px;
        background: rgba(0, 0, 0, 0.85);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }

    .feed-container {
        border: none;
        max-width: 100%;
    }

    /* Mobile Bottom Nav */
    .mobile-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 65px;
        background: rgba(0, 0, 0, 0.9);
        backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-color);
        z-index: 2000;
    }

    .mobile-nav a {
        color: var(--text-muted);
        font-size: 1.7rem;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        transition: 0.2s;
    }

    .mobile-nav a.active {
        color: var(--primary);
    }

    .mobile-nav a.add {
        background: var(--primary);
        color: white;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        font-size: 2rem;
        margin-bottom: 20px;
        /* Floating look */
        box-shadow: 0 5px 15px var(--primary-glow);
    }

    .new-post-box {
        padding: 15px;
    }

    .post {
        padding: 15px;
    }
}

/* --- AUTH PAGE --- */
/* MOVED TO custom_style.css TO PREVENT CONFLICTS AND FIX LAYOUT ISSUES */

.auth-box {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Helper for Buttons */
.btn-xs {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: white;
    cursor: pointer;
    transition: 0.2s;
}

.btn-follow {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-follow:hover {
    background: rgba(244, 42, 53, 0.1);
}

.btn-following {
    border-color: var(--border-color);
    color: var(--text-dim);
}

.btn-following:hover {
    border-color: #ef4444;
    color: #ef4444;
}

/* Switch Toggle (Inheritance Check) */
/* The switch CSS is in custom_style.css, we just ensure variables match */
/* --- IMAGE LIGHTBOX MODAL --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: modalZoom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalZoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

.modal-caption {
    margin-top: 20px;
    color: white;
    font-size: 1.1rem;
    text-align: center;
    max-width: 600px;
    line-height: 1.6;
}

.close-modal {
    position: absolute;
    top: 30px;
    right: 40px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    z-index: 10001;
}

.close-modal:hover {
    color: var(--primary);
    transform: scale(1.1);
}

/* Ensure post images look clickable */
.post-image {
    cursor: pointer;
    transition: filter 0.2s;
}

.post-image:hover {
    filter: brightness(0.9);
}