:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #475569;
    --danger: #ef4444;
    --success: #22c55e;
    --glass-blur: blur(12px);
    --sidebar-width: 260px;
    --right-sidebar-width: 300px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(0, 0, 0, 0.05);
    --text-main: #0f172a;
    --text-muted: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
    background-attachment: fixed;
}

/* Glassmorphism Utilities */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--card-border);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 40px;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
}

.nav-links li i {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.nav-links li:hover, .nav-links li.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    transform: translateX(5px);
}

.user-mini-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: var(--transition);
}

.user-mini-profile:hover {
    background: rgba(59, 130, 246, 0.05);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info h4 {
    font-size: 14px;
    margin-bottom: 2px;
}

.user-info p {
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    margin-right: var(--right-sidebar-width);
    padding: 24px;
    min-height: 100vh;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    position: sticky;
    top: 24px;
    z-index: 90;
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    padding: 12px 24px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
}

.search-bar {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 10px 16px;
    border-radius: 20px;
    width: 300px;
    gap: 12px;
    border: 1px solid var(--card-border);
}
[data-theme="light"] .search-bar { background: rgba(0,0,0,0.05); }

.search-bar input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-main);
    width: 100%;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.action-btn:hover {
    transform: scale(1.05);
    background: var(--primary);
}

/* Right Sidebar */
.right-sidebar {
    width: var(--right-sidebar-width);
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-left: 1px solid var(--card-border);
    overflow-y: auto;
}

.right-sidebar::-webkit-scrollbar { width: 4px; }
.right-sidebar::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 4px; }

.right-sidebar h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.trending-section, .suggestions-section {
    padding: 20px;
}

.trend-item {
    margin-bottom: 16px;
    cursor: pointer;
}
.trend-item:last-child { margin-bottom: 0; }

.trend-tag {
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
}

.trend-item p {
    font-size: 14px;
    font-weight: 500;
    margin: 4px 0;
}

.trend-item small {
    color: var(--text-muted);
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.suggestion-item:last-child { margin-bottom: 0; }
.suggestion-item img {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}
.btn-secondary {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
}
.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--card-border);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-outline:hover { background: rgba(255,255,255,0.1); }

/* --- VIEWS --- */
.view-container {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Feed View */
.create-post {
    padding: 20px;
    margin-bottom: 24px;
}

.post-input-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.post-input-wrapper input {
    flex: 1;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--card-border);
    padding: 12px 20px;
    border-radius: 24px;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}
[data-theme="light"] .post-input-wrapper input { background: rgba(0,0,0,0.05); }

.post-input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.post-actions {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--card-border);
    padding-top: 16px;
}

.post-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: var(--transition);
}

.post-actions button:hover:not(.btn-primary) {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
}
.post-actions .btn-primary { color: white; }

.post {
    margin-bottom: 24px;
    padding: 20px;
}

.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.post-header img { width: 44px; height: 44px; border-radius: 50%; }
.post-user-info h4 { font-size: 15px; }
.post-user-info span { font-size: 12px; color: var(--text-muted); }
.more-btn { margin-left: auto; background: none; border: none; color: var(--text-muted); cursor: pointer; }

.post-content p { margin-bottom: 16px; line-height: 1.5; }
.post-image { width: 100%; border-radius: 12px; max-height: 500px; object-fit: cover; }

.post-stats {
    display: flex;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.post-footer {
    display: flex;
    justify-content: space-between;
}
.post-footer button {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.post-footer button:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }

/* Profile View */
.profile-header {
    overflow: hidden;
    margin-bottom: 24px;
}

.cover-photo {
    height: 250px;
    position: relative;
}
.cover-photo img { width: 100%; height: 100%; object-fit: cover; }
.edit-cover-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    cursor: pointer;
    transition: var(--transition);
    z-index: 2;
}
.edit-cover-btn:hover { background: rgba(0,0,0,0.8); }

.profile-details {
    padding: 0 24px 24px;
    display: flex;
    align-items: flex-end;
    margin-top: -60px;
    position: relative;
    gap: 24px;
}

.profile-picture-container {
    position: relative;
    width: 140px;
    height: 140px;
}
.profile-picture {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid var(--bg-color);
    object-fit: cover;
    background: var(--card-bg);
}
.upload-btn {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid var(--bg-color);
    transition: var(--transition);
}
.upload-btn:hover { background: var(--primary-hover); transform: scale(1.1); }

.profile-meta { flex: 1; padding-bottom: 10px; }
.profile-meta h2 { font-size: 28px; margin-bottom: 4px; }
.profile-meta .bio { color: var(--text-muted); margin-bottom: 12px; }

