/* =========================================================================
   FlowIT — Style global
   Charte : alignée sur le logo FlowIT (bleu-pétrole, corail, mint, fond crème)
   Polices : Manrope (UI) + JetBrains Mono (codes/IDs)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Palette FlowIT — extraite directement du logo */
  --brand:        #234a5c;   /* bleu-pétrole du wordmark : couleur principale */
  --brand-deep:   #1a3848;   /* hover, accents foncés */
  --brand-soft:   #d6e3e7;   /* fond menus actifs */
  --brand-tint:   #eaf1f3;   /* fond très subtil */

  --accent:       #f4a07c;   /* orange corail des carrés du logo */
  --accent-deep:  #e08560;
  --accent-soft:  #fde4d4;   /* fond doux pour priorités, alertes chaudes */

  --mint:         #8ed4cc;   /* teal mint des petits carrés */
  --mint-deep:    #5fb5ab;
  --mint-soft:    #d8efeb;

  --amber:        #f5b773;   /* jaune doré du logo */
  --amber-soft:   #fde8c8;

  --red:          #d8453d;   /* rouge réchauffé, harmonisé avec l'orange */
  --red-soft:     #fbe1de;

  --green:        #5fb5ab;   /* succès = mint deep, cohérent avec le logo */
  --green-soft:   #d8efeb;

  --ink:          #1a2b34;   /* texte principal, harmonisé avec la marque */
  --ink-soft:     #2d4150;
  --muted:        #6b7e88;
  --muted-soft:   #a4b2ba;
  --border:       #e6e9ec;
  --border-soft:  #f2f4f6;
  --bg:           #fbf7f3;   /* fond crème du logo */
  --bg-deep:      #f5efe8;   /* fond plus prononcé pour zones */
  --white:        #ffffff;

  /* Aliases rétrocompat (utilisés dans certains composants) */
  --teal:         var(--brand);
  --teal-deep:    var(--brand-deep);
  --teal-soft:    var(--brand-soft);
  --orange:       var(--accent);
  --orange-soft:  var(--accent-soft);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 2px rgba(26,43,52,.05);
  --shadow:    0 1px 3px rgba(26,43,52,.06), 0 4px 12px -4px rgba(26,43,52,.06);
  --shadow-lg: 0 8px 24px -8px rgba(26,43,52,.16);

  --sidebar-w: 240px;
  --header-h:  64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-deep); }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* =========================================================================
   LOGIN
   ========================================================================= */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top left, rgba(35,74,92,.08), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(244,160,124,.10), transparent 50%),
    var(--bg);
}
.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  margin: 16px 0 4px;
  font-size: 22px;
  font-weight: 700;
}
.login-card p.lead {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 13px;
}
.login-card .logo { margin-bottom: 8px; }

/* =========================================================================
   APP SHELL
   ========================================================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.logo-img {
  height: 36px;
  width: auto;
  display: block;
}
.logo-img.lg { height: 64px; }
.logo-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(35,74,92,.30);
}
.logo-text {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--brand);
}
.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-soft);
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--border-soft); color: var(--ink); }
.nav-item.active {
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-weight: 600;
}
.nav-item.active svg { color: var(--teal-deep); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.nav-item .badge {
  margin-left: auto;
  background: var(--ink);
  color: var(--white);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.user-meta { line-height: 1.2; min-width: 0; flex: 1; }
.user-meta strong { font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 11px; color: var(--muted); }
.user-meta .role-tag { color: var(--teal-deep); font-weight: 600; text-transform: capitalize; }

.sidebar-saas {
  margin: 8px 12px 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-tint), var(--accent-soft));
  border: 1px solid var(--brand-soft);
}
.sidebar-saas h4 { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--brand-deep); }
.sidebar-saas p { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.4; }
.sidebar-saas .pill {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--white);
  text-transform: uppercase;
}

/* ----- Header ----- */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.header-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}
.header-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 13px;
}
.header-search input:focus {
  outline: none;
  border-color: var(--teal);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(35,74,92,.15);
}
.header-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--muted);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ----- Main content ----- */
.main { padding: 28px; min-width: 0; }

/* =========================================================================
   COMPONENTS
   ========================================================================= */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  background: var(--white);
  color: var(--ink);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: var(--teal-deep); }
