/* frontend/css/app.css */
/* Auteur : M. HEMERY */

:root {
  color-scheme: dark;
  --background: #07101d;
  --sidebar: #081220;
  --surface: #101b2c;
  --surface-soft: #0c1727;
  --surface-hover: #14243a;
  --border: rgba(128, 157, 197, 0.2);
  --border-strong: rgba(62, 129, 255, 0.45);
  --text: #f5f8ff;
  --muted: #8f9db1;
  --blue: #3b82f6;
  --cyan: #06b6d4;
  --red: #ef4444;
  --purple: #8b5cf6;
  --yellow: #fbbf24;
  --green: #22c55e;
  --orange: #f59e0b;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.27);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  min-width: 320px;
  max-width: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 74% -10%, rgba(37, 99, 235, 0.12), transparent 30rem),
    var(--background);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.dashboard-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 27px 18px 22px;
  border-right: 1px solid var(--border);
  background:
    radial-gradient(circle at 20% 90%, rgba(37, 99, 235, 0.19), transparent 19rem),
    var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 10px 33px;
  font-size: 1.55rem;
  letter-spacing: -0.04em;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 2px solid #2563eb;
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(37, 99, 235, 0.36);
}

.brand-mark::before,
.brand-mark span {
  content: "";
  border-radius: 50%;
  border: 3px solid #38bdf8;
}

.brand-mark::before {
  width: 23px;
  height: 23px;
  border-top-color: transparent;
}

.brand-mark span {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #38bdf8;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  color: #b6c0d1;
  border: 1px solid transparent;
  border-radius: 11px;
  transition: 160ms ease;
}

.nav-link:hover,
.nav-link--active {
  color: white;
  border-color: rgba(59, 130, 246, 0.2);
  background: linear-gradient(100deg, rgba(37, 99, 235, 0.4), rgba(37, 99, 235, 0.18));
}

.nav-icon {
  width: 22px;
  color: #dbeafe;
  font-size: 1.18rem;
  text-align: center;
}

.system-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: auto;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(15, 27, 45, 0.75);
}

.system-card div {
  display: grid;
  gap: 3px;
}

.system-card strong {
  font-size: 0.82rem;
}

.system-card small {
  color: var(--muted);
  font-size: 0.71rem;
}

.system-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
}

.dashboard-main {
  width: min(100%, 1600px);
  min-width: 0;
  padding: 28px 34px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 2px 0 4px;
  font-size: clamp(2rem, 4vw, 2.75rem);
  letter-spacing: -0.045em;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.eyebrow,
.panel-kicker {
  color: #60a5fa !important;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.import-button,
.primary-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 0 23px;
  color: white;
  font-weight: 750;
  cursor: pointer;
  border: 1px solid #3b82f6;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.24), rgba(30, 64, 175, 0.13));
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.22), inset 0 0 20px rgba(37, 99, 235, 0.08);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 16px;
}

.source-stat-cards {
  display: contents;
}

.stat-card,
.panel {
  min-width: 0;
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(18, 31, 51, 0.98), rgba(11, 22, 38, 0.98));
  box-shadow: var(--shadow);
}

.stat-card {
  position: relative;
  min-height: 157px;
  padding: 18px 17px;
  overflow: hidden;
  border-radius: 11px;
}

.stat-card::after {
  position: absolute;
  right: -28px;
  bottom: -48px;
  width: 120px;
  height: 120px;
  content: "";
  border-radius: 50%;
  background: currentColor;
  opacity: 0.045;
  filter: blur(2px);
}

.stat-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dce6f5;
  font-size: 0.82rem;
}

.stat-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: currentColor;
  font-size: 0.83rem;
  font-weight: 850;
  border-radius: 10px;
  background: color-mix(in srgb, currentColor 18%, transparent);
}

.stat-card strong {
  display: block;
  margin-top: 18px;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.stat-card small {
  display: block;
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.7rem;
}

.stat-card .stat-trend {
  margin-top: 8px;
  font-weight: 750;
}

.trend--up {
  color: #34d399 !important;
}

.trend--down {
  color: #fb7185 !important;
}

.trend--neutral {
  color: var(--muted) !important;
}

.stat-card--blue { color: var(--blue); border-bottom-color: var(--blue); }
.stat-card--cyan { color: var(--cyan); border-bottom-color: var(--cyan); }
.stat-card--red { color: var(--red); border-bottom-color: var(--red); }
.stat-card--purple { color: var(--purple); border-bottom-color: var(--purple); }
.stat-card--green { color: var(--green); border-bottom-color: var(--green); }
.stat-card--orange { color: var(--orange); border-bottom-color: var(--orange); }
.stat-card--yellow { color: var(--yellow); border-bottom-color: var(--yellow); }
.stat-card--sla { transition: color 180ms ease, border-color 180ms ease; }
.sla-status--good { color: var(--green); border-bottom-color: var(--green); }
.sla-status--warning { color: var(--orange); border-bottom-color: var(--orange); }
.sla-status--critical { color: var(--red); border-bottom-color: var(--red); }
.sla-status--neutral { color: var(--muted); border-bottom-color: var(--muted); }

.stat-heading,
.stat-card strong {
  color: var(--text);
}

.stat-card--blue .stat-icon { color: var(--blue); }
.stat-card--cyan .stat-icon { color: var(--cyan); }
.stat-card--red .stat-icon { color: var(--red); }
.stat-card--purple .stat-icon { color: var(--purple); }
.stat-card--green .stat-icon { color: var(--green); }
.stat-card--orange .stat-icon { color: var(--orange); }
.stat-card--yellow .stat-icon { color: var(--yellow); }
.stat-card--sla .stat-icon,
.stat-card--sla strong { color: inherit; }

.panel {
  border-radius: 12px;
}

.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 12px;
  margin-bottom: 16px;
}

