/* AI Project Manager — design SaaS épuré (inspiration Fullmetrix). */

:root {
  --bg: #f8f9fb;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-soft: #f3f4f6;
  --bg-hover: #f4f5f7;
  --border: #ececef;
  --border-strong: #d6d6da;
  --text: #111114;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.03);
  --sidebar-w: 248px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
               Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =========================================================== App layout */

body.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  min-height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.topbar {
  grid-area: topbar;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.main-content {
  grid-area: main;
  padding: 24px 32px 48px;
  max-width: 1400px;
  width: 100%;
}

/* =========================================================== Sidebar */

.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 7px;
  font-size: 16px;
}
.brand-text { font-size: 14px; }
.brand-sub { color: var(--text-muted); font-weight: 400; }

.quick-create {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 12px;
  background: var(--primary);
  color: white !important;
  border-radius: var(--radius-sm);
  font-weight: 500;
  margin-bottom: 14px;
  font-size: 13px;
}
.quick-create:hover { background: var(--primary-dark); text-decoration: none; }
.quick-create span:first-child { font-size: 16px; line-height: 1; }

.sidenav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidenav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  padding: 14px 10px 6px;
  font-weight: 500;
}
.sidenav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 450;
}
.sidenav-item:hover { background: var(--bg-hover); text-decoration: none; }
.sidenav-item .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; flex-shrink: 0;
  font-size: 14px;
}
.sidenav-item .badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.sidenav-item .badge-warn { background: var(--warning); }