.btn-secondary { background: var(--white); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--muted-soft); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--border-soft); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b03830; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; border: 1px solid var(--border); }
.btn-icon:hover { background: var(--bg); }

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.card-header h3 { margin: 0; font-size: 15px; font-weight: 700; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.kpi-delta { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--teal-deep); }
.kpi-delta.down { color: var(--red); }
.kpi-icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  display: flex; align-items: center; justify-content: center;
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi.alt .kpi-icon { background: var(--orange-soft); color: var(--accent-deep); }
.kpi.green .kpi-icon { background: var(--green-soft); color: var(--mint-deep); }
.kpi.red .kpi-icon   { background: var(--red-soft);   color: #a8362e; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr.row-clickable { cursor: pointer; }
.table tr.row-clickable:hover { background: var(--bg); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  line-height: 1.4;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* Status colors */
.b-status-open       { background: var(--red-soft);    color: #a8362e; }
.b-status-in_progress{ background: var(--amber-soft);  color: #b67d2c; }
.b-status-waiting    { background: #e0e7ff;            color: #4338ca; }
.b-status-resolved   { background: var(--green-soft);  color: var(--mint-deep); }

/* Priority colors */
.b-priority-low      { background: #f1f5f9;            color: #475569; }
.b-priority-medium   { background: #e0f2fe;            color: #075985; }
.b-priority-high     { background: var(--orange-soft); color: var(--accent-deep); }
.b-priority-urgent   { background: var(--red-soft);    color: #a8362e; }

/* Equipment status colors */
.b-status-in_service   { background: var(--green-soft);  color: var(--mint-deep); }
.b-status-in_stock     { background: #f1f5f9;            color: #475569; }
.b-status-maintenance  { background: var(--amber-soft);  color: #b67d2c; }
.b-status-broken       { background: var(--red-soft);    color: #a8362e; }
.b-status-retired      { background: #f1f5f9;            color: #94a3b8; }

/* Forms */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--white);
  color: var(--ink);
}
.form-row textarea { min-height: 90px; resize: vertical; font-family: inherit; }
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(35,74,92,.15);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .form-row { margin-bottom: 0; }
.form-row.full { grid-column: 1 / -1; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,43,52,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
  animation: fade-in .15s ease;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: pop-in .2s ease;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
@keyframes fade-in { from {opacity: 0} to {opacity: 1} }
@keyframes pop-in { from {opacity: 0; transform: scale(.96)} to {opacity:1; transform:scale(1)} }

/* Filters bar */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.filters select, .filters input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--white);
}
.filters input { min-width: 200px; }

/* Section grid (dashboard) */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

/* Detail layout */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
@media (max-width: 980px) { .detail-grid { grid-template-columns: 1fr; } }

/* Chat (ticket conversation) */
.chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.msg-bubble {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  max-width: 80%;
  font-size: 13px;
  line-height: 1.5;
}
.msg.mine { flex-direction: row-reverse; }
.msg.mine .msg-bubble {
  background: var(--teal-soft);
  border-color: rgba(35,74,92,.20);
  color: var(--teal-deep);
}
.msg.internal .msg-bubble {
  background: var(--amber-soft);
  border-color: #fcd34d;
}
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; }
.chat-input { display: flex; gap: 8px; margin-top: 14px; align-items: flex-end; }
.chat-input textarea {
  flex: 1;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  min-height: 60px;
}
.chat-input textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(35,74,92,.15); }

/* Detail sidebar */
.detail-side dl { margin: 0; }
.detail-side dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  margin-top: 14px;
}
.detail-side dt:first-child { margin-top: 0; }
.detail-side dd { margin: 4px 0 0; font-size: 13px; font-weight: 500; }

/* History list */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 12px;
  border-left: 3px solid var(--teal);
}
.history-item .field-name { font-weight: 700; color: var(--ink); }
.history-item time { color: var(--muted); margin-left: auto; }
.history-item .arrow { color: var(--muted); margin: 0 4px; }

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty svg { width: 40px; height: 40px; opacity: 0.4; margin-bottom: 8px; }

/* Alerts */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert.err  { background: var(--red-soft);    color: #991b1b; border: 1px solid #fecaca; }
.alert.ok   { background: var(--green-soft);  color: #065f46; border: 1px solid #a7f3d0; }
.alert.info { background: var(--teal-soft);   color: var(--teal-deep); border: 1px solid rgba(35,74,92,.25); }
.alert.warn { background: var(--amber-soft);  color: #87501c; border: 1px solid #fcd34d; }

/* Toasts */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--ink);
  color: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slide-in .25s ease;
  max-width: 320px;
}
.toast.err { background: var(--red); }
.toast.ok  { background: var(--teal); }
@keyframes slide-in { from {opacity: 0; transform: translateX(20px);} to {opacity:1; transform: translateX(0);} }

/* Utility */
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12px; }
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.gap-2      { gap: 6px; }
.gap-3      { gap: 10px; }
.gap-4      { gap: 14px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-2 { margin-top: 6px; }
.mt-3 { margin-top: 10px; }
.mt-4 { margin-top: 14px; }
.mb-2 { margin-bottom: 6px; }
.mb-3 { margin-bottom: 10px; }
.mb-4 { margin-bottom: 14px; }

/* Loading skeleton */
.skel {
  background: linear-gradient(90deg, var(--border-soft) 0%, var(--border) 50%, var(--border-soft) 100%);
  background-size: 200% 100%;
  animation: skeleton 1.2s ease-in-out infinite;
  border-radius: var(--radius);
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Charts (simple SVG / canvas containers) */
.chart-wrap { position: relative; height: 240px; }

/* Responsive */
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 18px; }
  .header { padding: 0 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .header-search { display: none; }
}
