/* ============================================================
   ENERGIE SOFTWARE — DESIGN SYSTEM
   Palette: European energy-tech quality
   Blue: institutional trust / Amber: warmth-action / Teal: sustainability
   ============================================================ */

:root {
  /* --- Core palette --- */
  --clr-primary:        #2056A5;
  --clr-primary-light:  #3B82F6;
  --clr-primary-dark:   #163E87;
  --clr-primary-subtle: #EBF2FF;

  --clr-accent:         #E8A020;
  --clr-accent-light:   #FFF3DC;
  --clr-accent-dark:    #C47F0A;

  --clr-success:        #0A9E72;
  --clr-success-light:  #E6F7F2;
  --clr-warning:        #D97706;
  --clr-warning-light:  #FEF3C7;
  --clr-danger:         #DC2626;
  --clr-danger-light:   #FEE2E2;

  /* --- Surface / layout --- */
  --clr-bg:             #F4F7FB;
  --clr-surface:        #FFFFFF;
  --clr-border:         #E2E8F0;
  --clr-border-strong:  #CBD5E1;

  /* --- Typography --- */
  --clr-text:           #1A202C;
  --clr-text-muted:     #64748B;
  --clr-text-subtle:    #94A3B8;

  /* --- Spacing scale --- */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;

  /* --- Radius --- */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-full: 9999px;

  /* --- Shadow --- */
  --shadow-card:  0 1px 4px rgba(32,86,165,.08), 0 4px 16px rgba(32,86,165,.06);
  --shadow-hover: 0 4px 12px rgba(32,86,165,.14), 0 8px 28px rgba(32,86,165,.10);
  --shadow-modal: 0 20px 60px rgba(0,0,0,.18);

  /* --- Chart colours --- */
  --chart-1: #2056A5;
  --chart-2: #0A9E72;
  --chart-3: #E8A020;
  --chart-4: #7C3AED;
  --chart-5: #DC2626;
  --chart-6: #0891B2;
}

/* ============================================================
   GLOBAL BASE
   ============================================================ */

body {
  background: var(--clr-bg);
  color: var(--clr-text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.btn-primary   { background: var(--clr-primary); border-color: var(--clr-primary); }
.btn-primary:hover { background: var(--clr-primary-dark); border-color: var(--clr-primary-dark); }
.text-primary  { color: var(--clr-primary) !important; }
.bg-primary    { background: var(--clr-primary) !important; }
.border-primary{ border-color: var(--clr-primary) !important; }

/* ============================================================
   ES-CARD
   ============================================================ */

.es-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: box-shadow .18s ease, transform .18s ease;
}
.es-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.es-card-header {
  padding: var(--space-lg) var(--space-lg) var(--space-sm);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
  border-bottom: 1px solid var(--clr-border);
}
.es-card-body { padding: var(--space-lg); }

/* ============================================================
   KPI METRIC CARD
   ============================================================ */

.es-metric-card {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--clr-border);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: box-shadow .18s, transform .18s;
}
.es-metric-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.es-metric-card__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}
.es-metric-card__label {
  font-size: .72rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--clr-text-muted);
}
.es-metric-card__value {
  font-size: 1.75rem; font-weight: 700;
  color: var(--clr-text); line-height: 1;
}
.es-metric-card__sub  { font-size: .8rem; color: var(--clr-text-muted); }
.es-metric-card__delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: .75rem; font-weight: 600;
  padding: 2px 6px; border-radius: var(--radius-full);
}
.es-metric-card__delta--up   { background: var(--clr-danger-light);  color: var(--clr-danger); }
.es-metric-card__delta--down { background: var(--clr-success-light); color: var(--clr-success); }
.es-metric-card__delta--flat { background: var(--clr-border);        color: var(--clr-text-muted); }

.es-metric-card--primary .es-metric-card__icon { background: var(--clr-primary-subtle); color: var(--clr-primary); }
.es-metric-card--success .es-metric-card__icon { background: var(--clr-success-light);  color: var(--clr-success); }
.es-metric-card--accent  .es-metric-card__icon { background: var(--clr-accent-light);   color: var(--clr-accent-dark); }
.es-metric-card--warning .es-metric-card__icon { background: var(--clr-warning-light);  color: var(--clr-warning); }
.es-metric-card--danger  .es-metric-card__icon { background: var(--clr-danger-light);   color: var(--clr-danger); }

/* ============================================================
   BADGE SYSTEM
   ============================================================ */

.es-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: .72rem; font-weight: 600; letter-spacing: .03em;
}
.es-badge--paid,
.es-badge--active,
.es-badge--success  { background: var(--clr-success-light); color: var(--clr-success); }
.es-badge--open,
.es-badge--pending  { background: var(--clr-primary-subtle); color: var(--clr-primary); }
.es-badge--overdue,
.es-badge--danger   { background: var(--clr-danger-light);  color: var(--clr-danger); }
.es-badge--warning,
.es-badge--on-hold  { background: var(--clr-warning-light); color: var(--clr-warning); }
.es-badge--neutral  { background: var(--clr-border);        color: var(--clr-text-muted); }
.es-badge--accent   { background: var(--clr-accent-light);  color: var(--clr-accent-dark); }

