/* ── Tokens ──────────────────────────────────────────────────────── */
:root {
  --sidebar-bg:          #1D2A3F;
  --sidebar-hover:       #263550;
  --sidebar-active:      #2E4268;
  --sidebar-border:      #141E2E;
  --sidebar-accent:      #6FAEE0;
  --sidebar-text:        #C4D8F0;
  --sidebar-text-active: #FFFFFF;
  --sidebar-text-muted:  #7090B0;

  --body-bg:      #ECF0F6;
  --surface:      #FFFFFF;
  --surface-2:    #F4F6FA;
  --border:       #D2DCEA;
  --border-light: #E2EAF4;

  --text-primary:   #18243A;
  --text-secondary: #485878;
  --text-muted:     #7888A4;

  --accent:       #2E6DC4;
  --accent-light: #E6F0FB;
  --accent-hover: #2458A8;

  --tag-orange-bg:   #FEF1E8; --tag-orange-text: #B85810;
  --tag-blue-bg:     #E6F0FB; --tag-blue-text:   #2058A8;
  --tag-green-bg:    #E8F5EE; --tag-green-text:  #1E7A48;
  --tag-yellow-bg:   #FEF9E7; --tag-yellow-text: #9A6F00;
  --tag-purple-bg:   #F3EEFE; --tag-purple-text: #6B3FA0;
  --tag-teal-bg:     #E6F5F5; --tag-teal-text:   #1A7A78;
  --tag-red-bg:      #FDECEA; --tag-red-text:    #C0392B;

  --sidebar-w: 240px;
  --topbar-h:  56px;
  --pinned-w:  268px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --body-bg: #101826; --surface: #18243A; --surface-2: #1E2C44;
    --border: #253650; --border-light: #1E2E48;
    --text-primary: #CCD8EC; --text-secondary: #7898B8; --text-muted: #485E78;
    --accent: #5A9AE0; --accent-light: #162038; --accent-hover: #6AAAE8;
  }
}

