
/* ==================================
   PLC MONITORING DASHBOARD
   Modern dark dashboard + Inter font
   ================================== */

:root {
  --bg: #0b1425;
  --panel: #13233b;
  --panel-hover: #192d49;
  --text: #f3f7ff;
  --muted: #9aafce;
  --blue: #65a9ff;
  --cyan: #5ce1e6;
  --green: #55d6a0;
  --red: #ff929c;
  --border: rgba(255, 255, 255, 0.09);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background:
    radial-gradient(
      circle at 10% 0%,
      rgba(49, 105, 190, 0.22),
      transparent 38%
    ),
    linear-gradient(145deg, #0b1425, #101c31 60%, #081222);
  line-height: 1.6;
}

/* Page layout */

.container {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

/* Header */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0 26px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.05em;
}

header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

h2 {
  margin: 0 0 18px;
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.04em;
}

h3 {
  margin-top: 0;
}

p {
  overflow-wrap: anywhere;
}

section {
  margin: 30px 0;
}

/* PLC connection status */

#connection,
.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  padding: 8px 14px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

#connection::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Optional status classes for app.js */

#connection.connected {
  color: var(--green);
  background: rgba(85, 214, 160, 0.1);
  border-color: rgba(85, 214, 160, 0.22);
}

#connection.disconnected {
  color: var(--red);
  background: rgba(255, 100, 120, 0.1);
  border-color: rgba(255, 100, 120, 0.22);
}

/* Backend error message */

#error {
  margin: 0 0 24px;
  padding: 12px 16px;
  color: var(--red);
  background: rgba(255, 100, 120, 0.09);
  border: 1px solid rgba(255, 100, 120, 0.2);
  border-radius: 12px;
  font-size: 0.9rem;
}

#error:empty {
  display: none;
}

/* Current reading cards */

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.cards:empty {
  display: block;
  min-height: 40px;
}

.cards > * {
  min-width: 0;
  padding: 24px;
  overflow-wrap: anywhere;
  background: linear-gradient(
    145deg,
    rgba(25, 45, 73, 0.96),
    rgba(17, 32, 54, 0.96)
  );
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
  transition: transform 180ms ease, border-color 180ms ease;
}

.cards > *:hover {
  transform: translateY(-3px);
  border-color: rgba(101, 169, 255, 0.42);
}

.cards h3 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.cards p {
  margin: 0;
}

.cards strong,
.cards .value,
.cards .reading-value,
.cards .metric-value {
  color: var(--text);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.unit,
.metric-unit {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0;
}

/* History controls */

label {
  display: inline-block;
  margin: 0 10px 12px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

button,
select,
input {
  font: inherit;
}

select,
input {
  max-width: 100%;
  padding: 10px 12px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
}

button {
  padding: 11px 16px;
  margin: 0 8px 12px 0;
  color: white;
  background: linear-gradient(135deg, #3985f5, #536dfe);
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease;
}

button:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

/* Historical readings table */

.table-wrap {
  width: 100%;
  margin-top: 10px;
  overflow-x: auto;
  background: rgba(19, 35, 59, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
}

thead {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

tbody {
  color: #dce8fb;
  font-size: 0.9rem;
}

tbody tr {
  transition: background 150ms ease;
}

tbody tr:hover {
  background: rgba(101, 169, 255, 0.06);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Responsive design */

@media (max-width: 850px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .container {
    width: calc(100% - 28px);
    padding-top: 20px;
  }

  header {
    align-items: flex-start;
    flex-direction: column;
    padding-bottom: 20px;
  }

  section {
    margin-top: 24px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .cards > * {
    padding: 19px;
  }

  th,
  td {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
