/* ============================================================
   portal.css — Design système Portails Customer & Partner
   Clean, moderne, orienté utilisateur final (non CRM)
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --portal-primary:        var(--primary, #0d6efd);
  --portal-primary-hover:  var(--primary-hover, #0b5ed7);
  --portal-bg:             #f4f6f9;
  --portal-navbar-bg:      #ffffff;
  --portal-card-bg:        #ffffff;
  --portal-card-radius:    14px;
  --portal-card-shadow:    0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.04);
  --portal-card-shadow-hover: 0 4px 12px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.06);
  --portal-navbar-height:  64px;
  --portal-text:           #1e2128;
  --portal-text-muted:     #6b7280;
  --portal-border:         #e9ecef;
  --portal-success:        #12b76a;
  --portal-warning:        #f79009;
  --portal-danger:         #f04438;
  --portal-info:           #0ba5ec;
}

/* ── Reset / Base ───────────────────────────────────────────── */
body.portal-body {
  background: var(--portal-bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--portal-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.portal-navbar {
  background: var(--portal-navbar-bg);
  border-bottom: 1px solid var(--portal-border);
  height: var(--portal-navbar-height);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
}

.portal-navbar .container,
.portal-navbar .container-xl,
.portal-navbar .container-xxl {
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
}

.portal-navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-right: 40px;
  flex-shrink: 0;
}

.portal-navbar-brand img {
  max-height: 32px;
  width: auto;
}

.portal-navbar-brand .portal-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: .3px;
  white-space: nowrap;
}

.portal-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
}

.portal-nav-item {
  height: 100%;
  display: flex;
  align-items: center;
}

.portal-nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  height: 100%;
  font-size: 14px;
  font-weight: 500;
  color: var(--portal-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.portal-nav-link:hover {
  color: var(--portal-primary);
}

.portal-nav-link.active {
  color: var(--portal-primary);
  border-bottom-color: var(--portal-primary);
}

.portal-nav-link i { font-size: 16px; }

/* User menu */
.portal-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--portal-border, #e9ecef);
  border-radius: 40px;
  background: transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-decoration: none;
  color: var(--portal-text, #1e2128);
  white-space: nowrap;
  width: auto;
  align-self: center;
  user-select: none;
  outline: none;
  -webkit-user-select: none;
}

.portal-user-btn:hover {
  background: #f4f6f9;
  border-color: #d0d5dd;
  color: var(--portal-text);
}

.portal-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--portal-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.portal-user-name {
  font-size: 14px;
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mobile toggle */
.portal-mobile-toggle {
  display: none;
  background: none;
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  margin-left: auto;
}

/* ── Main content ───────────────────────────────────────────── */
.portal-main {
  flex: 1;
  padding: 32px 0 48px;
}

.portal-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.portal-page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--portal-text);
  margin: 0;
}

.portal-breadcrumb {
  font-size: 13px;
  color: var(--portal-text-muted);
  margin-top: 4px;
}

.portal-breadcrumb a {
  color: var(--portal-text-muted);
  text-decoration: none;
}

.portal-breadcrumb a:hover { color: var(--portal-primary); }
.portal-breadcrumb span { margin: 0 6px; }

/* ── Cards ──────────────────────────────────────────────────── */
.portal-card {
  background: var(--portal-card-bg);
  border-radius: var(--portal-card-radius);
  box-shadow: var(--portal-card-shadow);
  border: 1px solid rgba(0,0,0,.04);
  /*overflow: hidden;*/
}

.portal-card-header {
  padding: 20px 24px 0;
  border-bottom: none;
}

.portal-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--portal-text);
  margin: 0 0 16px;
}

.portal-card-body { padding: 24px; }

.portal-card:hover { box-shadow: var(--portal-card-shadow-hover); }

/* ── Stat cards ─────────────────────────────────────────────── */
.portal-stat-card {
  background: var(--portal-card-bg);
  border-radius: var(--portal-card-radius);
  box-shadow: var(--portal-card-shadow);
  border: 1px solid rgba(0,0,0,.04);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.portal-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}

.portal-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--portal-text);
  line-height: 1;
  margin-bottom: 6px;
}

