/* Presence Sensor Dashboard - Dark Theme */

:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-card: #242424;
  --bg-hover: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #333333;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Screens */
.screen {
  min-height: 100vh;
  padding: 20px;
}

/* Login Screen */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  background: var(--bg-card);
  padding: 40px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-container h1 {
  text-align: center;
  margin-bottom: 30px;
  color: var(--accent);
}

.login-container input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 16px;
}

.login-container input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-container button {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
}

.toggle-auth {
  text-align: center;
  margin-top: 20px;
  color: var(--text-secondary);
}

.toggle-auth a {
  color: var(--accent);
  text-decoration: none;
}

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

header h1 {
  font-size: 24px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* Buttons */
button, .btn-primary, .btn-secondary {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  padding: 8px 0;
}

/* Summary Bar */
.summary-bar {
  background: var(--bg-card);
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Sensor Grid */
.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.sensor-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.sensor-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.sensor-card .name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.sensor-card .room {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
}

.sensor-card .status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.online {
  background: var(--success);
}

.status-dot.offline {
  background: var(--danger);
}

.status-dot.occupied {
  background: var(--warning);
}

/* Detail Screen */
.detail-header {
  margin-bottom: 24px;
}

.detail-header h2 {
  font-size: 28px;
  margin-bottom: 4px;
}

.room-label {
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.online {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.status-badge.offline {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius);
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Sections */
.section {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.section h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

/* Bar Chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 100px;
  padding-top: 10px;
}

.bar {
  flex: 1;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-width: 8px;
  position: relative;
}

.bar:hover::after {
  content: attr(data-value);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

/* Readings List */
.readings-list {
  max-height: 300px;
  overflow-y: auto;
}

.reading-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.reading-item:last-child {
  border-bottom: none;
}

.reading-time {
  color: var(--text-muted);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
}

.modal input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 16px;
}

.modal input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.device-info {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.device-info p {
  margin-bottom: 4px;
}

/* Error */
.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 600px) {
  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  
  .stat-card {
    padding: 12px 8px;
  }
  
  .stat-value {
    font-size: 18px;
  }
  
  .sensor-grid {
    grid-template-columns: 1fr;
  }
  
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .header-actions {
    width: 100%;
  }
  
  .header-actions button {
    flex: 1;
  }
}
