@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Inter:wght@400;500&display=swap');

:root {
  --blue-dark:   #1F3A5F;
  --blue-action: #2E75B6;
  --blue-light:  #4A90D9;
  --bg:          #F5F7FA;
  --surface:     #FFFFFF;
  --text:        #1A1A2E;
  --text-muted:  #6B7280;
  --success:     #2ECC71;
  --danger:      #E74C3C;
  --warning:     #F39C12;
  --border:      #E5E9F0;
  --shadow:      0 2px 12px rgba(31,58,95,.10);
  --shadow-lg:   0 8px 32px rgba(31,58,95,.15);
  --radius:      12px;
  --radius-sm:   8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 15px; line-height: 1.6; }
h1,h2,h3,h4 { font-family: 'Outfit', sans-serif; font-weight: 600; color: var(--blue-dark); }
a { color: var(--blue-action); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar { width: 240px; background: var(--blue-dark); color: #fff; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-logo { padding: 28px 24px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-logo .logo-text { font-family: 'Outfit',sans-serif; font-size: 20px; font-weight: 700; color: #fff; }
.sidebar-logo .logo-sub  { font-size: 11px; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 16px 0; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 24px; color: rgba(255,255,255,.75); font-size: 14px; font-weight: 500; transition: all .15s; border-left: 3px solid transparent; }
.sidebar-nav a:hover, .sidebar-nav a.active { color: #fff; background: rgba(255,255,255,.08); border-left-color: var(--blue-light); text-decoration: none; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px 24px; border-top: 1px solid rgba(255,255,255,.1); }
.user-card { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-action); display: flex; align-items: center; justify-content: center; font-family: 'Outfit',sans-serif; font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0; }
.user-info .user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.user-info .user-role { font-size: 11px; color: rgba(255,255,255,.5); }
.btn-logout { margin-top: 10px; width: 100%; padding: 8px; background: rgba(231,76,60,.15); border: 1px solid rgba(231,76,60,.3); border-radius: var(--radius-sm); color: #ff8080; font-size: 13px; cursor: pointer; transition: all .15s; }
.btn-logout:hover { background: rgba(231,76,60,.25); }

/* ── Main ────────────────────────────────────────────────── */
.main-content { margin-left: 240px; flex: 1; padding: 32px 40px; min-height: 100vh; }
.page-header { margin-bottom: 28px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 26px; }
.page-header p  { color: var(--text-muted); font-size: 14px; }

/* ── Boutons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; font-family: 'Inter',sans-serif; cursor: pointer; transition: all .15s; border: none; text-decoration: none; }
.btn-primary { background: var(--blue-action); color: #fff; }
.btn-primary:hover { background: #2563a8; color: #fff; text-decoration: none; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--blue-action); color: var(--blue-action); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; padding: 13px; font-size: 15px; }

/* ── Formulaires ─────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-control { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: 'Inter',sans-serif; color: var(--text); background: var(--bg); outline: none; transition: border-color .15s, box-shadow .15s; }
.form-control:focus { border-color: var(--blue-action); box-shadow: 0 0 0 3px rgba(46,117,182,.12); background: #fff; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Tableaux ────────────────────────────────────────────── */
.table-container { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1.5px solid var(--border); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg); }
th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1.5px solid var(--border); }
td { padding: 13px 16px; font-size: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(245,247,250,.8); }

/* ── Badges statut affaire ───────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-etude     { background: rgba(46,117,182,.12); color: var(--blue-action); }
.badge-en_cours  { background: rgba(46,204,113,.12); color: #1a9a50; }
.badge-termine   { background: rgba(107,114,128,.12); color: var(--text-muted); }
.badge-archive   { background: rgba(231,76,60,.10); color: #c0392b; }

/* ── Badge type acteur ───────────────────────────────────── */
.badge-moa { background: rgba(31,58,95,.12);   color: var(--blue-dark); }
.badge-moe { background: rgba(46,117,182,.12); color: var(--blue-action); }
.badge-bc  { background: rgba(243,156,18,.12); color: #b7770d; }
.badge-client { background: rgba(46,204,113,.12); color: #1a9a50; }
.badge-autre  { background: rgba(107,114,128,.12); color: var(--text-muted); }

/* ── Fiche détail ────────────────────────────────────────── */
.detail-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1.5px solid var(--border); padding: 28px; margin-bottom: 20px; }
.detail-card h2 { font-size: 16px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1.5px solid var(--border); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.detail-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 4px; }
.detail-field span  { font-size: 14px; color: var(--text); }

/* ── Barre de recherche ──────────────────────────────────── */
.search-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.search-bar .form-control { max-width: 320px; }

/* ── Alertes ─────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error   { background: rgba(231,76,60,.10); color: #c0392b; border: 1px solid rgba(231,76,60,.25); }
.alert-success { background: rgba(46,204,113,.10); color: #1a9a50; border: 1px solid rgba(46,204,113,.25); }
.alert-hidden  { display: none; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 32px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; transform: translateY(16px); transition: transform .2s; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-header h3 { font-size: 18px; }
.btn-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; flex-direction: column; gap: 16px; }
.loading-page .spinner { width: 36px; height: 36px; border-color: rgba(31,58,95,.2); border-top-color: var(--blue-dark); }

/* ── Historique rattachement ─────────────────────────────── */
.historique-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.historique-item:last-child { border-bottom: none; }
.historique-actif { color: var(--success); font-weight: 600; }
.historique-inactif { color: var(--text-muted); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { color: var(--text-muted); font-size: 14px; padding: 40px 24px; text-align: center; background: var(--surface); border-radius: var(--radius); border: 1.5px dashed var(--border); }

/* ── Login ───────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--blue-dark) 0%, #2a4d7a 100%); }
.login-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 48px 40px; width: 100%; max-width: 420px; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-main { font-family: 'Outfit',sans-serif; font-size: 28px; font-weight: 700; color: var(--blue-dark); }
.login-logo .logo-domain { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .main-content { margin-left: 0; padding: 20px; }
  .form-grid-2 { grid-template-columns: 1fr; }
}