.profile-stats {
    display: flex;
    gap: 16px;
}
.profile-stats span { color: var(--text-muted); }
.profile-stats strong { color: var(--text-main); }

.profile-actions { padding-bottom: 10px; display: flex; gap: 12px; }

.profile-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
}

.about-card { padding: 20px; height: fit-content; }
.about-card h3 { margin-bottom: 16px; }
.about-card ul { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.about-card li { display: flex; align-items: center; gap: 12px; color: var(--text-muted); }
.about-card li i { width: 20px; text-align: center; color: var(--primary); }
.about-card a { color: var(--primary); text-decoration: none; }

/* Pages View */
.flex-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.page-card { overflow: hidden; transition: var(--transition); }
.page-card:hover { transform: translateY(-5px); }
.page-cover { width: 100%; height: 120px; object-fit: cover; }
.page-info { padding: 0 20px 20px; text-align: center; position: relative; margin-top: -30px; }
.page-icon { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--card-bg); margin-bottom: 12px; background: #fff;}
.page-info h3 { font-size: 18px; margin-bottom: 4px; }
.page-info p { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }
.page-info button { width: 100%; }

/* Chat View */
.chat-view {
    display: flex;
    height: calc(100vh - 120px);
    overflow: hidden;
    padding: 0;
}
.chat-sidebar {
    width: 320px;
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
}
.chat-search { padding: 16px; border-bottom: 1px solid var(--card-border); }
.chat-search input {
    width: 100%; padding: 10px 16px; border-radius: 20px;
    background: rgba(0,0,0,0.2); border: 1px solid var(--card-border);
    color: var(--text-main); outline: none;
}
[data-theme="light"] .chat-search input { background: rgba(0,0,0,0.05); }

.chat-list { list-style: none; overflow-y: auto; flex: 1; }
.chat-list-item {
    display: flex; align-items: center; gap: 12px; padding: 16px;
    cursor: pointer; border-bottom: 1px solid var(--card-border);
    transition: var(--transition); position: relative;
}
.chat-list-item:hover, .chat-list-item.active { background: rgba(59, 130, 246, 0.1); }
.chat-list-item img { width: 48px; height: 48px; border-radius: 50%; }
.chat-preview { flex: 1; overflow: hidden; }
.chat-preview h4 { font-size: 15px; margin-bottom: 4px; }
.chat-preview p { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--text-muted); position: absolute; top: 16px; right: 16px; }

.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-header {
    padding: 16px 24px; border-bottom: 1px solid var(--card-border);
    display: flex; align-items: center; gap: 16px;
}
.chat-header img { width: 40px; height: 40px; border-radius: 50%; }
.status.online { color: var(--success); font-size: 12px; display: flex; align-items: center; gap: 4px; }
.status.online::before { content: ''; width: 8px; height: 8px; background: var(--success); border-radius: 50%; display: inline-block; }
.chat-actions { margin-left: auto; display: flex; gap: 12px; }
.chat-actions button { background: none; border: none; color: var(--primary); font-size: 18px; cursor: pointer; padding: 8px; border-radius: 50%; transition: var(--transition); }
.chat-actions button:hover { background: rgba(59, 130, 246, 0.1); }

