/* GED Qualité — main.css */

:root {
  --navy: #0D2137;
  --blue: #1565C0;
  --blue-light: #E3F2FD;
  --teal: #0097A7;
  --teal-light: #E0F7FA;
  --green: #2E7D32;
  --green-light: #E8F5E9;
  --red: #C62828;
  --red-light: #FFEBEE;
  --amber: #E65100;
  --amber-light: #FFF3E0;
  --gray: #546E7A;
  --gray-light: #ECEFF1;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --border: #E0E0E0;
  --text: #1A2B3C;
  --text-muted: #78909C;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); display: flex; min-height: 100vh; }

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

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar { width: var(--sidebar-w); background: var(--navy); display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: width 0.2s; overflow: hidden; }
.sidebar.collapsed { width: 60px; }

.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo-icon { width: 32px; height: 32px; background: var(--teal); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.logo-icon.large { width: 48px; height: 48px; font-size: 16px; }
.logo-text { font-size: 15px; font-weight: 600; color: #fff; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; color: rgba(255,255,255,0.65); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background 0.15s, color 0.15s; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.nav-separator { height: 1px; background: rgba(255,255,255,0.08); margin: 8px 0; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-info { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--teal); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-details { overflow: hidden; }
.user-name { display: block; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 11px; color: rgba(255,255,255,0.5); }
.btn-logout { display: block; text-align: center; padding: 6px; border-radius: 6px; font-size: 12px; color: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.12); }
.btn-logout:hover { color: #fff; background: rgba(255,255,255,0.08); text-decoration: none; }

/* ── Main content ──────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left 0.2s; }
.sidebar.collapsed ~ .main-content { margin-left: 60px; }

.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.sidebar-toggle { background: none; border: none; cursor: pointer; padding: 4px; border-radius: 4px; color: var(--gray); }
.sidebar-toggle:hover { background: var(--gray-light); }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

.page-content { padding: 24px; flex: 1; }

/* ── Messages ──────────────────────────────────────────── */
.messages { padding: 0 24px; }
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 8px; }
.alert-success { background: var(--green-light); color: var(--green); border-left: 3px solid var(--green); }
.alert-error, .alert-danger { background: var(--red-light); color: var(--red); border-left: 3px solid var(--red); }
.alert-warning { background: var(--amber-light); color: var(--amber); border-left: 3px solid var(--amber); }
.alert-info { background: var(--blue-light); color: var(--blue); border-left: 3px solid var(--blue); }

/* ── Buttons ───────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--border); font-size: 13px; font-weight: 500; cursor: pointer; background: var(--surface); color: var(--text); transition: all 0.15s; white-space: nowrap; }
.btn:hover { background: var(--gray-light); text-decoration: none; color: var(--text); }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: #1251A1; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--blue); border-color: var(--blue); }
.btn-secondary:hover { background: var(--blue-light); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #A32020; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--gray); }
.btn-ghost:hover { background: var(--gray-light); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards ─────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 16px; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-link { font-size: 12px; color: var(--blue); }
.card-body { padding: 16px 18px; }
.card-body.p0 { padding: 0; }
.card-alert.danger { border-left: 4px solid var(--red); background: var(--red-light); }
.card-alert.warning { border-left: 4px solid var(--amber); background: var(--amber-light); }
.card-alert .alert-title { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.card-alert .alert-body { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }

/* ── KPI Grid ──────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-grid.compact { grid-template-columns: repeat(4, 1fr); }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.kpi-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 32px; font-weight: 700; color: var(--text); margin: 4px 0; line-height: 1; }
.kpi-sub { font-size: 11px; color: var(--text-muted); }
.kpi-card.danger { border-left: 3px solid var(--red); }
.kpi-card.danger .kpi-value { color: var(--red); }
.kpi-card.warning { border-left: 3px solid var(--amber); }
.kpi-card.warning .kpi-value { color: var(--amber); }
.kpi-card.warning-soft { border-left: 3px solid #F9A825; }
.kpi-card.warning-soft .kpi-value { color: #F9A825; }
.kpi-card.success { border-left: 3px solid var(--green); }
.kpi-card.success .kpi-value { color: var(--green); }
.kpi-card.info { border-left: 3px solid var(--blue); }
.kpi-card.info .kpi-value { color: var(--blue); }

/* ── Dashboard grid ────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dashboard-grid .card:first-child { grid-column: 1 / -1; }

/* ── Table ─────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); background: var(--bg); }
.table td { padding: 11px 14px; border-bottom: 1px solid #F0F0F0; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: var(--bg); }
.row-danger td { background: #FFF5F5; }
.row-warning td { background: #FFFBF0; }
.td-title { max-width: 280px; }
.td-muted { color: var(--text-muted); }
.td-date { white-space: nowrap; }
.td-actions { text-align: right; white-space: nowrap; }

/* ── Badges ────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-success { background: var(--green-light); color: var(--green); }
.badge-danger { background: var(--red-light); color: var(--red); }
.badge-warning { background: var(--amber-light); color: var(--amber); }
.badge-info { background: var(--blue-light); color: var(--blue); }
.badge-gray { background: var(--gray-light); color: var(--gray); }

/* ── Filters bar ───────────────────────────────────────── */
.filters-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters-form { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; align-items: center; }
.search-input { flex: 1; min-width: 200px; padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--surface); }
.search-input:focus { outline: none; border-color: var(--blue); }
.filter-select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--surface); }
.results-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── Refs & codes ──────────────────────────────────────── */
.ref-code { font-family: 'Courier New', monospace; font-size: 12px; background: var(--gray-light); padding: 2px 6px; border-radius: 4px; color: var(--text); white-space: nowrap; }
.ref-link { color: var(--blue); font-family: monospace; font-size: 12px; }
.cat-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.doc-link { color: var(--text); font-weight: 500; }
.doc-link:hover { color: var(--blue); }
.norme-tag { display: inline-block; margin-left: 6px; font-size: 10px; color: var(--text-muted); background: var(--gray-light); padding: 1px 5px; border-radius: 3px; }
.tag { display: inline-block; padding: 3px 8px; border-radius: 10px; font-size: 11px; background: var(--blue-light); color: var(--blue); margin: 2px; }

