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

/* ── Variables ─────────────────────────────────────────── */
: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, 0.10);
  --shadow-lg:   0 8px 32px rgba(31, 58, 95, 0.15);
  --radius:      12px;
  --radius-sm:   8px;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::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 principal ──────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--blue-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 0;
  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,0.1);
}

.sidebar-logo .logo-text {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.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,0.75);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: #fff;
  background: rgba(255,255,255,0.08);
  border-left-color: var(--blue-light);
  text-decoration: none;
}

.sidebar-nav .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.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,0.5);
  text-transform: capitalize;
}

.btn-logout {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  background: rgba(231,76,60,0.15);
  border: 1px solid rgba(231,76,60,0.3);
  border-radius: var(--radius-sm);
  color: #ff8080;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logout:hover {
  background: rgba(231,76,60,0.25);
}

/* ── Main content ──────────────────────────────────────── */
.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 32px 40px;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 26px;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Page 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;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 11px 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);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--blue-action);
  box-shadow: 0 0 0 3px rgba(46, 117, 182, 0.12);
  background: #fff;
}

/* ── 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 0.15s;
  border: none;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: #2563a8;
  text-decoration: none;
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-full { width: 100%; justify-content: center; padding: 13px; font-size: 15px; }

.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;
}

/* ── Cartes projet ──────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1.5px solid var(--border);
  transition: box-shadow 0.2s, transform 0.2s;
}

.project-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.project-card-header {
  margin-bottom: 16px;
}

.project-name {
  font-family: 'Outfit', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 4px;
}

.project-client {
  font-size: 13px;
  color: var(--text-muted);
}

.project-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--blue-dark);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-tool:hover {
  background: var(--blue-dark);
  color: #fff;
  border-color: var(--blue-dark);
  text-decoration: none;
}

.btn-tool .tool-arrow { font-size: 11px; opacity: 0.7; }

/* ── 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: 0.5px;
  border-bottom: 1.5px solid var(--border);
}

td {
  padding: 14px 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, 0.8); }

/* ── Badges rôle ─────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-admin      { background: rgba(31,58,95,0.12);   color: var(--blue-dark); }
.badge-charge     { background: rgba(46,117,182,0.12); color: var(--blue-action); }
.badge-calculateur{ background: rgba(46,204,113,0.12); color: #1a9a50; }
.badge-assistante { background: rgba(155,89,182,0.12); color: #8e44ad; }
.badge-lecture    { background: rgba(107,114,128,0.12);color: var(--text-muted); }

/* ── Bac à sable ─────────────────────────────────────────── */
.sandbox-card {
  border-style: dashed;
  border-color: rgba(243,156,18,0.4);
  background: rgba(255,251,235,0.6);
}

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

/* ── Alertes ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error   { background: rgba(231,76,60,0.10); color: #c0392b; border: 1px solid rgba(231,76,60,0.25); }
.alert-success { background: rgba(46,204,113,0.10); color: #1a9a50; border: 1px solid rgba(46,204,113,0.25); }
.alert-hidden  { display: none; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.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: 480px;
  transform: translateY(16px);
  transition: transform 0.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);
  padding: 4px;
}

/* ── Stats ───────────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  border: 1.5px solid var(--border);
  flex: 1;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--blue-dark);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.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,0.2);
  border-top-color: var(--blue-dark);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; }
  .main-content { margin-left: 0; padding: 20px; }
  .projects-grid { grid-template-columns: 1fr; }
  .stats-row { flex-direction: column; }
}