.portal-stat-label {
  font-size: 13px;
  color: var(--portal-text-muted);
  font-weight: 500;
}

.portal-stat-sub {
  font-size: 12px;
  margin-top: 12px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.portal-table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--portal-text-muted);
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--portal-border);
  white-space: nowrap;
}

.portal-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  color: var(--portal-text);
}

.portal-table tbody tr:last-child td { border-bottom: none; }

.portal-table tbody tr:hover td { background: #fafbfc; }

.portal-table tfoot td {
  padding: 14px 16px;
  border-top: 2px solid var(--portal-border);
  font-weight: 600;
}

/* ── Badges / Pills ─────────────────────────────────────────── */
.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.portal-badge-success  { background: #dcfce7; color: #166534; }
.portal-badge-warning  { background: #fef9c3; color: #854d0e; }
.portal-badge-danger   { background: #fee2e2; color: #991b1b; }
.portal-badge-info     { background: #dbeafe; color: #1e40af; }
.portal-badge-primary  { background: #ede9fe; color: #5b21b6; }
.portal-badge-secondary{ background: #f1f5f9; color: #475569; }

/* ── Buttons ────────────────────────────────────────────────── */
.portal-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}

.portal-btn:active { transform: translateY(1px); }

.portal-btn-primary {
  background: var(--portal-primary);
  color: #fff;
}

.portal-btn-primary:hover {
  background: var(--portal-primary-hover);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.portal-btn-light {
  background: #f4f6f9;
  color: var(--portal-text);
  border: 1px solid var(--portal-border);
}

.portal-btn-light:hover {
  background: #e9ecef;
  color: var(--portal-text);
}

.portal-btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.portal-btn-outline {
  background: transparent;
  border: 1px solid var(--portal-border);
  color: var(--portal-text-muted);
}

.portal-btn-outline:hover {
  border-color: var(--portal-primary);
  color: var(--portal-primary);
}

/* ── Forms ──────────────────────────────────────────────────── */
.portal-form-group { margin-bottom: 20px; }

.portal-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--portal-text);
  margin-bottom: 7px;
}

.portal-label.required::after {
  content: ' *';
  color: var(--portal-danger);
}

.portal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--portal-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.portal-input:focus {
  border-color: var(--portal-primary);
  box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb, 13,110,253), .12);
}

.portal-input::placeholder { color: #b0b7c3; }

textarea.portal-input { resize: vertical; min-height: 100px; }

.portal-input-hint {
  font-size: 12px;
  color: var(--portal-text-muted);
  margin-top: 5px;
}

/* ── Empty states ───────────────────────────────────────────── */
.portal-empty {
  text-align: center;
  padding: 64px 24px;
}

.portal-empty-icon {
  font-size: 48px;
  color: #d1d5db;
  margin-bottom: 20px;
  display: block;
}

.portal-empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--portal-text);
  margin-bottom: 8px;
}

.portal-empty-text {
  font-size: 14px;
  color: var(--portal-text-muted);
  margin-bottom: 24px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Notices / Alerts ───────────────────────────────────────── */
.portal-notice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 10px;
  font-size: 14px;
}

.portal-notice-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.portal-notice-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.portal-notice-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.portal-notice-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.portal-notice i { font-size: 20px; flex-shrink: 0; margin-top: 1px; }

/* ── Chat / Messages ────────────────────────────────────────── */
.portal-message-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  max-height: 520px;
  overflow-y: auto;
}

.portal-message {
  display: flex;
  gap: 12px;
  max-width: 75%;
}

.portal-message.client { margin-left: auto; flex-direction: row-reverse; }

.portal-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.portal-message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.portal-message.agent .portal-message-bubble {
  background: #f4f6f9;
  color: var(--portal-text);
  border-bottom-left-radius: 4px;
}

.portal-message.client .portal-message-bubble {
  background: var(--portal-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.portal-message-meta {
  font-size: 11px;
  color: var(--portal-text-muted);
  margin-top: 4px;
}

.portal-message.client .portal-message-meta { text-align: right; }

/* ── Flash ──────────────────────────────────────────────────── */
.portal-flash {
  position: fixed;
  top: 74px;
  right: 20px;
  z-index: 9999;
  min-width: 300px;
  max-width: 440px;
}

.portal-flash-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  border-left: 4px solid var(--portal-primary);
  font-size: 14px;
  animation: portal-flash-in .25s ease;
}

@keyframes portal-flash-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Footer ─────────────────────────────────────────────────── */
.portal-footer {
  background: #fff;
  border-top: 1px solid var(--portal-border);
  padding: 16px 0;
  margin-top: auto;
  font-size: 13px;
  color: var(--portal-text-muted);
}

/* ── Login page ─────────────────────────────────────────────── */
.portal-login-wrapper {
  min-height: 100vh;
  display: flex;
}

.portal-login-side {
  width: 420px;
  flex-shrink: 0;
  background: var(--portal-primary);
  background: linear-gradient(155deg, var(--portal-primary) 0%, var(--portal-primary-hover) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 60px 48px;
  position: relative;
  overflow: hidden;
}

.portal-login-side::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  top: -100px;
  right: -100px;
}

.portal-login-side::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  bottom: -80px;
  left: -80px;
}

.portal-login-form-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 60px 48px;
  background: #fff;
}