/* ── Timeline ──────────────────────────────────────────── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 1px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot { position: absolute; left: -21px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--border); border: 2px solid var(--surface); }
.timeline-dot.active { background: var(--teal); }
.timeline-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.version-num { font-size: 14px; font-weight: 600; color: var(--text); font-family: monospace; }
.timeline-date { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.timeline-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.timeline-motif { font-size: 13px; color: var(--text); margin-bottom: 4px; }
.timeline-resume { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }

/* ── Detail layout ─────────────────────────────────────── */
.detail-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
.doc-header { display: flex; gap: 16px; margin-bottom: 16px; }
.doc-header-info { flex: 1; }
.doc-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.doc-title { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.3; margin-bottom: 6px; }
.doc-desc { font-size: 13px; color: var(--text-muted); }
.doc-status-block { text-align: right; flex-shrink: 0; }
.status-pill { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.status-pill.success { background: var(--green-light); color: var(--green); }
.status-pill.danger { background: var(--red-light); color: var(--red); }
.status-pill.warning { background: var(--amber-light); color: var(--amber); }
.status-pill.info { background: var(--blue-light); color: var(--blue); }
.status-pill.gray { background: var(--gray-light); color: var(--gray); }
.expiry-block { padding: 8px 12px; border-radius: var(--radius); background: var(--gray-light); text-align: center; }
.expiry-block.danger { background: var(--red-light); }
.expiry-block.warning { background: var(--amber-light); }
.expiry-label { display: block; font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.expiry-date { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.expiry-days { display: block; font-size: 12px; font-weight: 700; color: var(--red); }
.doc-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.meta-item { }
.meta-label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.meta-value { font-size: 13px; font-weight: 500; color: var(--text); }
.meta-value.mono { font-family: monospace; }
.tags-row { padding-top: 12px; border-top: 1px solid var(--border); margin-top: 12px; }

/* ── Workflow items ────────────────────────────────────── */
.workflow-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #F0F0F0; }
.workflow-item:last-child { border-bottom: none; }
.workflow-info { flex: 1; }
.workflow-ref { display: block; font-size: 11px; font-family: monospace; color: var(--text-muted); }
.workflow-title { display: block; font-size: 13px; font-weight: 500; color: var(--text); }
.workflow-meta { display: block; font-size: 11px; color: var(--text-muted); }
.wf-status { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.wf-label { font-size: 13px; color: var(--text); }

/* ── Activity ──────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item { display: flex; align-items: flex-start; gap: 10px; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-top: 4px; flex-shrink: 0; }
.activity-dot.expire { background: var(--red); }
.activity-dot.publie { background: var(--green); }
.activity-dot.en_relecture, .activity-dot.en_approbation { background: var(--amber); }
.activity-info { flex: 1; }
.activity-text { display: block; font-size: 13px; color: var(--text); }
.activity-meta { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ── Forms ─────────────────────────────────────────────── */
.form-layout { max-width: 800px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 13px; font-weight: 500; color: var(--text); }
.field input, .field select, .field textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-family: inherit; background: var(--surface); transition: border-color 0.15s; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); }
.field input[type="file"] { padding: 6px; }
.field-error { font-size: 11px; color: var(--red); }
.field-hint { font-size: 11px; color: var(--text-muted); }
.required { color: var(--red); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }

/* ── Pagination ────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; border-top: 1px solid var(--border); }
.page-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--blue); }
.page-info { font-size: 13px; color: var(--text-muted); }

/* ── Empty state ───────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 24px; color: var(--text-muted); text-align: center; }
.empty-state.small { padding: 24px; }
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 13px; }

/* ── Login page ────────────────────────────────────────── */
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background: var(--navy); }
.login-container { width: 100%; max-width: 380px; padding: 16px; }
.login-card { background: var(--surface); border-radius: var(--radius-lg); padding: 36px; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); margin: 10px 0 4px; }
.login-logo p { font-size: 13px; color: var(--text-muted); }
.login-form .field { margin-bottom: 16px; }
.login-form button { margin-top: 8px; }
.login-footer { text-align: center; font-size: 11px; color: rgba(255,255,255,0.3); margin-top: 16px; }

