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

/* ===== Variables ===== */
:root {
  --sidebar-w: 240px;
  --topbar-h: 60px;

  --sidebar-bg: #FFFFFF;
  --sidebar-item: #EEF4FF;
  --sidebar-active: #1A5CBA;
  --sidebar-text: #374151;
  --sidebar-text-muted: #9CA3AF;

  --primary: #1A5CBA;
  --primary-dark: #134A9A;
  --primary-light: #DBEAFE;
  --success: #16A34A;
  --success-light: #DCFCE7;
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --info: #0891B2;
  --info-light: #CFFAFE;

  --bg: #F0F6FF;
  --card: #FFFFFF;
  --topbar: #FFFFFF;
  --border: #D1E0F5;
  --border-light: #EEF4FF;

  --text: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== App shell ===== */
#app-shell {
  display: flex;
  height: 100vh;
}

/* ===== Sidebar ===== */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 50;
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 8px rgba(26,92,186,0.04);
}
.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.logo-text strong {
  display: block;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.logo-text span {
  color: var(--sidebar-text-muted);
  font-size: 11px;
}

.sidebar-section {
  padding: 20px 12px 8px;
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sidebar-text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-item); color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; border-left: 3px solid var(--primary); padding-left: 7px; }
.nav-item .nav-icon {
  width: 18px; height: 18px;
  opacity: 0.8;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  display: none;
}
.nav-badge.show { display: block; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-info strong {
  display: block;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
}
.user-info span {
  color: var(--sidebar-text-muted);
  font-size: 11px;
}
.btn-logout-side {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-logout-side:hover { color: var(--primary); background: var(--primary-light); }

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

/* ===== Topbar ===== */
#topbar {
  background: var(--topbar);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.topbar-breadcrumb {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.topbar-breadcrumb span {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
}

/* Client selector */
#client-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
#client-selector {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
  min-width: 180px;
}
#client-selector:focus { outline: none; border-color: var(--primary); }

/* Alert bell */
.topbar-bell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: background 0.15s;
}
.topbar-bell:hover { background: var(--bg); color: var(--text); }
.bell-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}
.bell-dot.show { display: block; }

/* ===== Content ===== */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Page header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 1.25rem; font-weight: 600; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ===== Stats grid ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
}
.kpi-card.kpi-warning::before { background: var(--warning); }
.kpi-card.kpi-success::before { background: var(--success); }
.kpi-card.kpi-danger::before  { background: var(--danger); }
.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-icon {
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  opacity: 0.08;
}