.portal-login-box {
  width: 100%;
  max-width: 400px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991px) {
  .portal-nav { display: none; }
  .portal-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--portal-navbar-height);
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--portal-border);
    padding: 8px 16px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    z-index: 999;
  }
  .portal-nav.open .portal-nav-item { height: auto; }
  .portal-nav.open .portal-nav-link {
    height: auto;
    padding: 10px 12px;
    border-bottom: none;
    border-radius: 8px;
  }
  .portal-nav.open .portal-nav-link.active { background: #f4f6f9; }
  .portal-mobile-toggle { display: flex; }
  .portal-navbar .container,
  .portal-navbar .container-xl,
  .portal-navbar .container-xxl { position: relative; flex-wrap: wrap; }
  .portal-navbar { height: auto; min-height: var(--portal-navbar-height); flex-wrap: wrap; }
  .portal-login-side { display: none; }
  .portal-login-form-side { padding: 40px 24px; }
}

@media (max-width: 576px) {
  .portal-main { padding: 20px 0 40px; }
  .portal-page-header { margin-bottom: 20px; }
  .portal-stat-value { font-size: 22px; }
  .portal-user-name { display: none; }
}

/* ── Autocomplete portail ───────────────────────────────────── */
.portal-ac-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 1050;
  background: #fff;
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  max-height: 340px;
  overflow-y: auto;
}
.portal-ac-dropdown .ac-menu { display: flex; flex-direction: column; }
.portal-ac-dropdown .ac-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--portal-border);
  transition: background .1s;
}
.portal-ac-dropdown .ac-item:last-child { border-bottom: none; }
.portal-ac-dropdown .ac-item:hover { background: var(--portal-bg); }
.portal-ac-dropdown .ac-title { font-weight: 600; font-size: 14px; color: var(--portal-text); }
.portal-ac-dropdown .ac-desc  { font-size: 12px; color: var(--portal-text-muted); margin-top: 2px; }
.portal-ac-dropdown .ac-row   { display: flex; align-items: center; justify-content: space-between; }
.portal-ac-dropdown mark       { background: #fef3c7; border-radius: 2px; padding: 0 2px; }
.portal-ac-dropdown .ac-empty { padding: 12px 14px; color: var(--portal-text-muted); font-size: 13px; }

/* ── Utilitaires étendus (Bootstrap 5 s'arrête à mb-5/gap-5) ── */
.mb-6  { margin-bottom: 3.5rem !important; }
.mb-7  { margin-bottom: 4rem   !important; }
.mb-8  { margin-bottom: 4.5rem !important; }
.mt-6  { margin-top: 3.5rem    !important; }
.mt-7  { margin-top: 4rem      !important; }
.mt-8  { margin-top: 4.5rem    !important; }
.g-6   { gap: 3.5rem           !important; }
.g-8   { gap: 4.5rem           !important; }
.gap-6 { gap: 3.5rem           !important; }
.gap-8 { gap: 4.5rem           !important; }
