/* =============================================================================
   Twecto Cloud Platform - shared dashboard styling
   Carries over the teal/dark branding from Data Insight Tracker (DI Tracker)
   but restructured around a sidebar + fleet-of-devices layout.
============================================================================= */

:root {
  --tw-dark: #00424e;
  --tw-accent: #1abc9c;
  --tw-accent-dark: #16a085;
  --tw-blue: #3498db;
  --tw-bg: #ecf0f1;
  --tw-card-border: #dfe6e9;
  --tw-danger: #e74c3c;
  --tw-warning: #f39c12;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Roboto", sans-serif;
  background-color: var(--tw-bg);
  color: #2c3e50;
}

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

/* ---------------------------------------------------------------- Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background-color: var(--tw-dark);
  background-image: url("../assets/cubes1.png");
  background-repeat: repeat;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 10px;
}

.sidebar .brand img {
  width: 32px;
  height: 32px;
}

.sidebar .brand span {
  font-weight: 700;
  font-size: 18px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  font-size: 15px;
  color: #d9f4ef;
  transition: background-color 0.15s ease;
}

.sidebar nav a i {
  width: 18px;
  text-align: center;
}

.sidebar nav a:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.sidebar nav a.active {
  background-color: var(--tw-accent);
  color: #fff;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 20px 28px;
}

/* ---------------------------------------------------------------- Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-header h1 {
  margin: 0;
  font-size: 22px;
}

.page-header .meta {
  font-size: 13px;
  color: #607d8b;
}

.header-context {
  display: flex;
  flex-direction: column;
}

.header-context .client-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--tw-dark);
}

/* ---------------------------------------------------------------- Cards */
.summary-cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.summary-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px 22px;
  min-width: 150px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-card .label {
  font-size: 13px;
  color: #607d8b;
}

.summary-card .value {
  font-size: 28px;
  font-weight: 700;
}

.summary-card.connected .value { color: var(--tw-accent-dark); }
.summary-card.disconnected .value { color: var(--tw-danger); }
.summary-card.unconnected .value { color: #95a5a6; }

/* ---------------------------------------------------------------- Devices list */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input, .toolbar select {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--tw-card-border);
  font-size: 14px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.device-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border-left: 4px solid #95a5a6;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.device-card:hover {
  transform: translateY(-2px);
}

.device-card.connected { border-left-color: var(--tw-accent); }
.device-card.disconnected { border-left-color: var(--tw-danger); }

.device-card .device-code {
  font-weight: 700;
  font-size: 16px;
}

.device-card .device-type {
  font-size: 12px;
  color: #607d8b;
  margin-bottom: 8px;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.connected { background: var(--tw-accent); }
.status-dot.disconnected { background: var(--tw-danger); }
.status-dot.unconnected { background: #bdc3c7; }

/* ---------------------------------------------------------------- Sensor carousel */
.sensor-carousel {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 20px;
}

.sensor-card {
  flex: 0 0 170px;
  border-radius: 14px;
  padding: 16px;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.sensor-card .param-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.sensor-card .param-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 8px;
}

.sensor-card .param-unit {
  font-size: 13px;
  opacity: 0.85;
}

.sensor-card .corrected-badge {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 2px 6px;
  margin-top: 6px;
  display: inline-block;
}

/* gradient palette cycled across cards, similar to the reference dashboard */
.sensor-card.g0 { background: linear-gradient(135deg, #56ab2f, #a8e063); }
.sensor-card.g1 { background: linear-gradient(135deg, #2193b0, #6dd5ed); }
.sensor-card.g2 { background: linear-gradient(135deg, #cb2d3e, #ef473a); }
.sensor-card.g3 { background: linear-gradient(135deg, #00b09b, #96c93d); }
.sensor-card.g4 { background: linear-gradient(135deg, #ff8008, #ffc837); }
.sensor-card.g5 { background: linear-gradient(135deg, #8e2de2, #4a00e0); }

/* ---------------------------------------------------------------- Panels */
.panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 20px;
}

.panel h2 {
  margin-top: 0;
  font-size: 16px;
}

.chart-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

#map {
  height: 220px;
  border-radius: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

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

/* ---------------------------------------------------------------- Forms/buttons */
.button {
  padding: 10px 18px;
  font-size: 14px;
  background-color: var(--tw-blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.button:hover { background-color: #2980b9; }
.button.accent { background-color: var(--tw-accent); }
.button.accent:hover { background-color: var(--tw-accent-dark); }
.button.danger { background-color: var(--tw-danger); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table th, table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--tw-card-border);
}

/* ---------------------------------------------------------------- Login page */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--tw-dark);
  background-image: url("../assets/hexagons.svg");
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 40px;
  width: 340px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.login-card img {
  width: 56px;
  margin-bottom: 10px;
}

.login-card input {
  width: 100%;
  padding: 12px 14px;
  margin-top: 12px;
  border-radius: 8px;
  border: 1px solid var(--tw-card-border);
  font-size: 14px;
}

.login-card .button {
  width: 100%;
  margin-top: 18px;
}

.error-text {
  color: var(--tw-danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 16px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.badge.info { background: #d6eaf8; color: #2471a3; }
.badge.warning { background: #fdebd0; color: #b9770e; }
.badge.critical { background: #fadbd8; color: #c0392b; }
