* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  color: #333;
  line-height: 1.6;
  padding: 20px;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

header {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e0e0e0;
}

h1 {
  color: #2e7d32;
  margin-bottom: 10px;
  font-size: 2.2rem;
}

.subtitle {
  color: #666;
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.dashboard-title {
  text-align: center;
  color: #2e7d32;
  margin: 30px 0 20px;
  font-size: 1.8rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.card {
  background: #f9f9f9;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  border-left: 4px solid #2e7d32;
}

.card-title {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  color: #2e7d32;
  font-weight: 600;
}

.card-title i {
  margin-right: 10px;
  font-size: 1.2rem;
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.status-label {
  font-weight: 500;
}

.status-value {
  font-weight: 600;
  color: #2e7d32;
  margin-bottom: 10px;
}

.progress-bar {
  height: 20px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  margin: 10px 0;
}

.progress {
  height: 100%;
  background: linear-gradient(90deg, #4caf50 0%, #2e7d32 100%);
  border-radius: 10px;
}

.progress-text {
  font-size: 0.9rem;
  color: #666;
}

/* Tombol toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 30px;
}

.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: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #4caf50;
}

input:checked + .slider:before {
  transform: translateX(30px);
}

/* Jadwal */
.schedule-section {
  margin-top: 40px;
}

.schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.btn {
  background: #2e7d32;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.3s;
  display: inline-flex;
  align-items: center;
}

.btn i {
  margin-right: 8px;
}

.btn:hover {
  background: #1b5e20;
}

.schedule-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.schedule-item {
  background: #f9f9f9;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.schedule-name {
  font-weight: 600;
  margin-bottom: 10px;
  color: #2e7d32;
}

.schedule-details {
  margin-bottom: 15px;
  color: #666;
}

.status-badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-active {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-inactive {
  background: #ffebee;
  color: #c62828;
}

/* Status koneksi */
.online-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: #4caf50;
  border-radius: 50%;
  margin-right: 8px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
  }
}

.connection-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 20px;
  color: #4caf50;
  font-weight: 500;
}

@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .schedule-list {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 1.8rem;
  }
}

/* Chatbot widget */
#chatbot {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
}
#chat-toggle {
  background: #2e7d32;
  color: white;
  border: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}
#chat-panel {
  width: 320px;
  max-width: 90vw;
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  display: none;
  flex-direction: column;
}
#chat-header {
  padding: 10px 12px;
  background: #f1f8f3;
  border-bottom: 1px solid #e6f0e9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#chat-messages {
  padding: 12px;
  height: 220px;
  overflow: auto;
  font-size: 0.95rem;
}
.chat-msg {
  margin-bottom: 10px;
}
.chat-msg.user {
  text-align: right;
}
.chat-msg .bubble {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 85%;
}
.chat-msg.user .bubble {
  background: #2e7d32;
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-msg.bot .bubble {
  background: #f1f1f1;
  color: #222;
  border-bottom-left-radius: 4px;
}

/* Typing indicator animation */
.typing-indicator .bubble {
  background: #f1f1f1 !important;
  color: #666 !important;
  font-style: italic;
  position: relative;
}

.typing-indicator .bubble:after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #666;
  margin-left: 5px;
  animation: typing-dots 1.5s infinite;
}

@keyframes typing-dots {
  0%, 60%, 100% {
    opacity: 0.3;
  }
  30% {
    opacity: 1;
  }
}
#chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #eee;
}
#chat-input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
}
#chat-send,
#chat-clear {
  background: #2e7d32;
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
#chat-send:hover,
#chat-clear:hover,
#chat-toggle:hover {
  opacity: 0.9;
}

/* Chatbot Message Styles */
.chat-message {
  margin: 10px 0;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 80%;
  word-wrap: break-word;
}

.chat-user {
  background: #2e7d32;
  color: white;
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 3px;
}

.chat-bot {
  background: #f5f5f5;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.chat-error {
  background: #ffebee;
  color: #c62828;
  border-left: 3px solid #c62828;
}

.message-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

.chat-bot .message-time {
  text-align: left;
}

/* Typing Indicator */
.typing .typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing .typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #666;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing .typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing .typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  } 40% {
    transform: scale(1);
  }
}

/* Sensor Data Display */
.chat-sensor-data {
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  font-size: 13px;
}

.sensor-header {
  font-weight: bold;
  color: #1976d2;
  margin-bottom: 8px;
  border-bottom: 1px solid #90caf9;
  padding-bottom: 4px;
}

.sensor-item {
  margin: 4px 0;
  padding: 2px 0;
}

/* Recommendations Display */
.chat-recommendations {
  background: #fff3e0;
  border: 1px solid #ffb74d;
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  font-size: 13px;
}

.recommendation-header {
  font-weight: bold;
  color: #f57c00;
  margin-bottom: 8px;
  border-bottom: 1px solid #ffb74d;
  padding-bottom: 4px;
}

.recommendation-item {
  margin: 6px 0;
  padding: 4px 0;
}

/* Notifications */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 6px;
  color: white;
  font-weight: 500;
  z-index: 10000;
  animation: slideInRight 0.3s ease;
}

.notification-success {
  background: #4caf50;
}

.notification-error {
  background: #f44336;
}

.notification-info {
  background: #2196f3;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Quick Action Buttons */
.quick-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0;
  flex-wrap: wrap;
}

.quick-action-btn {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #2e7d32;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-action-btn:hover {
  background: #2e7d32;
  color: white;
}

/* Responsive Chatbot */
@media (max-width: 768px) {
  #chatbot {
    bottom: 15px;
    right: 15px;
  }
  
  #chat-panel {
    width: calc(100vw - 30px);
    height: 70vh;
    right: 15px;
    bottom: 70px;
  }
  
  .chat-message {
    max-width: 90%;
  }
}