/* ── Text colors ───────────────────────────────────────── */
.danger-text { color: var(--red); }
.warning-text { color: var(--amber); }

/* ── Card alert sidebar ─────────────────────────────────────────────────── */
.card-alert { margin-bottom: 12px; }
.card-alert.danger { 
  border: 1px solid #FFCDD2;
  border-left: 4px solid var(--red);
  background: var(--red-light);
  padding: 14px 16px;
  border-radius: var(--radius-lg);
}
.card-alert.warning {
  border: 1px solid #FFCCBC;
  border-left: 4px solid var(--amber);
  background: var(--amber-light);
  padding: 14px 16px;
  border-radius: var(--radius-lg);
}
.card-alert .alert-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-alert .alert-title::before {
  content: '⚠';
  font-size: 14px;
}
.card-alert.danger .alert-title::before { content: '🔴'; }
.card-alert .alert-body {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

/* ── Doc header ─────────────────────────────────────────────────────────── */
.expiry-block {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--gray-light);
  text-align: center;
  min-width: 120px;
}
.expiry-block.danger { background: var(--red-light); border: 1px solid #FFCDD2; }
.expiry-block.warning { background: var(--amber-light); border: 1px solid #FFCCBC; }
.expiry-label { 
  display: block; 
  font-size: 10px; 
  color: var(--text-muted); 
  text-transform: uppercase; 
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.expiry-date { 
  display: block; 
  font-size: 15px; 
  font-weight: 600; 
  color: var(--text); 
}
.expiry-days { 
  display: block; 
  font-size: 12px; 
  font-weight: 700; 
  color: var(--red);
  margin-top: 2px;
}
.expiry-block.warning .expiry-days { color: var(--amber); }

/* ── Detail sidebar spacing ─────────────────────────────────────────────── */
.detail-sidebar > * { margin-bottom: 12px; }
.detail-sidebar > *:last-child { margin-bottom: 0; }

/* ── Modales admin GED ──────────────────────────────────────────────────── */
[id^="modal-"] {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 9999 !important;
  background: rgba(0, 0, 0, 0.6) !important;
  backdrop-filter: blur(2px);
  align-items: center !important;
  justify-content: center !important;
}

[id^="modal-"] > div {
  background: #ffffff !important;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35) !important;
  position: relative;
  z-index: 10000;
}

[id^="modal-"] .field input,
[id^="modal-"] .field select,
[id^="modal-"] .field textarea {
  background: #ffffff !important;
  border: 1px solid #B0BEC5 !important;
}

/* ── Sidebar collapsed ──────────────────────────────────────────────────── */
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed ~ .main-content { margin-left: 60px; }
.sidebar.collapsed .nav-text { display: none; }
.sidebar.collapsed .logo-text { display: none; }
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .user-details { display: none; }
.sidebar.collapsed .btn-logout { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sidebar-logo { justify-content: center; }
.sidebar.collapsed .sidebar-footer { justify-content: center; padding: 12px 0; }