.es-badge--pulse::before {
  content: '';
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor;
  margin-right: 5px;
  animation: es-pulse 1.8s ease-in-out infinite;
}
@keyframes es-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.85); }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.es-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--space-2xl) var(--space-xl);
  text-align: center; gap: var(--space-md);
}
.es-empty__icon {
  width: 72px; height: 72px;
  background: var(--clr-primary-subtle);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--clr-primary);
  margin-bottom: var(--space-sm);
}
.es-empty__title { font-size: 1.1rem; font-weight: 600; color: var(--clr-text); }
.es-empty__body  { font-size: .9rem; color: var(--clr-text-muted); max-width: 320px; }

/* ============================================================
   PROGRESS ARC
   ============================================================ */

.es-arc-ring { transform: rotate(-90deg); }
.es-arc-ring__bg    { fill: none; stroke: var(--clr-border); }
.es-arc-ring__track { fill: none; stroke: var(--clr-primary);
                      stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.4,0,.2,1); }
.es-arc-ring__track--warning { stroke: var(--clr-warning); }
.es-arc-ring__track--danger  { stroke: var(--clr-danger); }

/* ============================================================
   TIMELINE
   ============================================================ */

.es-timeline { display: flex; flex-direction: column; gap: 0; }
.es-timeline-step {
  display: flex; gap: var(--space-md);
  padding-bottom: var(--space-lg);
  position: relative;
}
.es-timeline-step:not(:last-child)::before {
  content: '';
  position: absolute; left: 15px; top: 32px;
  width: 2px; bottom: 0;
  background: var(--clr-border);
}
.es-timeline-step__dot {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--clr-border);
  background: var(--clr-surface);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: var(--clr-text-muted);
  z-index: 1;
}
.es-timeline-step--done   .es-timeline-step__dot { background: var(--clr-success); border-color: var(--clr-success); color: #fff; }
.es-timeline-step--active .es-timeline-step__dot { background: var(--clr-primary); border-color: var(--clr-primary); color: #fff;
  box-shadow: 0 0 0 4px var(--clr-primary-subtle); }
.es-timeline-step--warn   .es-timeline-step__dot { background: var(--clr-warning); border-color: var(--clr-warning); color: #fff; }
.es-timeline-step--danger .es-timeline-step__dot { background: var(--clr-danger);  border-color: var(--clr-danger);  color: #fff; }

.es-timeline-step__content { padding-top: 4px; }
.es-timeline-step__label   { font-size: .85rem; font-weight: 600; color: var(--clr-text); }
.es-timeline-step__meta    { font-size: .78rem; color: var(--clr-text-muted); margin-top: 2px; }

/* ============================================================
   FORM ENHANCEMENTS
   ============================================================ */

.es-input-hint {
  font-size: .78rem; color: var(--clr-text-muted);
  margin-top: var(--space-xs);
}
.es-input-hint--warn { color: var(--clr-warning); }
.es-input-hint--ok   { color: var(--clr-success); }

.form-control.es-input--anomaly {
  border-color: var(--clr-warning);
  background: var(--clr-warning-light);
  box-shadow: 0 0 0 3px rgba(217,119,6,.15);
}

/* ============================================================
   QUICK-ACTION CARD
   ============================================================ */

.es-quick-action {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: var(--space-sm);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-decoration: none; color: inherit;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.es-quick-action:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: var(--clr-primary-light);
  color: inherit; text-decoration: none;
}
.es-quick-action__icon {
  width: 44px; height: 44px;
  background: var(--clr-primary-subtle);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.es-quick-action__title { font-size: .9rem; font-weight: 600; }
.es-quick-action__desc  { font-size: .78rem; color: var(--clr-text-muted); }

/* ============================================================
   GRID HELPERS
   ============================================================ */

.es-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
}
.es-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
}

/* ============================================================
   CHART CONTAINERS
   ============================================================ */

.es-chart-wrap {
  position: relative;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
}
.es-chart-title {
  font-size: .78rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--clr-text-muted); margin-bottom: var(--space-md);
}

/* ============================================================
   BACKEND CS QUEUE PRIORITY BORDERS
   ============================================================ */

.es-priority-row { position: relative; }
.es-priority-row--urgent td:first-child { border-left: 4px solid var(--clr-danger); }
.es-priority-row--high   td:first-child { border-left: 4px solid var(--clr-warning); }
.es-priority-row--normal td:first-child { border-left: 4px solid var(--clr-primary-light); }
.es-priority-row--low    td:first-child { border-left: 4px solid var(--clr-border-strong); }

/* ============================================================
   ANIMATION
   ============================================================ */

@keyframes es-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.es-animate-in { animation: es-fade-up .35s ease both; }
.es-animate-in:nth-child(1) { animation-delay: .04s; }
.es-animate-in:nth-child(2) { animation-delay: .08s; }
.es-animate-in:nth-child(3) { animation-delay: .12s; }
.es-animate-in:nth-child(4) { animation-delay: .16s; }
.es-animate-in:nth-child(5) { animation-delay: .20s; }
.es-animate-in:nth-child(6) { animation-delay: .24s; }
