/* ================= RESET ================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", sans-serif;
}

body {
  background: linear-gradient(135deg, #1e1e2f, #141427);
  color: #eee;
}

/* ================= NAVBAR ================= */
.navbar {
  width: 100%;
  height: 60px;
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 25px;
  border-bottom: 1px solid #2c2c3a;
}

.navbar .logo {
  font-weight: bold;
  font-size: 18px;
  color: #4da3ff;
}

.navbar .menu a {
  color: #bbb;
  text-decoration: none;
  margin-left: 20px;
  font-size: 14px;
  transition: 0.2s;
}

.navbar .menu a:hover {
  color: #4da3ff;
}

/* ================= LAYOUT ================= */
.app {
  display: flex;
  height: calc(100vh - 60px);
}

.sidebar {
  width: 260px;
  background: #151522;
  padding: 20px;
  border-right: 1px solid #2c2c3a;
  overflow-y: auto;
}

.main {
  flex: 1;
  padding: 25px;
  overflow-y: auto;
}

/* ================= SIDEBAR TITLE ================= */
.device-title {
  font-weight: bold;
  margin-bottom: 20px;
  color: #4da3ff;
}

/* ================= GATEWAY BUTTON ================= */
.gateway-btn {
  width: 100%;
  background: #252538;
  border: none;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  text-align: left;
  color: white;
  cursor: pointer;
  transition: 0.2s;
  font-weight: 500;
}

.gateway-btn:hover {
  background: #33334d;
}

.gateway-btn.active {
  background: #4da3ff;
}

/* ================= LIGHT BUTTON ================= */
.light-btn {
  display: inline-block;
  background: #33334d;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  color: white;
  margin: 5px 5px 5px 0;
  cursor: pointer;
  transition: 0.2s;
  font-size: 13px;
}

.light-btn:hover {
  background: #4da3ff;
}

.light-btn.on {
  background: #4caf50;
}

/* ================= TOOLBAR ================= */
.toolbar {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.tool-item {
  background: #252538;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 14px;
}

.tool-item.alert {
  color: #ff6b6b;
}

/* ================= CARD ================= */
.card {
  background: #252538;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 25px;
  box-shadow: 0 0 12px rgba(0,0,0,0.3);
}

.card h3 {
  margin-bottom: 15px;
  color: #4da3ff;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ================= BUTTONS ================= */
.btn-primary {
  background: #4da3ff;
  border: none;
  padding: 8px 15px;
  border-radius: 6px;
  cursor: pointer;
  color: white;
  font-size: 13px;
}

.btn-primary:hover {
  background: #358be0;
}

.btn-secondary {
  background: #444;
  border: none;
  padding: 8px 15px;
  border-radius: 6px;
  cursor: pointer;
  color: white;
  font-size: 13px;
}

.btn-secondary:hover {
  background: #666;
}

/* ================= TABLE ================= */
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.schedule-table th,
.schedule-table td {
  padding: 10px;
  border-bottom: 1px solid #333;
  text-align: center;
}

.schedule-table th {
  background: #33334d;
}

/* ================= MODAL ================= */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal-content {
  background: #252538;
  padding: 25px;
  border-radius: 12px;
  width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content.large {
  width: 650px;
}

.modal h2,
.modal h3 {
  margin-bottom: 15px;
  color: #4da3ff;
}

/* ================= FORM ================= */
.form-group {
  margin-bottom: 15px;
}

.form-group input {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background: #33334d;
  color: white;
}

.brightness-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  flex: 1;
}

/* ================= SCROLLBAR ================= */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

/* ================= GATEWAY GROUP ================= */

.gateway-group {
  margin-bottom: 15px;
}

.gateway-btn {
  width: 100%;
  background: linear-gradient(145deg, #2a2a3f, #1f1f30);
  border: 1px solid #333;
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 6px;
  text-align: left;
  color: white;
  cursor: pointer;
  transition: all 0.25s ease;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gateway-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

/* Gateway ON */
.gateway-btn.on {
  border-color: #4da3ff;
  box-shadow: 0 0 12px rgba(77,163,255,0.5);
}

/* Gateway OFF */
.gateway-btn.off {
  opacity: 0.6;
}

/* Gateway Status Dot */
.gateway-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.gateway-status.on {
  background: #4caf50;
}

.gateway-status.off {
  background: #ff4d4d;
}

/* ================= LIGHT LIST ================= */

.light-list {
  padding-left: 10px;
  margin-bottom: 8px;
}

.light-btn {
  display: block;
  width: 100%;
  background: #2d2d45;
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  color: white;
  margin-bottom: 5px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.2s;
  text-align: left;
}

.light-btn:hover {
  background: #4da3ff;
}

/* Light ON */
.light-btn.on {
  border-left: 4px solid #4caf50;
}

/* Light OFF */
.light-btn.off {
  border-left: 4px solid #ff4d4d;
}

/* Nếu Gateway OFF thì đèn bị mờ */
.gateway-group.disabled .light-btn {
  opacity: 0.4;
  pointer-events: none;
}

.selected {
  outline: 2px solid #4da3ff;
  box-shadow: 0 0 10px rgba(77,163,255,0.6);
}