.chart-panel,
.table-panel,
.upload-panel,
.imports-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-size: 1.05rem;
}

.panel-kicker {
  margin: 0;
}

.chart-container {
  position: relative;
  height: 285px;
}

.empty-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  pointer-events: none;
}

.table-panel {
  margin-bottom: 16px;
}

.data-count {
  padding: 6px 9px;
  color: #aab7ca;
  font-size: 0.69rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(4, 10, 19, 0.3);
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  align-content: center;
  text-align: center;
}

.empty-state h3 {
  margin: 12px 0 5px;
}

.empty-state p,
.panel-description,
.imports-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.08);
}

.table-wrapper {
  width: 100%;
  max-height: 490px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  font-size: 0.75rem;
}

th,
td {
  max-width: 260px;
  padding: 10px 12px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-bottom: 1px solid rgba(128, 157, 197, 0.12);
}

th {
  position: sticky;
  z-index: 1;
  top: 0;
  color: #b9c7da;
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #132035;
}

tbody tr:hover {
  background: var(--surface-hover);
}

.source-badge,
.latest-badge {
  display: inline-flex;
  padding: 4px 7px;
  color: #60a5fa;
  font-size: 0.66rem;
  font-weight: 800;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 5px;
  background: rgba(37, 99, 235, 0.12);
}

.imports-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
}

.upload-form {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 17px;
}

.client-picker {
  display: grid;
  gap: 4px;
}

.client-picker span {
  color: var(--muted);
  font-size: 0.67rem;
}

.client-picker select {
  min-height: 46px;
  padding: 0 11px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.client-badge {
  padding: 4px 7px;
  color: #bfdbfe;
  font-size: 0.65rem;
  font-weight: 800;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 5px;
  background: rgba(59, 130, 246, 0.1);
}

#csv-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.file-picker {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
  padding: 11px 13px;
  cursor: pointer;
  border: 1px dashed rgba(96, 165, 250, 0.34);
  border-radius: 8px;
  background: rgba(5, 12, 22, 0.42);
}

.file-picker span {
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-picker small {
  color: var(--muted);
  font-size: 0.67rem;
}

.primary-button {
  border: 1px solid var(--blue);
}

.primary-button:disabled,
.danger-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.message {
  min-height: 18px;
  margin-top: 10px;
  font-size: 0.74rem;
}

.message--success { color: var(--green); }
.message--error { color: var(--red); }

.imports-list {
  display: grid;
  gap: 7px;
}

.import-item {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 12, 22, 0.36);
}

.import-details {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.import-details strong {
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-details span {
  color: var(--muted);
  font-size: 0.66rem;
}

.import-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.danger-button {
  padding: 7px 10px;
  color: #fda4af;
  font-weight: 750;
  cursor: pointer;
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.08);
}

footer {
  padding: 24px 0 4px;
  color: #56667d;
  font-size: 0.68rem;
  text-align: center;
}

@media (max-width: 1280px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    z-index: 10;
    height: auto;
    padding: 14px 18px;
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand {
    padding: 0;
    font-size: 1.1rem;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .sidebar-nav {
    display: flex;
    margin-left: auto;
  }

  .nav-link {
    padding: 9px 11px;
    font-size: 0.77rem;
  }

  .nav-icon,
  .system-card {
    display: none;
  }

  .dashboard-main {
    padding: 22px 20px 34px;
  }

  .charts-grid,
  .imports-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .sidebar-nav {
    width: 100%;
    margin: 0;
    overflow-x: auto;
  }

  .nav-link {
    flex: 0 0 auto;
  }

  .dashboard-main {
    padding: 18px 10px 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .import-button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-card {
    min-height: 142px;
    padding: 14px;
  }

  .charts-grid {
    gap: 10px;
  }

  .chart-panel,
  .table-panel,
  .upload-panel,
  .imports-panel {
    padding: 14px;
  }

  .chart-container {
    height: 245px;
  }

  .upload-form {
    grid-template-columns: 1fr;
  }

  .import-item {
    align-items: stretch;
    flex-direction: column;
  }

  .import-actions {
    justify-content: space-between;
  }
}

@media (max-width: 390px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
