/* ============================================================
   pension.azeo.ch — Portail Entreprises B2B
   ============================================================ */

/* ---- Variables portail ---- */
:root {
  --portal-sidebar-w: 240px;
  --portal-topbar-h: 60px;
  --sidebar-bg: #0F172A;
  --sidebar-text: #94A3B8;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active: rgba(255,255,255,.1);
  --sidebar-active-text: #fff;
}

/* ---- Reset portail ---- */
.portal-body {
  background: #F1F5F9;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.portal-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--portal-topbar-h);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.portal-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.portal-topbar-center { flex: 1; display: flex; justify-content: center; }
.portal-topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  text-decoration: none;
}
.portal-brand:hover { color: var(--blue); text-decoration: none; }
.portal-brand-logo { font-size: 20px; }

.company-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.company-pill-dot { width: 6px; height: 6px; border-radius: 50%; }

.topbar-link {
  font-size: 12px;
  color: var(--gray-500);
  text-decoration: none;
}
.topbar-link:hover { color: var(--blue); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}
.topbar-logout {
  color: var(--gray-400);
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 6px;
  transition: color .2s, background .2s;
}
.topbar-logout:hover { color: #D4182B; background: #FFF0F0; }

.burger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-600);
  padding: 4px;
  border-radius: 6px;
}

/* ============================================================
   LAYOUT : SIDEBAR + MAIN
   ============================================================ */
.portal-layout {
  display: flex;
  margin-top: var(--portal-topbar-h);
  min-height: calc(100vh - var(--portal-topbar-h));
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.portal-sidebar {
  width: var(--portal-sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: var(--portal-topbar-h);
  height: calc(100vh - var(--portal-topbar-h));
  overflow-y: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-link.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar-link svg { flex-shrink: 0; opacity: .7; }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }

.sidebar-sep {
  border: none;
  border-top: 1px solid rgba(255,255,255,.08);
  margin: 8px 12px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.user-info { overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-logout {
  display: block;
  width: 100%;
  text-align: center;
  background: rgba(255,255,255,.06);
  color: var(--sidebar-text);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  text-decoration: none;
  transition: background .2s, color .2s;
  box-sizing: border-box;
}
.btn-logout:hover { background: rgba(212,24,43,.2); color: #FF6B6B; border-color: rgba(212,24,43,.3); text-decoration: none; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.portal-main {
  flex: 1;
  padding: 32px 36px;
  overflow-y: auto;
  min-width: 0;
}

.portal-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.portal-page-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--gray-900);
  margin: 0 0 4px;
}
.portal-page-sub { font-size: 14px; color: var(--gray-500); margin: 0; }

.company-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.company-dot { width: 7px; height: 7px; border-radius: 50%; }

/* ---- Alert welcome ---- */
.alert-welcome {
  background: linear-gradient(135deg, #F0FFF4, #DCFCE7);
  border: 1px solid #86EFAC;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 14px;
  color: #166534;
  margin-bottom: 24px;
  font-weight: 500;
}

/* ============================================================
   STATS CARDS
   ============================================================ */
.portal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 32px;
}
.pstat-card {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pstat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.pstat-val { font-size: 17px; font-weight: 700; color: var(--gray-900); }
.pstat-label { font-size: 13px; color: var(--gray-500); }
.pstat-btn {
  display: inline-block;
  margin-top: 8px;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .2s, transform .1s;
  align-self: flex-start;
}
.pstat-btn:hover { opacity: .88; transform: translateY(-1px); text-decoration: none; color: #fff; }

/* ============================================================
   SECTIONS
   ============================================================ */
.portal-section { margin-bottom: 32px; }
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0 0 16px;
}

/* ---- Caisse card ---- */
.caisse-card {
  background: #fff;
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.caisse-name { font-size: 16px; font-weight: 700; color: var(--gray-900); margin-bottom: 8px; }
.caisse-info { font-size: 13px; color: var(--gray-600); margin-bottom: 12px; }
.caisse-info a { color: var(--blue); }
.caisse-note { font-size: 13px; color: var(--gray-500); line-height: 1.6; margin: 0; }

/* ---- Topic grid ---- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.topic-card {
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: box-shadow .2s, transform .15s;
  display: block;
}
.topic-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); text-decoration: none; color: inherit; }
.topic-icon { font-size: 28px; margin-bottom: 8px; }
.topic-title { font-size: 14px; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.topic-sub { font-size: 12px; color: var(--gray-500); }

/* ---- Documents list ---- */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-item {
  background: #fff;
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: box-shadow .2s;
}
.doc-item:hover { box-shadow: 0 3px 12px rgba(0,0,0,.08); text-decoration: none; color: inherit; }
.doc-coming { opacity: .7; cursor: default; }
.doc-coming:hover { box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.doc-icon { font-size: 24px; flex-shrink: 0; }
.doc-info { flex: 1; }
.doc-name { font-size: 14px; font-weight: 600; color: var(--gray-900); margin-bottom: 2px; }
.doc-meta { font-size: 12px; color: var(--gray-500); }
.doc-badge { background: var(--gray-100); color: var(--gray-500); border-radius: 12px; padding: 3px 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.doc-ext { font-size: 18px; color: var(--gray-400); }

/* ---- Disclaimer ---- */
.portal-disclaimer {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 10px;
  padding: 16px 20px;
  font-size: 13px;
  color: #92400E;
  line-height: 1.6;
  margin-top: 8px;
}
.portal-disclaimer a { color: #92400E; font-weight: 600; }

/* ============================================================
   CHAT PORTAIL — Pleine hauteur
   ============================================================ */
.portal-main--chat {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--portal-topbar-h));
}
.chat-portal-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #fff;
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}
.chat-portal-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-portal-avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.chat-portal-name { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.chat-portal-sub { font-size: 11px; color: var(--gray-500); }
.chat-portal-actions { display: flex; align-items: center; gap: 10px; }
.btn-icon {
  background: var(--gray-100);
  border: none;
  border-radius: 8px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--gray-600);
  transition: background .2s;
}
.btn-icon:hover { background: var(--gray-200); }

.chat-portal-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #F8FAFC;
}
.chat-portal-input {
  background: #fff;
  border-top: 1px solid var(--gray-200);
  padding: 16px 24px;
  flex-shrink: 0;
}
.chat-portal-input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  padding: 10px 14px;
  background: #fff;
  transition: border-color .2s;
}
.chat-portal-input-box:focus-within { border-color: var(--blue); }
.chat-portal-input-box textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: transparent;
  line-height: 1.5;
  max-height: 120px;
}
.chat-portal-footer {
  font-size: 11px;
  color: var(--gray-400);
  text-align: center;
  margin-top: 10px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .portal-stats { grid-template-columns: repeat(2, 1fr); }
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .burger-btn { display: flex; }
  .topbar-username { display: none; }
  .topbar-link { display: none; }
  .company-pill { display: none; }
  .portal-topbar-center { display: none; }

  .portal-sidebar {
    position: fixed;
    top: var(--portal-topbar-h);
    left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.2);
  }
  .portal-sidebar.open { transform: translateX(0); }
  .portal-main { padding: 20px 16px; }
  .portal-stats { grid-template-columns: 1fr; }
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .portal-page-header { flex-direction: column; }

  .chat-portal-header { padding: 12px 16px; }
  .chat-portal-messages { padding: 16px; }
  .chat-portal-input { padding: 12px 16px; }
}

@media (max-width: 480px) {
  .topic-grid { grid-template-columns: 1fr; }
}
