@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) --- */
.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; font-weight: 600;}
.nav-item:hover { background-color: var(--bg-hover); }
.nav-item.active { font-weight: 800; }
.nav-icon { width: 26px; height: 26px; flex-shrink: 0; }
.logout-btn { color: var(--error); font-weight: 700; margin-top: 1rem; }
.logout-btn:hover { background-color: #fee2e2; color: #f4212e; }

/* Animated Theme Toggle */
.theme-switch-container { padding-left: 0.8rem; }
.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); transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1), background-color 0.3s; }
[data-theme="dark"] .switch-handle { transform: translateX(22px); background-color: var(--brand-color); }
.icon-sun, .icon-moon { width: 12px; height: 12px; position: absolute; transition: opacity 0.4s, transform 0.4s; }
.icon-sun { color: #f59e0b; opacity: 1; transform: rotate(0deg); }
.icon-moon { color: #000000; opacity: 0; transform: rotate(-90deg); }
[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(90deg); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0deg); }

/* --- Central Content (Profile) --- */
.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;
}

/* Profile Specifics */
.cover-photo {
    width: 100%;
    height: 200px;
    background: linear-gradient(136.8deg, #b9ffa0 0%, #348dff 100%);
}

.profile-header { padding: 0 1.5rem 1.5rem 1.5rem; border-bottom: 1px solid var(--border-line); }

.profile-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: -65px; 
}

.profile-avatar {
    width: 130px; height: 130px; border-radius: 50%;
    border: 4px solid var(--bg-app); background-color: #ecc2db;
    color: var(--bg-app); display: flex; align-items: center;
    justify-content: center; font-size: 3rem; font-weight: 800;
    position: relative; z-index: 2;
}

.profile-actions { margin-top: 75px; display: flex; gap: 0.8rem; }

/* Action Buttons */
.btn-outline, .btn-primary {
    padding: 0.5rem 1.2rem; border-radius: 2rem; font-weight: 700;
    font-size: 0.95rem; cursor: pointer; transition: all 0.2s;
}

.btn-outline { background-color: transparent; color: var(--text-primary); border: 1px solid var(--border-line); }
.btn-outline:hover { background-color: var(--bg-hover); }

.btn-primary { background-color: var(--brand-color); color: var(--bg-app); border: 1px solid var(--brand-color); }
.btn-primary:hover { background-color: var(--brand-hover); }

.profile-details { margin-top: 1rem; }

.profile-name { font-size: 1.5rem; font-weight: 800; line-height: 1.2; text-transform: capitalize; }
.profile-username { color: var(--text-muted); font-size: 1rem; margin-bottom: 1rem; font-weight: 500;}

/* Updated Bio to support line breaks */
.profile-bio { 
    font-size: 0.95rem; 
    line-height: 1.5; 
    margin-bottom: 1rem; 
    font-weight: 400;
    white-space: pre-wrap; 
    word-wrap: break-word;
}

/* Location Text Styling */
.profile-location {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-stats { display: flex; gap: 1.5rem; color: var(--text-muted); font-size: 0.95rem; }
.profile-stats strong { color: var(--text-primary); font-weight: 800; }

/* Updated Scrollable Profile Tabs */
.profile-tabs { 
    display: flex; 
    border-bottom: 1px solid var(--border-line); 
    overflow-x: auto; 
    scrollbar-width: none; 
}
.profile-tabs::-webkit-scrollbar { 
    display: none; 
}
.tab { 
    flex: 1; 
    min-width: 80px; 
    text-align: center; 
    padding: 1rem; 
    font-weight: 700; 
    color: var(--text-muted); 
    cursor: pointer; 
    transition: background 0.2s; 
    position: relative; 
    white-space: nowrap;
}
.tab:hover { background-color: var(--bg-hover); }
.tab.active { color: var(--text-primary); }
.tab.active::after { 
    content: ''; position: absolute; bottom: 0; left: 20%; right: 20%; 
    height: 4px; background-color: var(--brand-color); border-radius: 4px 4px 0 0; 
}

/* Feed Posts */
.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: 800; font-size: 1rem; }
.post-username, .post-time { color: var(--text-muted); font-size: 0.9rem; font-weight: 500;}
.post-content { font-size: 0.95rem; line-height: 1.4; color: var(--text-primary); margin-bottom: 0.8rem; word-wrap: break-word;}
.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;}

