/* ============================================================
   components.css — Composants UI réutilisables
   Broadpeak CRM Design System
   ============================================================ */

/* ── Boutons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: var(--font-body);
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--color-blue); color: white; }
.btn-primary:hover { background: var(--color-blue-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,86,219,.35); }

.btn-ghost-dark { background: var(--surface-base); color: var(--text-secondary); border: 1px solid var(--border-dark); }
.btn-ghost-dark:hover { background: var(--surface-hover); color: var(--text-primary); }

.btn-ghost-light { background: var(--color-gray100); color: var(--color-gray600); border: 1px solid var(--border-light); }
.btn-ghost-light:hover { background: var(--color-gray200); }

.btn-danger { background: var(--color-red); color: white; }
.btn-danger:hover { background: #c53030; }

.btn-sm { padding: .35rem .75rem; font-size: .8125rem; }
.btn-lg { padding: .625rem 1.375rem; font-size: .9375rem; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .175rem .5rem;
  border-radius: 20px;
  font-size: .6875rem;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge-active     { background: #dcfce7; color: #166534; }
.badge-inactive   { background: #fef9c3; color: #854d0e; }
.badge-eol        { background: #fee2e2; color: #991b1b; }
.badge-deprecated { background: #f3e8ff; color: #6b21a8; }

/* ── Dot de statut ── */
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.up     { background: var(--color-green); animation: pulse 2s infinite; }
.status-dot.down   { background: var(--color-red); }
.status-dot.warn   { background: var(--color-orange); }
.status-dot.pause  { background: var(--color-gray400); }

/* ── Cards ── */
.card {
  background: var(--surface-light);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-dark {
  background: var(--color-navy2);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ── Stat cards ── */
.stat-card {
  background: var(--surface-light);
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.25rem;
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-accent, var(--color-blue));
}
.stat-label { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--color-gray600); }
.stat-value { font-family: var(--font-head); font-size: 1.875rem; font-weight: 800; color: var(--color-navy); line-height: 1.1; margin: .2rem 0 .1rem; }
.stat-sub   { font-size: .75rem; color: var(--color-gray400); }

/* ── Table card ── */
.table-card { background: var(--surface-light); border-radius: var(--radius-lg); border: 1px solid var(--border-light); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-toolbar { padding: .875rem 1.25rem; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--color-gray50);
  padding: .625rem 1rem;
  text-align: left;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--color-gray600);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--color-gray100); transition: background .1s; }
tbody tr:hover { background: var(--color-gray50); }
tbody tr:last-child { border-bottom: none; }
td { padding: .75rem 1rem; font-size: .875rem; color: var(--color-gray800); vertical-align: middle; }
.cell-primary   { font-weight: 600; color: var(--color-navy); }
.cell-secondary { font-size: .75rem; color: var(--color-gray400); margin-top: .1rem; }

/* ── Row actions ── */
.row-actions { display: flex; gap: .25rem; opacity: 0; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }
.icon-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .8125rem;
  transition: var(--transition);
  color: var(--color-gray600);
}
.icon-btn:hover       { border-color: var(--color-blue); background: #eff6ff; color: var(--color-blue); }
.icon-btn.danger:hover{ border-color: var(--color-red);  background: #fff5f5; color: var(--color-red); }

/* ── Search box ── */
.search-box {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--color-gray100);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: .4rem .75rem;
}
.search-box input { border: none; background: transparent; outline: none; font-size: .875rem; font-family: var(--font-body); color: var(--color-gray800); width: 100%; }
.search-box input::placeholder { color: var(--color-gray400); }

/* ── Filter select ── */
.filter-select {
  padding: .4rem .75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  font-family: var(--font-body);
  color: var(--color-gray600);
  background: white;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}
.filter-select:focus { border-color: var(--color-blue); }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .875rem; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.span-2 { grid-column: span 2; }

label { font-size: .8125rem; font-weight: 600; color: var(--color-gray600); }
label .req { color: var(--color-red); margin-left: .15rem; }

input[type=text],
input[type=email],
input[type=date],
input[type=password],
select,
textarea {
  padding: .5rem .75rem;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: var(--font-body);
  color: var(--color-gray800);
  background: white;
  transition: border-color .15s;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(26,86,219,.08);
}
textarea { resize: vertical; min-height: 72px; }

.form-section-title {
  font-family: var(--font-head);
  font-size: .8125rem;
  font-weight: 700;
  color: var(--color-navy);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--color-blue);
  margin: 1rem 0 .75rem;
  display: inline-block;
  grid-column: span 2;
}