/* ── Reset & base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-header { padding: 22px 18px 18px; border-bottom: 1px solid var(--sidebar-border); }

.logo-mark {
  width: 36px; height: 36px;
  background: var(--sidebar-accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 11px;
}

.logo-name { color: #fff; font-size: 13px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.logo-sub  { color: var(--sidebar-text-muted); font-size: 10.5px; font-weight: 500; margin-top: 3px; letter-spacing: 0.06em; text-transform: uppercase; }

.nav { flex: 1; padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.nav-label { color: var(--sidebar-text-muted); font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; padding: 10px 10px 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 5px;
  color: var(--sidebar-text); font-size: 13px; font-weight: 500;
  transition: background 0.1s, color 0.1s;
  position: relative; user-select: none;
}
.nav-item:hover                    { background: var(--sidebar-hover); color: #fff; }
.nav-item.active                   { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.nav-item.active::after            { content: ''; position: absolute; left: 0; top: 5px; bottom: 5px; width: 3px; background: var(--sidebar-accent); border-radius: 0 3px 3px 0; }
.nav-item.soon                     { opacity: 0.4; pointer-events: none; }
.nav-icon                          { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-icon,
.nav-item:hover  .nav-icon         { opacity: 1; }
.nav-divider                       { height: 1px; background: var(--sidebar-border); margin: 6px 0; }
.soon-badge                        { margin-left: auto; font-size: 9px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; background: rgba(255,255,255,0.08); color: var(--sidebar-text-muted); padding: 2px 6px; border-radius: 3px; }

.sidebar-footer { padding: 13px 15px; border-top: 1px solid var(--sidebar-border); display: flex; align-items: center; gap: 10px; }
.footer-text    { flex: 1; min-width: 0; }
.footer-name    { color: var(--sidebar-text); font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-role    { color: var(--sidebar-text-muted); font-size: 10.5px; margin-top: 1px; }

/* ── Avatar ──────────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; flex-shrink: 0;
  letter-spacing: -0.01em;
}
.av-xs   { width: 24px; height: 24px; font-size: 9px; }
.av-sm   { width: 32px; height: 32px; font-size: 11px; }
.av-md   { width: 36px; height: 36px; font-size: 12px; }
.av-pin  { width: 26px; height: 26px; font-size: 10px; }

/* Avatar color classes — assignées par index utilisateur */
.av-c0 { background: #4A80C0; }
.av-c1 { background: #607898; }
.av-c2 { background: #3A8898; }
.av-c3 { background: #3A5888; }
.av-c4 { background: #6A4898; }
.av-c5 { background: #3A7858; }

/* ── Main area ───────────────────────────────────────────────────── */
.main    { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* Standard page container — use in every module's {% block content %} inner div */
.page-body { width: 100%; max-width: 1160px; margin: 0 auto; padding: 24px 28px 60px; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; flex-shrink: 0; gap: 16px;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.02em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; border: none; transition: background 0.1s, filter 0.1s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-sm      { padding: 5px 10px; font-size: 12px; }

/* ── Two-column content ──────────────────────────────────────────── */
.content  { flex: 1; overflow: hidden; display: flex; min-height: 0; }
.feed-col { flex: 1; overflow-y: auto; padding: 22px 20px 22px 26px; min-width: 0; }
.feed     { display: flex; flex-direction: column; gap: 12px; }

/* ── Pinned column ───────────────────────────────────────────────── */
.pinned-col {
  width: var(--pinned-w); flex-shrink: 0;
  overflow-y: auto; border-left: 1px solid var(--border);
  padding: 20px 16px; background: var(--surface-2);
}

.pinned-header {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.07em; text-transform: uppercase;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.pinned-count { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }

.pinned-empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 28px 8px; line-height: 1.7; }

.pinned-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 6px;
  padding: 10px 11px; margin-bottom: 8px;
  position: relative; cursor: pointer;
  transition: box-shadow 0.1s;
}
.pinned-card:hover { box-shadow: 0 1px 6px rgba(46,109,196,0.12); }
.pinned-card-head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.pinned-meta      { flex: 1; min-width: 0; }
.pinned-author    { font-size: 11.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinned-date      { font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }
.pinned-title     { font-size: 12px; font-weight: 600; color: var(--text-primary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.45; margin-bottom: 7px; letter-spacing: -0.01em; }
.pinned-foot      { display: flex; align-items: center; justify-content: space-between; }

.unpin-btn { display: flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 500; color: var(--text-muted); background: none; border: none; padding: 3px 6px; border-radius: 4px; opacity: 0; transition: opacity 0.1s, background 0.1s, color 0.1s; }
.pinned-card:hover .unpin-btn { opacity: 1; }
.unpin-btn:hover   { background: #FDECEA; color: #C0392B; }

/* ── Post card ───────────────────────────────────────────────────── */
.post-card           { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px; transition: box-shadow 0.2s; }
.post-card.is-pinned { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-light); }
.post-head           { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 12px; }
.post-meta           { flex: 1; }
.post-author         { font-size: 13px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.post-date           { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.post-title          { font-size: 14.5px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; line-height: 1.4; letter-spacing: -0.02em; }
.post-body           { font-size: 13px; color: var(--text-secondary); line-height: 1.65; margin-bottom: 14px; white-space: pre-wrap; }

.post-foot    { display: flex; align-items: center; gap: 8px; padding-top: 11px; border-top: 1px solid var(--border-light); }
.post-action  { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--text-muted); padding: 4px 7px; border-radius: 5px; border: none; background: none; transition: background 0.1s, color 0.1s; }
.post-action:hover         { background: var(--accent-light); color: var(--accent); }
.post-action.is-pinned-btn { color: var(--accent); }
.post-action.is-pinned-btn:hover { background: #FDECEA; color: #C0392B; }
.spacer { flex: 1; }

/* ── Tags ────────────────────────────────────────────────────────── */
.tag    { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 4px; letter-spacing: 0.01em; white-space: nowrap; display: inline-block; }
.tag-sm { font-size: 10px; padding: 2px 6px; }
.tag-orange { background: var(--tag-orange-bg); color: var(--tag-orange-text); }
.tag-blue   { background: var(--tag-blue-bg);   color: var(--tag-blue-text); }
.tag-green  { background: var(--tag-green-bg);  color: var(--tag-green-text); }
.tag-yellow { background: var(--tag-yellow-bg); color: var(--tag-yellow-text); }
.tag-purple { background: var(--tag-purple-bg); color: var(--tag-purple-text); }
.tag-teal   { background: var(--tag-teal-bg);   color: var(--tag-teal-text); }
.tag-red    { background: var(--tag-red-bg);    color: var(--tag-red-text); }

/* ── Comment preview ─────────────────────────────────────────────── */
.comment-preview { background: var(--surface-2); border: 1px solid var(--border-light); border-radius: 6px; padding: 10px 13px; margin-top: 10px; display: flex; gap: 9px; align-items: flex-start; }
.comment-body    { font-size: 12.5px; color: var(--text-secondary); line-height: 1.55; }
.comment-author  { font-weight: 600; color: var(--text-primary); }
.comment-more    { font-size: 11.5px; color: var(--accent); margin-top: 6px; }

/* ── Mosaïque photos ─────────────────────────────────────────────── */
.post-mosaic  { border-radius: 7px; overflow: hidden; margin-bottom: 14px; height: 280px; display: flex; flex-direction: column; gap: 2px; }
.mosaic-row   { display: flex; gap: 2px; flex: 1; min-height: 0; }
.mosaic-cell  { flex: 1; overflow: hidden; cursor: pointer; position: relative; min-width: 0; background: var(--surface-2); }
.mosaic-cell::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background 0.15s; }
.mosaic-cell:hover::after { background: rgba(0,0,0,0.1); }
.mosaic-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mosaic-more  { position: absolute; inset: 0; background: rgba(0,0,0,0.52); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; font-weight: 700; z-index: 1; }

/* ── Fichiers ────────────────────────────────────────────────────── */
.post-files { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.file-chip  { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; max-width: 360px; transition: border-color 0.1s, background 0.1s; }
.file-chip:hover { border-color: var(--accent); background: var(--accent-light); }
.file-icon  { width: 28px; height: 28px; border-radius: 5px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 9px; font-weight: 700; letter-spacing: 0.04em; }
.fi-pdf     { background: #FDECEA; color: #C0392B; }
.fi-doc     { background: #E8EEF8; color: #1A4A90; }
.fi-xls     { background: #E8F5E9; color: #2E7D32; }
.fi-img     { background: var(--accent-light); color: var(--accent); }
.file-info  { flex: 1; min-width: 0; }
.file-name  { font-size: 12.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size  { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.file-dl    { color: var(--text-muted); flex-shrink: 0; transition: color 0.1s; }
.file-chip:hover .file-dl { color: var(--accent); }

/* ── Modal / overlay ─────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(10,18,30,0.6); z-index: 1000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface); border-radius: 10px;
  width: 100%; max-width: 560px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header { padding: 18px 20px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 15px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.modal-close  { width: 28px; height: 28px; background: var(--surface-2); border: none; border-radius: 6px; color: var(--text-muted); display: flex; align-items: center; justify-content: center; transition: background 0.1s; }
.modal-close:hover { background: var(--border); }
.modal-body   { padding: 16px 20px; }
.modal-footer { padding: 0 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 14px; }
.form-label  { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; letter-spacing: 0.01em; }
.form-input,
.form-select,
.form-textarea {
  width: 100%; padding: 8px 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; font-family: inherit;
  color: var(--text-primary);
  transition: border-color 0.1s;
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-select   { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237888A4' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* ── Lightbox ────────────────────────────────────────────────────── */
#lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 9999; align-items: center; justify-content: center; flex-direction: column; gap: 12px; padding: 20px; }
#lightbox.open { display: flex; }
.lb-close   { position: absolute; top: 16px; right: 20px; width: 36px; height: 36px; background: rgba(255,255,255,0.12); border: none; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; transition: background 0.15s; }
.lb-close:hover { background: rgba(255,255,255,0.22); }
.lb-counter { color: rgba(255,255,255,0.55); font-size: 13px; font-weight: 500; position: absolute; top: 22px; left: 50%; transform: translateX(-50%); }
.lb-stage   { width: 100%; max-width: 840px; flex: 1; display: flex; align-items: center; justify-content: center; position: relative; }
.lb-image   { width: 100%; max-height: 75vh; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; transition: opacity 0.15s; }
.lb-image img { max-width: 100%; max-height: 75vh; object-fit: contain; display: block; }
.lb-arrow   { position: absolute; width: 44px; height: 44px; background: rgba(255,255,255,0.14); border: none; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.lb-arrow:hover { background: rgba(255,255,255,0.26); }
.lb-arrow.prev { left: -56px; } .lb-arrow.next { right: -56px; }
.lb-arrow:disabled { opacity: 0.2; pointer-events: none; }
.lb-caption { color: rgba(255,255,255,0.6); font-size: 12.5px; text-align: center; max-width: 480px; }
.lb-thumbs  { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.lb-thumb   { width: 52px; height: 40px; border-radius: 4px; overflow: hidden; cursor: pointer; opacity: 0.5; border: 2px solid transparent; transition: opacity 0.15s, border-color 0.15s; flex-shrink: 0; }
.lb-thumb:hover { opacity: 0.8; }
.lb-thumb.active { opacity: 1; border-color: #fff; }
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Login page ──────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--body-bg); }
.login-box  { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 36px 40px; width: 100%; max-width: 380px; box-shadow: 0 4px 20px rgba(0,0,0,0.06); }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-title { font-size: 17px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; line-height: 1.25; }
.login-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; letter-spacing: 0.04em; text-transform: uppercase; }

.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #FDECEA; color: #C0392B; border: 1px solid #F5C6C3; }
.alert-info  { background: var(--accent-light); color: var(--accent); border: 1px solid var(--border); }

/* ── Utilities ───────────────────────────────────────────────────── */
.icon { width: 14px; height: 14px; }
.icon-sm { width: 12px; height: 12px; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }

/* ── Hamburger (caché sur desktop) ──────────────────────────────── */
.hamburger {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: none; border: none;
  color: var(--text-muted);
  border-radius: 6px;
  flex-shrink: 0;
  transition: background 0.1s;
}
.hamburger:hover { background: var(--surface-2); color: var(--text-primary); }

/* ── Overlay backdrop (mobile) ───────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 499;
}
.sidebar-backdrop.open { display: block; }

/* ── Mobile ≤ 768px ──────────────────────────────────────────────── */
@media (max-width: 768px) {

  body {
    display: block;
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* Sidebar : overlay slide-in */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 500;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0,0,0,0.35);
  }

  /* Main : pleine largeur */
  .main {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    overflow: visible;
  }

  /* Topbar sticky */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 14px;
  }
  .hamburger { display: flex; }

  /* Content : colonne unique */
  .content {
    flex-direction: column;
    overflow: visible;
    height: auto;
  }
  .feed-col {
    overflow: visible;
    padding: 12px 12px 24px;
  }
  .pinned-col { display: none; }

  /* Post card */
  .post-card { padding: 13px 13px; }
  .post-mosaic { height: 210px; }
  .post-foot { gap: 4px; }
  .post-action { padding: 4px 5px; font-size: 11.5px; gap: 4px; }
  .pin-label { display: none; }

  /* Modal → bottom sheet */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    border-radius: 16px 16px 0 0;
    max-height: 92dvh;
    overflow-y: auto;
    max-width: 100%;
  }

  /* Page body des autres modules */
  .page-body { padding: 16px 14px 60px; }

  /* Lightbox flèches rapprochées */
  .lb-arrow.prev { left: 6px; }
  .lb-arrow.next { right: 6px; }

  /* Login */
  .login-box { padding: 28px 22px; margin: 16px; border-radius: 10px; }

  /* Table overflow dans les modules */
  table { font-size: 12.5px; }
  th, td { padding: 8px 10px; }
}

/* ── Tablette 769–1024px ─────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --pinned-w: 220px; --sidebar-w: 210px; }
  .feed-col { padding: 16px 16px 16px 20px; }
  .page-body { padding: 20px 20px 60px; }
}