/* ===== Alerts ===== */
.alerts-wrap { margin-bottom: 24px; }
.alert-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1px solid;
}
.alert-item.alert-danger  { background: var(--danger-light);  border-color: #FECACA; }
.alert-item.alert-warning { background: var(--warning-light); border-color: #FDE68A; }
.alert-item.alert-info    { background: var(--info-light);    border-color: #A5F3FC; }
.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.alert-danger  .alert-dot { background: var(--danger); }
.alert-warning .alert-dot { background: var(--warning); }
.alert-info    .alert-dot { background: var(--info); }
.alert-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.alert-danger  .alert-type { background: var(--danger);  color: #fff; }
.alert-warning .alert-type { background: var(--warning); color: #fff; }
.alert-info    .alert-type { background: var(--info);    color: #fff; }
.alert-text { font-size: 13px; color: var(--text); }

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: #F8FAFC;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover td { background: #F8FAFC; }
tr.row-danger td  { background: #FFF5F5; }
tr.row-warning td { background: #FFFBEB; }
tbody tr.row-danger:hover td  { background: #FEE2E2; }
tbody tr.row-warning:hover td { background: #FEF3C7; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.badge-nouvelle            { background: #EFF6FF; color: #1D4ED8; }
.badge-en_cours            { background: #FFFBEB; color: #B45309; }
.badge-traitee             { background: #F0FDF4; color: #15803D; }
.badge-refusee             { background: #FFF5F5; color: #B91C1C; }
.badge-actif               { background: #F0FDF4; color: #15803D; }
.badge-termine             { background: #F8FAFC; color: #64748B; }
.badge-sorti               { background: #F8FAFC; color: #64748B; }
.badge-soumise             { background: #EFF6FF; color: #1D4ED8; }
.badge-validee_assistante  { background: #FFFBEB; color: #B45309; }
.badge-refusee_assistante  { background: #FFF5F5; color: #B91C1C; }
.badge-validee             { background: #F0FDF4; color: #15803D; }
.badge-depose              { background: #EFF6FF; color: #1D4ED8; }
.badge-traite              { background: #F0FDF4; color: #15803D; }
.badge-inactif             { background: #F8FAFC; color: #64748B; }

/* ===== Forms ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.1px;
}
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], select, textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
textarea { resize: vertical; min-height: 72px; }
select { cursor: pointer; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { filter: brightness(0.92); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); filter: none; }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); filter: none; background: var(--primary-light); }
.btn-ghost    { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); filter: none; color: var(--text); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ===== Inline form (process) ===== */
.inline-form-row { display: none; }
.inline-form-row.open { display: table-row; }
.inline-form-cell {
  background: #EFF6FF;
  border-top: 2px solid var(--primary);
  padding: 16px 20px !important;
}
.inline-form-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

/* ===== Toast ===== */
#toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 13px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  pointer-events: none;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { background: var(--success); }
#toast.error   { background: var(--danger); }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* ===== Section divider ===== */
.section-sep { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* ===== Client pill (topbar) ===== */
.client-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ===== Login page ===== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0D1B2A 0%, #1E3A5F 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-container {
  display: flex;
  gap: 0;
  max-width: 860px;
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  background: var(--primary);
  background: linear-gradient(160deg, #1D4ED8, #2563EB);
  padding: 48px 40px;
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}
.login-brand .logo-icon {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
}
.login-brand .logo-text { color: #fff; font-size: 18px; font-weight: 700; }
.login-brand h2 { color: #fff; font-size: 1.5rem; font-weight: 700; margin-bottom: 12px; }
.login-brand p { color: rgba(255,255,255,0.75); font-size: 14px; line-height: 1.7; }
.login-features { margin-top: 32px; display: flex; flex-direction: column; gap: 10px; }
.login-feature {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,0.85); font-size: 13px;
}
.login-feature-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.5); flex-shrink: 0; }
.login-form-panel {
  flex: 1;
  background: #fff;
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-form-panel h3 { font-size: 1.4rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.login-form-panel .subtitle { color: var(--text-muted); font-size: 13.5px; margin-bottom: 32px; }
.login-form-panel .form-group { margin-bottom: 16px; }
.login-form-panel label { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; display: block; }
.login-form-panel input {
  width: 100%; padding: 10px 14px; font-size: 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.login-form-panel input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); outline: none; }
.btn-login { width: 100%; padding: 11px; font-size: 14px; margin-top: 8px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 14px; display: none; padding: 10px 14px; background: var(--danger-light); border-radius: var(--radius-sm); }

/* ===== Salarie portal ===== */
.portal-header {
  background: linear-gradient(135deg, #0D1B2A, #1D4ED8);
  color: #fff;
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.portal-header .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.portal-header .logo span { color: rgba(255,255,255,0.6); font-size: 13px; font-weight: 400; }
.portal-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: rgba(255,255,255,0.85); }
.portal-content { max-width: 900px; margin: 0 auto; padding: 28px 20px; }
.portal-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.portal-tab {
  padding: 10px 18px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-family: inherit; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s;
}
.portal-tab:hover { color: var(--text); }
.portal-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.welcome-banner {
  background: linear-gradient(135deg, #1D4ED8, #2563EB);
  border-radius: var(--radius);
  padding: 24px 28px;
  color: #fff;
  margin-bottom: 24px;
}
.welcome-banner h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 4px; }
.welcome-banner p { font-size: 13px; opacity: 0.8; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #sidebar { position: fixed; left: -260px; top: 0; bottom: 0; transition: left 0.25s; z-index: 200; }
  #sidebar.open { left: 0; }
  #main-area { margin-left: 0; }
  #content { padding: 16px; }
  .login-container { flex-direction: column; }
  .login-brand { width: 100%; padding: 28px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
