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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  text-align: center;
  color: white;
  margin-bottom: 30px;
  font-size: 2.5em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.device-card {
  background: white;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.device-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.device-info h2 {
  color: #333;
  margin-bottom: 10px;
  font-size: 1.8em;
}

.device-status {
  font-size: 1.1em;
  margin-bottom: 5px;
  font-weight: 600;
  transition: color 0.3s ease;
}

.device-status.on {
  color: #4caf50;
}

.device-status.off {
  color: #f44336;
}

.device-status.unknown {
  color: #9e9e9e;
}

.device-status.switching {
  color: #ff9800;
  animation: pulse 1.5s infinite;
}

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

.device-connection {
  font-size: 0.9em;
  color: #666;
}

.device-connection.online {
  color: #4caf50;
}

.device-connection.offline {
  color: #f44336;
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 80px;
  height: 40px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 40px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 32px;
  width: 32px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background-color: #4caf50;
}

input:focus + .slider {
  box-shadow: 0 0 1px #4caf50;
}

input:checked + .slider:before {
  transform: translateX(40px);
}

input:disabled + .slider {
  cursor: not-allowed;
  opacity: 0.6;
}

.footer {
  text-align: center;
  color: white;
  margin-top: 30px;
}

.footer p {
  margin-bottom: 15px;
  opacity: 0.9;
}

.refresh-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1em;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

.refresh-btn:active {
  transform: scale(0.95);
}

/* Loading state */
.loading {
  opacity: 0.8;
  pointer-events: none;
}

.loading .switch {
  position: relative;
}

.loading .switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #ff9800;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Error state */
.error {
  background-color: #ffebee;
  border-left: 4px solid #f44336;
}

/* Responsive design */
@media (max-width: 600px) {
  .container {
    padding: 10px;
  }

  h1 {
    font-size: 2em;
  }

  .device-card {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }

  .device-controls {
    margin-top: 20px;
  }
}

/* Login Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
  text-align: center;
  animation: slideUp 0.3s ease;
}

.modal-content h2 {
  color: #333;
  margin-bottom: 10px;
  font-size: 1.8em;
}

.modal-content p {
  color: #666;
  margin-bottom: 20px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#password-input {
  padding: 12px 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1em;
  transition: border-color 0.3s ease;
}

#password-input:focus {
  outline: none;
  border-color: #667eea;
}

#login-btn {
  padding: 12px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#login-btn:active {
  transform: translateY(0);
}

#login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error-message {
  color: #f44336;
  font-size: 0.9em;
  min-height: 20px;
  margin: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
