/* ===== Reset & variables ===== */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg:      #fafafa;
    --surface: #ffffff;
    --border:  #e2e2e2;
    --text:    #1a1a1a;
    --muted:   #6b6b6b;
    --primary: #1a1a1a;
    --primary-hover: #333333;
    --error:   #c0392b;
    --success: #27ae60;
    --radius:  8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    line-height: 1.6;
    font-size: 16px;
}

a { color: var(--text); }

/* ===== Header ===== */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.nav a { text-decoration: none; }

.nav-user { color: var(--muted); }

/* ===== Boutons ===== */
.btn-primary {
    background: var(--primary);
    color: #fff !important;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius);
    font-weight: 500;
    text-decoration: none !important;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text);
    text-decoration: underline;
}

.btn-submit {
    display: block;
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-submit:hover { background: var(--primary-hover); }

.logout-form { display: inline; }

/* ===== Flash messages ===== */
.flash-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 480px;
    margin: 1rem auto 0;
    padding: 0 1rem;
}

.flash {
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.flash--error   { background: #fce8e6; color: var(--error);   border: 1px solid #f5c6c2; }
.flash--success { background: #e6f4ea; color: var(--success); border: 1px solid #b7dfbe; }
.flash--info    { background: #e8f0fe; color: #1967d2;        border: 1px solid #c3d5fc; }

/* ===== Main ===== */
.main {
    max-width: 480px;
    margin: 0 auto;
    padding: 1rem;
}

/* ===== Formulaires ===== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 1rem;
    background: var(--surface);
    transition: border-color 0.15s;
    width: 100%;
}
.form-group input:focus {
    outline: none;
    border-color: var(--text);
}

.form-group small {
    font-size: 0.8rem;
    color: var(--muted);
}

/* ===== Auth box ===== */
.auth-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-top: 2rem;
}

.auth-box h1 {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--muted);
}

/* ===== Feed placeholder ===== */
.feed-placeholder {
    padding: 2rem 0;
}

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

/* ===== Page d'erreur ===== */
.error-box {
    text-align: center;
    padding: 4rem 0;
}

.error-box h1 {
    font-size: 5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    letter-spacing: -0.04em;
}

/* ===== Page profil ===== */
.profile-page { padding: 1rem 0; }

.profile-header {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.profile-avatar-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.profile-avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
    user-select: none;
}

.profile-info { flex: 1; min-width: 0; }

.profile-username {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.2rem;
}

.profile-display-name {
    font-size: 0.95rem;
    color: var(--muted);
    margin: 0 0 0.4rem;
}

.profile-bio {
    font-size: 0.9rem;
    margin: 0 0 0.6rem;
    word-break: break-word;
}

.profile-stat {
    font-size: 0.9rem;
    color: var(--muted);
    margin: 0 0 0.75rem;
}

.btn-outline {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}
.btn-outline:hover { border-color: var(--text); }

.profile-empty {
    text-align: center;
    color: var(--muted);
    padding: 2rem 0;
    font-size: 0.9rem;
}

/* Grille de posts */
.post-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
    margin-top: 0.5rem;
}

.post-grid-item {
    overflow: hidden;
    border-radius: 4px;
    background: var(--border);
}

.post-grid-item img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
    .main            { padding: 2rem 1rem; }
    .flash-container { padding: 0 1rem; }
    .post-grid       { grid-template-columns: repeat(3, 1fr); }
}