/* --- 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); font-weight: 500;}
.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 { font-size: 0.8rem; color: var(--text-muted); font-weight: 500;}
.trend-title { font-weight: 800; margin: 0.2rem 0; }

/* ==========================================
   MOBILE RESPONSIVENESS
   ========================================== */
@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;
    }
    
    .sidebar-bottom { display: none !important; }
    .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; }
    .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: flex; justify-content: space-between; align-items: center; }
    .mobile-top-bar h2 { font-weight: 800; letter-spacing: -1px; }
    .mobile-settings-btn { color: var(--text-primary); display: flex; align-items: center;}
    .mobile-settings-btn svg { width: 26px; height: 26px; }

    .modal-overlay { padding-bottom: 0; }
}

/* ==========================================
   MODALS: EDIT PROFILE & VERIFICATION INFO
   ========================================== */

/* Shared Modal Overlay Background */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000; display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

/* Shared Modal Content Box */
.modal-content {
    background-color: var(--bg-app); width: 90%; max-width: 550px;
    border-radius: 1rem; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    max-height: 90vh; overflow-y: auto; transform: translateY(20px);
    transition: transform 0.3s ease; margin: auto;
}
.modal-overlay.active .modal-content { transform: translateY(0); }

/* Header & Close Button */
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem; border-bottom: 1px solid var(--border-line);
    position: sticky; top: 0; background-color: var(--bg-app); z-index: 10;
}
.modal-header h2 { font-size: 1.25rem; font-weight: 800; }
.close-btn { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: var(--text-primary); line-height: 1; font-weight: 400;}

.modal-body { padding: 1.5rem; }

/* UPDATE: Sticky Footer for Edit Modal */
.modal-footer {
    position: sticky; 
    bottom: 0; 
    background-color: var(--bg-app); 
    padding: 1rem 1.5rem; 
    border-top: 1px solid var(--border-line); 
    z-index: 10;
}

/* Avatar Upload & 1:1 Preview */
.avatar-edit-container { display: flex; flex-direction: column; align-items: center; margin-bottom: 1.5rem; }
.avatar-preview-wrapper {
    width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--border-line);
    overflow: hidden; margin-bottom: 1rem; position: relative;
    background-color: var(--bg-hover); display: flex; align-items: center; justify-content: center;
}
.avatar-preview-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.upload-btn {
    background-color: var(--bg-hover); color: var(--text-primary); border: none;
    padding: 0.6rem 1.2rem; border-radius: 2rem; font-weight: 700; cursor: pointer; transition: background 0.2s;
}
.upload-btn:hover { background-color: var(--border-line); }

/* Form Inputs */
.form-group { margin-bottom: 1.2rem; display: flex; flex-direction: column; }
.form-group label { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.4rem; color: var(--text-muted); }
.form-group input, .form-group textarea, .form-group select {
    padding: 0.85rem; border: 1px solid var(--border-line); border-radius: 0.5rem;
    font-size: 1rem; background-color: transparent; color: var(--text-primary); transition: border-color 0.2s; font-weight: 500;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--brand-color); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group input:disabled { background-color: var(--bg-hover); color: var(--text-muted); cursor: not-allowed; opacity: 0.7; }