/* User widget bottom */
.user-widget {
  margin-top: 12px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-link {
  color: var(--text-muted) !important;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
}
.logout-link:hover { background: var(--bg-soft); color: var(--danger) !important;
  text-decoration: none; }

/* =========================================================== Topbar */

.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}
.role-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.role-admin { background: #ede9fe; color: #6d28d9; }
.role-team { background: #dbeafe; color: var(--primary-dark); }
.role-client { background: #dcfce7; color: var(--success); }

/* =========================================================== Headings & content */

h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
}
h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 28px 0 12px;
}
h3 {
  font-size: 13px;
  font-weight: 500;
  margin: 18px 0 8px;
}
.page-subtitle { color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

section { margin-bottom: 32px; }

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  font-weight: 500;
  margin: 24px 0 10px;
}

/* =========================================================== Cards */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.kpi { font-size: 26px; font-weight: 600; line-height: 1.1; }
.kpi-label { color: var(--text-muted); font-size: 11px; margin: 4px 0 8px;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
.kpi-mini { font-size: 18px; font-weight: 600; }
.kpi-mini.danger { color: var(--danger); }
.kpi-mini.warn { color: var(--warning); }
.kpi-mini.success { color: var(--success); }

/* =========================================================== Tables */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 8px 0;
}
th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 13px;
}
th {
  background: #fafafa;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }
.extrait { color: var(--text-muted); font-size: 12px; margin-top: 4px;
  white-space: pre-wrap; }

/* =========================================================== Tags */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-soft);
  color: var(--text-muted);
}
.tag-prio-urgent { background: #fee2e2; color: var(--danger); }
.tag-prio-high   { background: #fef3c7; color: #92400e; }
.tag-prio-normal { background: #dbeafe; color: var(--primary-dark); }
.tag-prio-backlog{ background: #f3f4f6; color: var(--text-muted); }

.tag-backlog   { background: #f3f4f6; color: var(--text-muted); }
.tag-planifie  { background: #dbeafe; color: var(--primary-dark); }
.tag-en_cours  { background: #fef3c7; color: #92400e; }
.tag-valide    { background: #dcfce7; color: var(--success); }
.tag-annule    { background: #f3f4f6; color: var(--text-muted); text-decoration: line-through; }
.tag-nouveau   { background: #dbeafe; color: var(--primary-dark); }
.tag-qualifie  { background: #dcfce7; color: var(--success); }
.tag-ignore    { background: #f3f4f6; color: var(--text-muted); }

.tag-source-email  { background: #ede9fe; color: #6d28d9; }
.tag-source-slack  { background: #fce7f3; color: #be185d; }
.tag-source-asana  { background: #ffedd5; color: #c2410c; }
.tag-source-manuel { background: #f3f4f6; color: var(--text-muted); }
.tag-source-reunion{ background: #cffafe; color: #0e7490; }

.tag-validee   { background: #dcfce7; color: var(--success); }
.tag-contestee { background: #fee2e2; color: var(--danger); }
.tag-en_attente{ background: #fef3c7; color: #92400e; }

/* =========================================================== Forms */

form { margin: 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px;
  background: #fafafa;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 8px 0;
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.form-grid label input,
.form-grid label select,
.form-grid label textarea {
  margin-top: 0;
  font-size: 13px;
  color: var(--text);
  font-weight: 400;
}
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=month],
select, textarea {
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: white;
  font-family: inherit;
  font-size: 13px;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

button, .btn-primary, .btn-ghost, .btn-outline {
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: white;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  font-family: inherit;
  display: inline-block;
}
button:hover { background: var(--bg-hover); }
.btn-primary {
  background: var(--primary);
  color: white !important;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark);
  text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  text-align: center;
  width: 100%;
}
.btn-outline:hover { background: var(--bg-hover); text-decoration: none; }
.btn-danger { color: var(--danger); border-color: #fca5a5; background: white; }
.btn-danger:hover { background: #fef2f2; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { display: inline; }

.cta { margin: 24px 0; text-align: right; }
.cta button { padding: 10px 22px; font-size: 14px; }

/* =========================================================== Filters */

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters a {
  padding: 5px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}
.filters a.active { background: var(--text); color: white; }
.filters a:hover:not(.active) { background: var(--bg-soft); text-decoration: none; }
.filters label { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-muted); }

.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  padding-bottom: 0;
}
.tabs a {
  padding: 8px 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--text); }

/* =========================================================== Flashes */

.flashes { margin: 0 0 16px; }
.flash {
  padding: 11px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
}
.flash-success { background: #dcfce7; color: var(--success); border: 1px solid #86efac; }
.flash-error { background: #fee2e2; color: var(--danger); border: 1px solid #fca5a5; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.auth-flashes { position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  width: 360px; max-width: 90vw; }

/* =========================================================== Bars */

.bar {
  display: inline-block;
  width: 140px; height: 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 6px;
}
.bar-fill { height: 100%; background: var(--primary); transition: width .3s; }
.bar-fill.warn { background: var(--warning); }
.bar-fill.danger { background: var(--danger); }
.bar-fill.success { background: var(--success); }

/* =========================================================== Alertes */

.alertes { list-style: none; padding: 0; margin: 0; }
.alerte {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 13px;
  border-left: 4px solid var(--text-muted);
  background: white;
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.alerte-info { border-left-color: var(--primary); }
.alerte-warning { border-left-color: var(--warning); background: #fffbeb; }
.alerte-critical { border-left-color: var(--danger); background: #fef2f2; }

/* =========================================================== Details */

details { margin: 4px 0; }
details > summary { cursor: pointer; user-select: none; font-weight: 500; }
details[open] > summary { margin-bottom: 8px; }
.ia-explication {
  background: #fef9c3;
  border-left: 3px solid #eab308;
  padding: 8px 12px;
  margin: 6px 0;
  font-size: 12px;
  border-radius: 4px;
}

/* =========================================================== Reporting */

.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}
.report-card header { margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.report-card h2 { margin: 0; font-size: 16px; }
.report-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.report-actions a { padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 6px; }
.report-actions a:hover { background: var(--bg-hover); text-decoration: none; }
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

/* =========================================================== Inbox sync row */

.ingestion-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form button { background: var(--bg-soft); }
.inline-label { display: flex; gap: 4px; align-items: center; font-size: 12px; color: var(--text-muted); }
.sync-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }

/* =========================================================== Integrations grid */

.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.integration-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 120px;
}
.integration-head { display: flex; align-items: flex-start; gap: 12px; }
.integration-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg-soft);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.integration-meta { flex: 1; min-width: 0; }
.integration-meta h3 {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 2px; font-size: 14px; font-weight: 600;
}
.integration-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}
.integration-status.is-connected { background: var(--warning); }
.integration-meta p { margin: 0; font-size: 12px; color: var(--text-muted); }
.integration-card .btn-outline { font-size: 13px; padding: 8px 12px; }

/* Integration "Add new" tile (placeholder) */
.integration-add {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  min-height: 120px;
  border-radius: var(--radius);
}
.integration-add span { font-size: 22px; line-height: 1; margin-bottom: 6px; color: var(--text-dim); }

/* =========================================================== Auth shell */

.auth-shell {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 36px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.04);
}
.auth-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 20px;
  font-size: 14px; font-weight: 500; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--text-muted); font-weight: 500; }
.auth-form button { padding: 10px; font-size: 14px; margin-top: 6px; }
.auth-footer { margin-top: 20px; text-align: center; }

/* =========================================================== Profile (account) page */

.profile-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.profile-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.profile-row:last-child { border-bottom: none; }
.profile-row .avatar { width: 48px; height: 48px; font-size: 18px; }
.profile-row-meta { flex: 1; }
.profile-row-meta strong { display: block; font-size: 14px; }
.profile-row-meta span { color: var(--text-muted); font-size: 12px; }
.profile-row-status {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 10px;
}
.profile-row-status.is-active { background: #dcfce7; color: var(--success); }
.profile-row-status.is-inactive { background: var(--bg-soft); color: var(--text-muted); }

/* =========================================================== Validation cards (client portal) */

.validation-list { display: flex; flex-direction: column; gap: 10px; }
.validation-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.validation-card.over-budget { border-left: 4px solid var(--danger); }
.validation-card-head { display: flex; justify-content: space-between; gap: 12px;
  align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.validation-meta {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted); margin-bottom: 12px;
}
.validation-meta strong { color: var(--text); }
.validation-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.validation-actions form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.validation-actions input[type=text] { flex: 1; min-width: 200px; }

/* =========================================================== Misc */

.client-h { font-size: 12px; margin: 18px 0 6px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; }

@media (max-width: 800px) {
  body.app {
    grid-template-columns: 1fr;
    grid-template-rows: auto var(--topbar-h) 1fr;
    grid-template-areas: "sidebar" "topbar" "main";
  }
  .sidebar { position: static; height: auto; max-height: none;
    border-right: none; border-bottom: 1px solid var(--border); }
  .main-content { padding: 16px; }
}