.chat-messages {
    flex: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
}
.message { max-width: 70%; padding: 12px 16px; border-radius: 16px; position: relative; }
.message.received { background: var(--card-bg); border: 1px solid var(--card-border); align-self: flex-start; border-bottom-left-radius: 4px; }
.message.sent { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-time { font-size: 10px; opacity: 0.7; margin-top: 4px; display: block; text-align: right; }

.chat-input-area {
    padding: 16px 24px; border-top: 1px solid var(--card-border);
    display: flex; align-items: center; gap: 12px;
}
.chat-input-area button { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; transition: var(--transition); }
.chat-input-area button:hover { color: var(--primary); }
.chat-input-area input {
    flex: 1; background: rgba(0,0,0,0.2); border: 1px solid var(--card-border);
    padding: 12px 20px; border-radius: 24px; color: var(--text-main); outline: none;
}
[data-theme="light"] .chat-input-area input { background: rgba(0,0,0,0.05); }
.chat-input-area .send-btn { color: var(--primary); }

/* Marketplace View */
.market-categories { display: flex; gap: 12px; margin-bottom: 24px; overflow-x: auto; padding-bottom: 8px; }
.market-categories button {
    padding: 8px 16px; border-radius: 20px; background: var(--card-bg); border: 1px solid var(--card-border);
    color: var(--text-main); cursor: pointer; white-space: nowrap; transition: var(--transition);
}
.market-categories button.active, .market-categories button:hover { background: var(--primary); color: white; border-color: var(--primary); }

.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
.market-item { overflow: hidden; transition: var(--transition); cursor: pointer; }
.market-item:hover { transform: translateY(-5px); box-shadow: 0 12px 40px rgba(0,0,0,0.2); }
.market-item img { width: 100%; height: 200px; object-fit: cover; }
.item-details { padding: 16px; }
.item-details h4 { font-size: 16px; margin-bottom: 8px; }
.item-details .price { font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.item-details .location { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.item-details .location::before { content: '\f3c5'; font-family: 'Font Awesome 6 Free'; font-weight: 900; }

/* Terms View */
.terms-view { padding: 40px; max-width: 800px; margin: 0 auto; }
.terms-view h2 { margin-bottom: 24px; color: var(--primary); font-size: 28px; }
.terms-content h3 { margin-top: 24px; margin-bottom: 12px; color: var(--text-main); font-size: 18px; }
.terms-content p { color: var(--text-muted); line-height: 1.6; margin-bottom: 16px; }

/* Friends View */
.friends-view {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

/* Logout Button */
.logout-btn {
    margin-top: auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--danger);
    font-weight: 500;
    cursor: pointer;
    border-radius: 12px;
    transition: var(--transition);
}
.logout-btn i { font-size: 20px; width: 24px; text-align: center; }
.logout-btn:hover { background: rgba(239, 68, 68, 0.1); transform: translateX(5px); }

/* --- AUTH (LOGIN/SIGNUP) STYLES --- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-container {
    display: flex;
    width: 100%;
    max-width: 1000px;
    min-height: 600px;
    overflow: hidden;
    padding: 0;
}

.auth-branding {
    flex: 1;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.8), rgba(139, 92, 246, 0.8));
    padding: 60px 40px;
    color: white;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.auth-logo { margin-bottom: auto; text-shadow: none; color: white; }
.auth-branding h2 { font-size: 36px; line-height: 1.2; margin-bottom: 16px; font-weight: 700; z-index: 2; }
.auth-branding p { font-size: 16px; opacity: 0.9; line-height: 1.5; z-index: 2; }

/* Decorative abstract shapes */
.shape { position: absolute; border-radius: 50%; filter: blur(40px); z-index: 1; }
.shape-1 { width: 300px; height: 300px; background: #60a5fa; top: -100px; left: -100px; opacity: 0.5; }
.shape-2 { width: 400px; height: 400px; background: #c084fc; bottom: -150px; right: -100px; opacity: 0.5; }
.shape-3 { width: 200px; height: 200px; background: #34d399; top: 40%; left: 20%; opacity: 0.3; }

.auth-form-wrapper {
    flex: 1;
    padding: 60px 40px;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.auth-form { width: 100%; max-width: 360px; transition: opacity 0.3s ease; }
.auth-form.hidden { display: none; opacity: 0; }
.auth-form h3 { font-size: 28px; margin-bottom: 8px; color: var(--text-main); }
.auth-subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }

.input-group {
    position: relative;
    margin-bottom: 20px;
}
.input-group i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.input-group input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--card-border);
    padding: 14px 16px 14px 44px;
    border-radius: 12px;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}
[data-theme="light"] .input-group input { background: rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.1); }
.input-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }

.auth-options { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; font-size: 13px; color: var(--text-muted); }
.auth-options label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.forgot-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.forgot-link:hover { text-decoration: underline; }

.auth-submit { width: 100%; padding: 14px; font-size: 16px; border-radius: 12px; margin-bottom: 24px; }

.auth-switch { text-align: center; color: var(--text-muted); font-size: 14px; }
.auth-switch span { color: var(--primary); font-weight: 600; cursor: pointer; transition: var(--transition); }
.auth-switch span:hover { text-decoration: underline; }

/* Responsive adjustments */
@media (max-width: 1200px) {
    .right-sidebar { display: none; }
    .main-content { margin-right: 0; }
}

@media (max-width: 900px) {
    .sidebar { width: 80px; padding: 24px 12px; }
    .logo span, .nav-links span, .user-info { display: none; }
    .logo { justify-content: center; margin-bottom: 40px; }
    .nav-links li { justify-content: center; padding: 14px; }
    .user-mini-profile { padding: 8px; justify-content: center; }
    .main-content { margin-left: 80px; }
    .search-bar { width: 200px; }
    .profile-content { grid-template-columns: 1fr; }
}
