/* css/styles.css - Full working version with light/dark themes, social layout + redesigned profile */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent: #6366f1;
    --accent-dark: #4f46e5;
    --border: #e2e8f0;
    --card-bg: #ffffff;
    --error: #ef4444;
    --success: #10b981;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #818cf8;
    --accent-dark: #6366f1;
    --border: #334155;
    --card-bg: #1e293b;
    --error: #fca5a5;
    --success: #86efac;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    transition: background 0.3s, color 0.3s;
}

/* Top bar (used on both index and profile) */
.top-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.8rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo a {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.4rem;
}

.avatar-link {
    text-decoration: none;
}

.avatar-placeholder {
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Main layout grid (index.php logged-in view) */
.main-layout {
    display: grid;
    grid-template-columns: 240px 1fr 300px;
    gap: 1.5rem;
    padding: 1.5rem 1rem;
    max-width: 1300px;
    margin: 0 auto;
}

@media (max-width: 1024px) {
    .main-layout { grid-template-columns: 200px 1fr; }
    .right-sidebar { display: none; }
}

@media (max-width: 768px) {
    .main-layout { grid-template-columns: 1fr; padding: 1rem 0.8rem; }
    .left-sidebar { display: none; }
}

/* Sidebar navigation */
.left-sidebar {
    position: sticky;
    top: 70px;
    height: fit-content;
}

.nav-item {
    display: block;
    padding: 0.9rem 1.2rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background: rgba(99,102,241,0.1);
    color: var(--accent);
}

/* Feed / post area */
.feed-area { min-width: 0; }

.composer-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1.5rem;
}

.composer-card textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
    font-size: 1rem;
}

.composer-actions {
    margin-top: 0.8rem;
    text-align: right;
}

.composer-actions button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.6rem 1.4rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.composer-actions button:hover {
    background: var(--accent-dark);
}

.post-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1rem;
}

.post-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.6rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.post-author {
    font-weight: 600;
    color: var(--accent);
}

.post-content {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Right sidebar */
.right-sidebar {
    position: sticky;
    top: 70px;
    height: fit-content;
}

.widget {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1.2rem;
}

.widget h3 {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
}

/* Auth card (not logged in) */
.auth-card {
    max-width: 420px;
    margin: 4rem auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 0.9rem;
    background: none;
    border: none;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

.tab.active {
    color: var(--accent);
    border-bottom: 3px solid var(--accent);
}

.auth-form {
    display: none;
}

.auth-form.active { display: block; }

.auth-form input {
    width: 100%;
    padding: 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.auth-form button {
    width: 100%;
    padding: 0.9rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.auth-form button:hover { background: var(--accent-dark); }

.alert {
    padding: 0.9rem;
    border-radius: 8px;
    margin-bottom: 1.2rem;
    text-align: center;
}

.alert.error { background: rgba(239,68,68,0.15); color: var(--error); border: 1px solid #fca5a5; }

/* Profile page styles */
.profile-container {
    max-width: 680px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.profile-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.8rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 1.5rem;
}

.avatar-large {
    width: 80px;
    height: 80px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: bold;
}

.profile-info h1 {
    font-size: 1.8rem;
    margin: 0;
    line-height: 1.2;
}

.join-date {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0.3rem 0 0;
}

.profile-stats {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    margin-bottom: 1.8rem;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 600;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.section-card {
    background: rgba(var(--accent-rgb, 99,102,241), 0.04);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.4rem;
}

.section-card h2 {
    font-size: 1.3rem;
    margin-bottom: 1.2rem;
    color: var(--accent);
}

.form-compact input {
    width: 100%;
    padding: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    font-size: 0.95rem;
}

.btn-primary {
    width: 100%;
    padding: 0.9rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.back-link {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.95rem;
}

.back-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.back-link a:hover {
    text-decoration: underline;
}

/* General utilities */
.alert.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid #6ee7b7;
}

.alert.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid #fca5a5;
}

/* Responsive tweaks */
@media (max-width: 768px) {
    .auth-card { margin: 2rem 1rem; padding: 1.5rem; }
    .profile-stats { flex-direction: column; gap: 1rem; }
}