/* General */
* {
  box-sizing: border-box;
}
canvas {
  max-width: 100%;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f4f6f9;
}
main{
  min-height: 100vh;
}

header {
  background: #1e293b;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 767px) {
  header h1 {
    font-size: 1.2rem;
  }
}


button {
  padding: 0.5rem 1rem;
  border: none;
  background: #2563eb;
  color: white;
  cursor: pointer;
  border-radius: 4px;
}

/* Login */
.login-body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.login-card {
  background: white;
  padding: 2rem;
  width: 300px;
  border-radius: 6px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.login-card input {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.6rem;
}

.error {
  color: red;
  font-size: 0.9rem;
}

/* Dashboard */
.cards-grid {
  padding: 2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.card {
  background: white;
  padding: 1rem;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: transform 0.15s ease;
}

.card:hover{
  transform: translateY(-4px);
}

/* Force consistent card width when displayed in a row */
.cards-grid .card {
  flex: 0 0 260px;
  width: 260px;
}

.status-activo {
  border-left: 6px solid #16a34a;
}

.status-enmantenimiento {
  border-left: 6px solid #f59e0b;
}

.status-inactivo {
  border-left: 6px solid #dc2626;
}

.device-detail {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.5rem;
}

@media (max-width: 1023px) {
  .device-detail {
    grid-template-columns: 1fr;
  }

  .device-chart canvas {
    width: 100%;
    height: auto;
  }
}


.device-info {
  background: white;
  padding: 1.5rem;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.device-chart {
  background: white;
  padding: 1.5rem;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* KPIs */
.kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

@media (max-width: 767px) {
  .kpis {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi p {
    font-size: 1.2rem;
  }
}


.kpi {
  background: white;
  padding: 1rem;
  text-align: center;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.kpi p {
  font-size: 1.4rem;
  font-weight: bold;
}

/* Actions */
.actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

.action-btn.warning {
  background: #f59e0b;
}

.action-btn.danger {
  background: #dc2626;
}

/* Logs */
.device-logs table {
  width: 100%;
  border-collapse: collapse;
}

.device-logs {
  overflow-x: auto;
}

.device-logs table {
  min-width: 500px;
}

@media (max-width: 767px) {
  .actions {
    flex-direction: column;
  }

  .actions button {
    width: 100%;
  }
}


.device-logs th,
.device-logs td {
  padding: 0.6rem;
  border-bottom: 1px solid #ddd;
}

.log-warning {
  background: #fff7ed;
}

.log-info {
  background: #f0f9ff;
}

.ws {
  font-weight: bold;
}

.ws.online {
  color: #16a34a;
}

.ws.offline {
  color: #dc2626;
}

.system-status {
  padding: 1.5rem;
  display: grid;
  gap: 2rem;
}

.system-health {
  background: white;
  padding: 1.5rem;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.health.ok {
  color: #16a34a;
  font-weight: bold;
}

.health.warning {
  color: #f59e0b;
  font-weight: bold;
}

.last-update {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #555;
}

.alerts-summary ul {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 6px;
  list-style: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.alerts-summary li {
  padding: 0.4rem 0;
  border-bottom: 1px solid #eee;
}

.navbar {
  height: 60px;
  background: #1e1e2f;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  font-weight: bold;
  font-size: 1.1rem;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1rem;
}

.nav-links a {
  color: white;
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 4px;
}

.nav-links a:hover {
  background: #333;
}

.logout {
  color: #ff6b6b;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .nav-links {
    position: absolute;
    top: 60px;
    right: 0;
    background: #1e1e2f;
    flex-direction: column;
    width: 200px;
    display: none;
    padding: 1rem;
  }

  .nav-links.show {
    display: flex;
  }
}

.buildings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.building-card {
  background: white;
  border-radius: 10px;
  padding: 1.2rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  transition: transform 0.15s ease;
}

.building-card:hover {
  transform: translateY(-4px);
}

.building-title {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.building-stats {
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.building-stats span {
  display: block;
}

.building-actions {
  text-align: right;
}

.building-actions button {
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.users-controls {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
}

.users-controls input {
  flex: 1;
  padding: 0.5rem;
}

.users-controls button {
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.users-table-container {
  overflow-x: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.users-table th,
.users-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.users-table th {
  background: #f5f5f5;
}

.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
}

.badge.active {
  background: #d4edda;
  color: #155724;
}

.badge.inactive {
  background: #f8d7da;
  color: #721c24;
}

.role {
  font-weight: bold;
}

.users-table-container {
  overflow-x: auto;
}

.footer {
  background: #1e1e2f;
  color: #aaa;
  font-size: 0.85rem;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background: #4caf50;
}

.disclaimer-content {
  max-width: 800px;
  margin: 2rem auto;
  background: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  line-height: 1.6;
}

.disclaimer-content p {
  margin-bottom: 1rem;
}
