/* Custom Styles for IoT Dashboard */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
}

@media (min-width: 1025px) {
  body {
    overflow: hidden;
  }
}

@media (max-width: 1024px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }
}

.dashboard-container {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1rem;
  padding: 1rem;
  box-sizing: border-box;
}

@media (max-width: 1024px) {
  .dashboard-container {
    height: auto;
    min-height: 100vh;
    padding: 1rem;
  }
}

.control-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  height: 100%;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  height: calc(100vh - 200px);
  align-items: stretch;
}

.led-section, .sensor-section, .chart-section {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.led-section > *, .sensor-section > *, .chart-section > * {
  flex-shrink: 0;
}

/* LED section specific - chia đều giữa LED control và Time */
.led-section {
  justify-content: space-between;
}

.led-section > h2:first-child {
  flex: 0 0 auto;
}

.led-controls {
  flex: 0 0 auto;
}

.time-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Sensor section - panel chiếm toàn bộ chiều cao còn lại */
.sensor-section > h2:first-child {
  flex: 0 0 auto;
}

.sensor-panel {
  flex: 1;
  min-height: 0;
}

/* Chart section - panel chiếm toàn bộ chiều cao còn lại */
.chart-section > h2:first-child {
  flex: 0 0 auto;
}

.chart-panel {
  flex: 1;
  min-height: 0;
}


.led-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  height: fit-content;
  width: 100%;
}

.led-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: 15px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  width: 100%;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  align-items: center;
}

.led-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.led-control {
  display: flex;
  justify-content: center;
  align-items: center;
}

.led-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.1), transparent);
  transition: left 0.5s;
}

.led-card:hover::before {
  left: 100%;
}

.led-card:hover {
  transform: translateY(-5px);
  border-color: rgba(0, 255, 255, 0.6);
  box-shadow: 0 10px 30px rgba(0, 255, 255, 0.2);
}

.led-toggle {
  width: 80px;
  height: 40px;
  background: #333;
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid #555;
}

.led-toggle.on {
  background: linear-gradient(45deg, #00ff00, #00cc00);
  border-color: #00ff00;
  box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}

.led-toggle.off {
  background: linear-gradient(45deg, #ff4444, #cc0000);
  border-color: #ff4444;
  box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

.led-toggle::after {
  content: '';
  position: absolute;
  width: 32px;
  height: 32px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.led-toggle.on::after {
  transform: translateX(40px);
}

.sensor-panel {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: 15px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chart-panel {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: 15px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chart-panel canvas {
  max-width: 100%;
  height: 100% !important;
  flex: 1;
  min-height: 0;
}

.time-panel {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: 15px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
}

.time-display {
  display: grid;
  gap: 1rem;
}

.current-time, .current-date {
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.current-time::before, .current-date::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #00ffff, #0080ff, #00ffff);
  background-size: 200% 100%;
  animation: flow 2s linear infinite;
}

.time-label, .date-label {
  font-size: 0.9rem;
  color: #00ffff;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.time-value, .date-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
  font-family: 'Courier New', monospace;
}

.sensor-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
  flex: 1;
  align-content: start;
}

.sensor-item {
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.sensor-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #00ffff, #0080ff, #00ffff);
  background-size: 200% 100%;
  animation: flow 2s linear infinite;
}

@keyframes flow {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.sensor-label {
  font-size: 0.9rem;
  color: #00ffff;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sensor-value {
  font-size: 1.8rem;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.sensor-unit {
  font-size: 1rem;
  color: #888;
  margin-left: 0.5rem;
}

.status-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.5rem;
  animation: pulse 2s infinite;
}

.status-online {
  background: #00ff00;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.status-offline {
  background: #ff4444;
  box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.connection-status {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.8rem;
  color: #00ffff;
  z-index: 10;
}

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #00ffff;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1200px) {
  .main-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: 100vh;
  }
  
  .led-section, .sensor-section, .chart-section {
    height: auto;
    max-height: none;
  }
  
  .sensor-panel, .chart-panel {
    height: auto;
    max-height: none;
    min-height: 400px;
  }
}

@media (max-width: 1024px) {
  .control-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  
  .led-card {
    grid-template-columns: 1fr 1fr;
  }
  
  .time-display {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .led-card {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 1.5rem;
  }
  
  .led-info {
    align-items: center;
    text-align: center;
  }
  
  .time-display {
    grid-template-columns: 1fr;
  }
  
  .dashboard-container {
    padding: 0.5rem;
  }
}