/* UPDATE: Removed margin-top from .save-btn so it sits perfectly in the footer */
.save-btn {
    width: 100%; padding: 1rem; background-color: var(--brand-color); color: var(--bg-app);
    border: none; border-radius: 2rem; font-weight: 800; font-size: 1rem;
    cursor: pointer; transition: background 0.2s; 
}
.save-btn:hover:not(:disabled) { background-color: var(--brand-hover); }
.save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- VERIFICATION BLUR MODAL SPECIFICS --- */
.blur-overlay {
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.verify-modal-content { text-align: center; max-width: 400px; padding: 2.5rem 1.5rem; }
#verify-modal-icon { display: flex; justify-content: center; margin-bottom: 1rem; }
#verify-modal-icon svg { width: 64px; height: 64px; }
#verify-modal-title { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); }
.verify-info-body p { font-size: 1rem; color: var(--text-primary); font-weight: 500;}
.verify-type-text { color: var(--text-muted) !important; margin-top: 1rem !important; font-size: 0.9rem !important; line-height: 1.5; padding: 0 1rem; }

/* ==========================================
   SEARCH DROPDOWN & FOLLOW LIST MODAL
   ========================================== */

/* Search Dropdown Styling */
.search-wrapper { position: relative; width: 100%; }
.search-dropdown {
    position: absolute; top: 100%; left: 0; width: 100%;
    background-color: var(--bg-app); border: 1px solid var(--border-line);
    border-radius: 1rem; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-top: 0.5rem; max-height: 300px; overflow-y: auto;
    z-index: 100; display: none;
}
.search-dropdown.active { display: block; }

/* Search Result Item (Card Style) */
.search-result-item {
    display: flex; align-items: center; gap: 10px; padding: 1rem;
    cursor: pointer; text-decoration: none; color: var(--text-primary);
    border-bottom: 1px solid var(--border-line); transition: background 0.2s;
    overflow-x: hidden; 
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background-color: var(--bg-hover); }

.search-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--brand-color); color: var(--bg-app); display: flex; align-items: center; justify-content: center; font-weight: bold; flex-shrink: 0; }
.search-info { display: flex; flex-direction: column; overflow: hidden;  }
.search-name { font-weight: 800; font-size: 1rem; display: flex; align-items: center; text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-username { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Clickable Stats */
.stat-link { cursor: pointer; transition: opacity 0.2s; }
.stat-link:hover { opacity: 0.7; }

/* ==========================================
   MODAL LISTS: SKELETONS & RESPONSIVE LAYOUT
   ========================================== */

#list-modal .modal-content {
    display: flex;
    flex-direction: column;
    height: 70vh; 
    max-height: 600px; 
    padding: 0; 
    overflow: hidden; 
}

/* Fix mobile modal height and bottom nav intersection */
@media (max-width: 768px) {
    #list-modal .modal-content {
        height: 75vh; 
        margin-bottom: 80px; 
    }
}

#list-modal .modal-header {
    padding: 1rem 1.5rem;
    flex-shrink: 0;
}

#list-modal .modal-body {
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden; 
    padding: 0;
}

#list-modal-container {
    display: flex;
    flex-direction: column;
    min-height: 100%; 
    padding-bottom: 20px;
}

/* Perfect Horizontal and Vertical Centering for Empty List Text */
.empty-list-msg {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-weight: 600;
    min-height: 250px; 
}

/* Inline Follow Button inside the list */
.btn-list-follow {
    margin-left: auto;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 2rem;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
    flex-shrink: 0; 
}

/* --- Shimmer Skeleton Loader --- */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.skeleton {
    background: var(--bg-hover);
    background-image: linear-gradient(90deg, var(--bg-hover) 0px, var(--border-line) 40px, var(--bg-hover) 80px);
    background-size: 1000px 100%;
    animation: shimmer 1.5s infinite linear forwards;
    border-radius: 4px;
}

.skeleton-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;}
.skeleton-text { height: 14px; margin-bottom: 8px; width: 120px; border-radius: 4px;}
.skeleton-text.short { width: 80px; }

/* Unread Navbar Badge */
.nav-item { position: relative; }
.nav-unread-badge {
    position: absolute; top: 4px; left: 24px; background-color: var(--error); color: #fff;
    font-size: 0.7rem; font-weight: 800; min-width: 18px; height: 18px; border-radius: 50px;
    display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg-app);
    padding: 0 4px; box-sizing: border-box;
}
@media (max-width: 768px) {
    .nav-unread-badge { top: 2px; left: 50%; margin-left: 2px; }
}