/* assets/css/global.css */
:root {
    --brand-orange: #cf4317; 
    --bg-color: #fbfbfb; 
    --text-main: #1a1a1a;
    --text-muted: #888888;
    --border-color: #e2e2e2; 
    --font-main: "Inter", -apple-system, sans-serif;
}

html { scroll-behavior: smooth; }

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-main); background-color: var(--bg-color); color: var(--text-main); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }

/* Global Buttons & Inputs - SHARP & SQUARE */
.btn-primary {
    background-color: var(--brand-orange);
    color: white;
    padding: 10px 24px;
    border: none;
    border-radius: 0; /* Square corners */
    font-size: 11px; /* Short font */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px; /* Spaced out */
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background-color: #b53811; }

.btn-icon {
    border: 1px solid var(--border-color);
    background: transparent;
    padding: 10px;
    border-radius: 0; /* Square corners */
    cursor: pointer;
    color: var(--text-main);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.btn-icon:hover { background: #eaeaea; }

.form-input, .form-select {
    width: 100%; padding: 16px; font-size: 18px; font-family: var(--font-main);
    border: 1px solid var(--border-color); border-radius: 0; /* Square inputs */
    background-color: #fff; color: var(--text-main); outline: none; transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus { border-color: var(--brand-orange); }

/* Top Navigation */
/* --- OVERHAULED NAVBAR --- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    background-color: #fff;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-brand {
    font-size: 24px;
    font-weight: 800;
    color: var(--brand-orange);
    text-decoration: none;
    letter-spacing: -0.5px;
}

/* Centered Search Bar */
.search-container {
    flex: 1;
    max-width: 600px;
    margin: 0 40px;
}

.search-bar {
    width: 100%;
    padding: 12px 20px;
    border-radius: 4px;
    background-color: #fbfbfb;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.search-bar:focus {
    background-color: #fff;
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 3px rgba(193, 56, 19, 0.1);
}

/* Nav Links & Active States */
.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 100%;
}

.nav-link {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    text-decoration: none;
    letter-spacing: 0.5px;
    height: 70px; /* Full height to allow bottom border */
    display: flex;
    align-items: center;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}

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

.nav-link.active {
    color: var(--brand-orange);
    border-bottom-color: var(--brand-orange);
}

/* Icons */
.nav-icon {
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    height: 70px;
}
.nav-icon:hover { color: var(--brand-orange); }

/* User Avatar & Dropdown */
.user-menu-container {
    position: relative;
    display: flex;
    align-items: center;
    height: 70px;
    cursor: pointer;
    margin-left: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--border-color); /* Fallback */
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.user-dropdown {
    position: absolute;
    top: 70px;
    right: 0;
    width: 220px;
    background: #fff;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    display: none; /* Hidden by default */
    flex-direction: column;
    z-index: 1001;
}

/* Show dropdown when hovering over the container */
.user-menu-container:hover .user-dropdown {
    display: flex; 
}

.dropdown-item {
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #fbfbfb;
    color: var(--brand-orange);
}

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

/* Global Grid Layout */
.layout-grid { display: grid; grid-template-columns: 240px 1fr 300px; max-width: 1440px; margin: 0 auto; min-height: calc(100vh - 70px); }


/* --- LEFT SIDEBAR (EDITORIAL HUB) --- */
.sidebar-left {
    padding: 32px 24px;
    border-right: 1px solid var(--border-color);
    background: #fff;
    height: calc(100vh - 70px);
    position: sticky;
    top: 70px;
    overflow-y: auto;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    margin-top: 32px;
}
.sidebar-section-title:first-child { margin-top: 0; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin: 0 -12px; /* Pulls the hover state out to the edges */
    border-radius: 6px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background-color: #fbfbfb;
    color: var(--brand-orange);
}

.sidebar-link.active {
    background-color: rgba(193, 56, 19, 0.05);
    color: var(--brand-orange);
}

.sidebar-link svg {
    color: var(--text-muted);
    transition: 0.2s;
}
.sidebar-link:hover svg, .sidebar-link.active svg {
    color: var(--brand-orange);
}

/* Dynamic Circle Indicator */
.circle-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--border-color);
    flex-shrink: 0;
}



.main-feed { padding: 40px 64px; background-color: #fff; }
.feed-header h1 { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin-bottom: 8px; }
.feed-header p { font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1px; border-bottom: 1px solid var(--border-color); padding-bottom: 24px; margin-bottom: 32px; }



/* ==========================================================================
   EXPLORE PAGE UI (DESKTOP & MOBILE FIXED)
   ========================================================================== */
.explore-main { width: 100%; box-sizing: border-box; padding: 40px 48px; max-width: 100%; overflow: hidden; }
.explore-section { margin-bottom: 40px; width: 100%; max-width: 100%; }
.explore-section .section-title { font-size: 14px; font-weight: 800; margin-bottom: 20px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-main); display: flex; align-items: center; gap: 8px; }

/* Circle Cards */
.circle-card { border: 1px solid var(--border-color); padding: 16px; text-align: center; background: #fff; transition: 0.2s; display: block; text-decoration: none; color: inherit; border-radius: 6px; overflow: hidden; }
.circle-card:hover { border-color: var(--brand-orange); box-shadow: 0 4px 12px rgba(193, 56, 19, 0.05); transform: translateY(-2px); }
.circle-card img { width: 56px; height: 56px; border-radius: 8px; margin-bottom: 12px; object-fit: cover; }
.circle-card h3 { font-size: 14px; font-weight: 800; margin-bottom: 4px; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.circle-card p { font-size: 12px; color: var(--text-muted); margin: 0; }

/* User Cards */
.user-card { border: 1px solid var(--border-color); padding: 12px; display: flex; align-items: center; gap: 12px; background: #fff; text-decoration: none; color: inherit; transition: 0.2s; border-radius: 6px; overflow: hidden; }
.user-card:hover { border-color: var(--brand-orange); background: #fbfbfb; transform: translateY(-2px); }
.user-card img { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; background: #fff; flex-shrink: 0; }
.user-card-info { overflow: hidden; flex: 1; min-width: 0; /* CRITICAL: Prevents flex children from breaking screen width */ }
.user-card h3 { font-size: 13px; font-weight: 800; margin: 0 0 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }
.user-card p { font-size: 11px; color: var(--text-muted); font-weight: 600; margin: 0; text-transform: uppercase;}

/* Topic Rows */
.topic-row { display: flex; align-items: center; padding: 12px 16px; border: 1px solid var(--border-color); background: #fff; margin-bottom: 8px; border-radius: 6px; text-decoration: none; color: inherit; transition: 0.2s; gap: 16px; overflow: hidden; }
.topic-row:hover { border-color: var(--brand-orange); transform: translateX(4px); }
.topic-number { font-size: 18px; font-weight: 800; color: #d1d1d1; width: 24px; text-align: center; flex-shrink: 0; }
.topic-content { overflow: hidden; flex: 1; min-width: 0; /* CRITICAL */ }
.topic-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-meta { font-size: 11px; color: var(--text-muted); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}

/* =======================================================
   STRICT DESKTOP GRID (Over 768px)
   Forces cards to wrap to the next line. Kills scrollbar.
   ======================================================= */
@media (min-width: 769px) {
    .horizontal-scroll-mobile {
        display: grid !important; 
        /* auto-fit stretches cards slightly to fill empty space perfectly */
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important; 
        gap: 16px !important;
        width: 100% !important;
        overflow-x: hidden !important; 
        flex-wrap: wrap !important; 
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .horizontal-scroll-mobile.user-grid {
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) !important; 
    }
}

/* =======================================================
   STRICT MOBILE SWIPE (Under 768px)
   Turns grids into native-app swipeable rows.
   ======================================================= */
@media (max-width: 768px) {
    .explore-main { padding: 16px !important; }
    
    .horizontal-scroll-mobile {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 12px !important;
        padding-bottom: 16px !important; 
        margin: 0 -16px !important; 
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    .horizontal-scroll-mobile .circle-card { flex: 0 0 140px !important; }
    .horizontal-scroll-mobile .user-card { flex: 0 0 200px !important; }
}


/* ==========================================================================
   SINGLE THREAD DESKTOP FIXES (Forces vertical stacking, kills flex columns)
   ========================================================================== */
.single-post-container { display: block !important; width: 100%; }
.single-post-header { margin-bottom: 32px; }
.single-title { font-size: 32px; font-weight: 800; margin-bottom: 16px; line-height: 1.2; color: var(--text-main); letter-spacing: -0.5px; }

/* Desktop alignment for the Meta Row */
.single-meta-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.single-meta-info-stack { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 14px; }
.single-author-container { display: flex; align-items: center; gap: 6px; }
.single-author-avatar { width: 24px; height: 24px; border-radius: 4px; object-fit: cover; }
.single-author-link { color: var(--brand-orange); font-weight: 700; text-decoration: none; }

/* ==========================================================================
   FINAL MOBILE RESPONSIVENESS (Max Width: 768px)
   ========================================================================== */

@media (max-width: 768px) {
    /* --- CORE FIXES --- */
    body, html { overflow-x: hidden !important; width: 100% !important; margin: 0; padding: 0; }
    * { box-sizing: border-box !important; }

    /* Shatter ALL grids site-wide */
    .layout-grid, .circle-content-grid, .profile-layout, .explore-grid { 
        display: flex !important; flex-direction: column !important; width: 100% !important; 
    }

    /* --- 1. NAVBAR & SEARCH BAR --- */
    #mobileMenuBtn { display: block !important; }
    .mobile-only-links { display: flex !important; } 
    
    .navbar { padding: 12px 16px !important; height: auto !important; display: flex !important; flex-wrap: wrap !important; align-items: center !important; }
    .nav-brand { margin-right: auto !important; }
    .nav-links { display: none !important; } 
    
    .search-container { order: 3 !important; flex: 0 0 100% !important; width: 100% !important; margin: 12px 0 0 0 !important; }

    /* --- 2. ACTION BUTTONS (STRICT SINGLE LINE) --- */
    .mobile-hide-text { display: none !important; } 
    
    .thread-block { padding: 16px !important; border-radius: 0 !important; border-left: none !important; border-right: none !important; }
    
    .thread-action-bar { 
        display: flex !important; 
        flex-wrap: nowrap !important; /* CRITICAL: Absolutely forbids wrapping to a 2nd line */
        justify-content: space-between !important; 
        align-items: center !important; 
        padding-top: 12px !important; 
        padding-bottom: 0 !important; 
        width: 100% !important;
    }
    
    .action-group-left { 
        display: flex !important; 
        flex-wrap: nowrap !important; /* CRITICAL */
        align-items: center !important;
        gap: 6px !important; /* Slightly tighter gap to ensure fit */
    }
    
    .action-btn-box, .action-btn-text { 
        white-space: nowrap !important; /* Prevents text inside buttons from breaking */
        flex-shrink: 0 !important; /* Prevents buttons from getting crushed */
        display: flex !important;
        align-items: center !important;
    }
    
    .action-btn-box { 
        padding: 6px 10px !important; 
        font-size: 11px !important; 
        font-weight: 700 !important; 
    }
    
    .action-btn-text { 
        padding: 6px 4px !important; /* Tighter padding since it's just icons now */
        font-size: 13px !important; 
    }

    /* --- 3. SINGLE THREAD FIXES --- */
    .single-main-feed { padding: 16px !important; }
    .single-breadcrumbs { margin-bottom: 24px !important; gap: 8px !important; }
    .breadcrumb-sep { color: var(--border-color) !important; font-size: 11px !important; }
    
    .single-title { font-size: 24px !important; line-height: 1.2 !important; margin-bottom: 12px !important; letter-spacing: -0.5px !important;}
    .single-meta-row { display: flex !important; flex-direction: column !important; align-items: flex-start !important; gap: 8px !important; margin-bottom: 24px !important; }
    .single-meta-info-stack { display: flex !important; flex-wrap: wrap !important; align-items: center !important; gap: 6px 10px !important; font-size: 13px !important; color: var(--text-muted) !important; width: 100% !important; overflow: hidden !important; }
    .single-author-container { display: flex !important; align-items: center !important; gap: 6px !important; }
    .single-author-avatar { width: 24px !important; height: 24px !important; flex-shrink: 0 !important; }
    
    .single-author-link { display: block !important; max-width: 130px !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; color: var(--brand-orange) !important; font-weight: 700 !important; }
    .single-meta-sep { display: none !important; }
    .quill-content { max-width: 100% !important; overflow-x: hidden !important; }
    .quill-content p, .quill-content img { max-width: 100% !important; height: auto !important; }

    /* --- 4. PROFILE HEADER FIXES --- */
    .profile-main { padding: 16px !important; margin: 0 !important; }
    .profile-header { flex-direction: column !important; align-items: center !important; text-align: center !important; gap: 20px !important; margin-bottom: 32px !important; }
    .profile-identity { flex-direction: column !important; align-items: center !important; gap: 16px !important; margin-bottom: 0 !important; }
    .profile-avatar { width: 80px !important; height: 80px !important; margin: 0 !important; }
    .profile-display-name { font-size: 24px !important; line-height: 1.2 !important; font-weight: 800 !important; margin-bottom: 2px !important; letter-spacing: -0.5px !important; color: var(--text-main) !important; }
    .profile-handle { font-size: 14px !important; color: var(--text-muted) !important; }
    .profile-actions { width: 100% !important; display: flex !important; justify-content: center !important;}
    .profile-header .btn-primary { width: 100% !important; max-width: 300px !important; text-align: center !important; justify-content: center !important; padding: 12px 24px !important; }
    .profile-tabs { justify-content: center !important; gap: 24px !important; width: 100% !important;}

    /* --- 5. GLOBAL FEED POLISH --- */
    .main-feed, .circle-main-feed { width: 100% !important; padding: 16px !important; margin: 0 !important; box-sizing: border-box !important; }
    
    /* --- 6. EXPLORE HORIZONTAL SWIPE --- */
    .horizontal-scroll-mobile { display: flex !important; flex-wrap: nowrap !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; gap: 12px !important; padding-bottom: 16px !important; margin: 0 -16px !important; padding-left: 16px !important; padding-right: 16px !important; }
    .horizontal-scroll-mobile .circle-card { flex: 0 0 140px !important; }
    .horizontal-scroll-mobile .user-card { flex: 0 0 200px !important; }

    /* --- 7. HAMBURGER MENU & SIDEBARS --- */
    .sidebar-left { position: fixed !important; top: 0 !important; left: -320px !important; width: 280px !important; height: 100vh !important; background: #fff !important; z-index: 2000 !important; padding: 24px 16px !important; box-shadow: 4px 0 24px rgba(0,0,0,0.2) !important; transition: left 0.3s ease-in-out !important; overflow-y: auto !important; }
    .sidebar-left.mobile-open { left: 0 !important; }
    aside:not(.sidebar-left), .circle-sidebar, .profile-sidebar { width: 100% !important; position: static !important; display: block !important; margin: 24px 0 0 0 !important; padding: 16px !important; border-left: none !important; border-top: 1px solid var(--border-color) !important; }
}