.field-error { font-size: .75rem; color: var(--color-red); margin-top: .2rem; display: none; }
.field-error.show { display: block; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,22,40,.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius-xl);
  width: 680px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
.modal-sm { width: 420px; }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0;
  background: white;
  z-index: 1;
}
.modal-title { font-family: var(--font-head); font-size: 1.0625rem; font-weight: 700; color: var(--color-navy); }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border-light);
  background: white;
  cursor: pointer;
  font-size: .875rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  color: var(--color-gray600);
}
.modal-close:hover { background: var(--color-gray100); }

.modal-body   { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex; gap: .75rem; justify-content: flex-end;
  position: sticky; bottom: 0;
  background: white;
}

/* ── Loading spinner ── */
.loading-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,22,40,.4);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.loading-overlay.show { display: flex; }
.spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: var(--color-cyan);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 999;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: var(--color-navy);
  color: white;
  padding: .75rem 1.125rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  display: flex; align-items: center; gap: .625rem;
  box-shadow: var(--shadow-md);
  animation: toastIn .25s ease;
  border-left: 4px solid var(--color-green);
  max-width: 340px;
}
.toast.error   { border-left-color: var(--color-red); }
.toast.warning { border-left-color: var(--color-orange); }

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--color-gray100) 25%, var(--color-gray200) 50%, var(--color-gray100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-sm);
}

/* ── Empty state ── */
.empty-state { padding: 3rem; text-align: center; color: var(--color-gray400); }
.empty-icon  { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-text  { font-size: .9375rem; font-weight: 500; }

/* ── Pagination ── */
.pagination {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-info { font-size: .8125rem; color: var(--color-gray600); }
.page-btns { display: flex; gap: .375rem; }
.page-btn {
  padding: .3rem .625rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: white;
  font-size: .8125rem;
  cursor: pointer;
  color: var(--color-gray600);
  font-family: var(--font-body);
  transition: var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--color-blue); color: white; border-color: var(--color-blue); }

/* ── Tile (homepage) ── */
.tile {
  background: var(--color-navy2);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  padding: 1rem 1.125rem;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}
.tile:hover { border-color: var(--border-dark-hover); background: var(--color-navy3); }

.tile-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.accent-blue   { background: var(--accent-blue); }
.accent-cyan   { background: var(--accent-cyan); }
.accent-purple { background: var(--accent-purple); }
.accent-orange { background: var(--accent-orange); }
.accent-green  { background: var(--accent-green); }
.accent-red    { background: var(--accent-red); }
.accent-gray   { background: var(--accent-gray); }

.tile-head { display: flex; align-items: center; justify-content: space-between; }
.tile-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icon-blue   { background: var(--icon-blue); }
.icon-cyan   { background: var(--icon-cyan); }
.icon-purple { background: var(--icon-purple); }
.icon-orange { background: var(--icon-orange); }
.icon-green  { background: var(--icon-green); }
.icon-red    { background: var(--icon-red); }
.icon-gray   { background: var(--icon-gray); }

.tile-status { display: flex; align-items: center; gap: .3rem; font-size: .6875rem; font-weight: 600; color: #68d391; }
.tile-status .status-dot { background: var(--color-green); }

.tile-name { font-family: var(--font-head); font-weight: 700; font-size: .9375rem; color: white; }
.tile-desc { font-size: .75rem; color: var(--text-secondary); line-height: 1.4; }
.tile-url  { font-size: .6875rem; font-family: var(--font-mono); color: var(--text-muted); margin-top: .1rem; }

.tile-arrow {
  position: absolute; bottom: .75rem; right: .875rem;
  font-size: .75rem; color: var(--text-muted);
  opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-arrow { opacity: 1; }
.tile-static { cursor: default; }
.tile-static:hover { border-color: var(--border-dark); background: var(--color-navy2); }
