/* ── Base ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.text-accent {
  color: #39ff14;
}

.text-danger {
  color: #ff4444;
}

.text-muted {
  color: #6b7280;
}

/* ── Login Screen ─────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.login-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(
      ellipse at 50% 0%,
      rgba(57, 255, 20, 0.04) 0%,
      transparent 60%
    ),
    #090d16;
}

.login-card {
  position: relative;
  width: min(420px, 92vw);
  padding: 2.5rem 2rem;
  background: linear-gradient(145deg, #151c2c 0%, #111827 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(57, 255, 20, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: card-enter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}

.login-logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #39ff14;
  box-shadow: 0 0 12px #39ff14;
  animation: pulse-dot 2s ease-in-out infinite;
}

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

.login-logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f3f4f6;
}

.login-subtitle {
  font-size: 0.75rem;
  color: #6b7280;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9ca3af;
}

.login-input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #e5e7eb;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input:focus {
  border-color: rgba(57, 255, 20, 0.4);
  box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.08);
}

.login-error {
  font-size: 0.78rem;
  color: #ff4444;
  margin: 0;
}

.login-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.85rem;
  background: linear-gradient(135deg, #1a2e1a 0%, #0f1f0f 100%);
  border: 1px solid rgba(57, 255, 20, 0.25);
  border-radius: 8px;
  color: #39ff14;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.login-button:hover {
  background: linear-gradient(135deg, #1f3a1f 0%, #142814 100%);
  box-shadow: 0 0 20px rgba(57, 255, 20, 0.15);
}

.login-button:active {
  transform: scale(0.98);
}

.login-button-arrow {
  transition: transform 0.2s;
}

.login-button:hover .login-button-arrow {
  transform: translateX(3px);
}

.login-footer {
  margin: 1.5rem 0 0;
  font-size: 0.65rem;
  color: #4b5563;
  text-align: center;
  letter-spacing: 0.08em;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.78rem;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.2s;
}

.auth-mode-toggle:hover:not(:disabled) {
  color: #9ca3af;
}

.auth-mode-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-mode-action {
  color: #39ff14;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(57, 255, 20, 0.2);
  border-top-color: #39ff14;
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}

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

.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.header-user-email {
  font-size: 0.72rem;
  color: #9ca3af;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Dashboard ──────────────────────────────────────── */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  animation: dashboard-enter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.dashboard.hidden {
  display: none;
}

@keyframes dashboard-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(12px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-brand h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f3f4f6;
}

.header-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #39ff14;
  box-shadow: 0 0 8px #39ff14;
  animation: pulse-dot 2s ease-in-out infinite;
}

.header-tagline {
  margin: 0.15rem 0 0;
  font-size: 0.7rem;
  color: #6b7280;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.header-stat-label {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: #6b7280;
}

.header-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #e5e7eb;
}

.logout-button {
  padding: 0.45rem 0.85rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #9ca3af;
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.logout-button:hover {
  border-color: rgba(255, 68, 68, 0.4);
  color: #ff4444;
}

.dashboard-main {
  flex: 1;
  padding: 1.5rem 2rem 2rem;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* ── Device Cards ─────────────────────────────────────── */
.device-card {
  position: relative;
  padding: 1.25rem;
  background: linear-gradient(160deg, #151c2c 0%, #111827 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  overflow: hidden;
}

.device-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(57, 255, 20, 0.03) 0%,
    transparent 50%
  );
  pointer-events: none;
}

.device-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.1);
}

.device-card.online {
  border-color: rgba(57, 255, 20, 0.12);
}

.device-card.high-load {
  border-color: rgba(255, 68, 68, 0.5);
  animation: high-load-pulse 2s ease-in-out infinite;
}

@keyframes high-load-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 68, 68, 0),
      0 0 20px rgba(255, 68, 68, 0.15);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(255, 68, 68, 0.08),
      0 0 40px rgba(255, 68, 68, 0.25);
  }
}

.device-card.offline {
  opacity: 0.55;
  filter: grayscale(0.6);
  border-color: rgba(107, 114, 128, 0.2);
}

.device-card.offline:hover {
  opacity: 0.7;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-device-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e5e7eb;
  letter-spacing: 0.02em;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.card-badge.online {
  background: rgba(57, 255, 20, 0.1);
  color: #39ff14;
  border: 1px solid rgba(57, 255, 20, 0.2);
}

.card-badge.offline {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(107, 114, 128, 0.2);
}

.card-badge.high-load {
  background: rgba(255, 68, 68, 0.12);
  color: #ff6b35;
  border: 1px solid rgba(255, 68, 68, 0.3);
  animation: badge-blink 1.5s ease-in-out infinite;
}

@keyframes badge-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.card-temp {
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.card-temp.normal {
  color: #39ff14;
}

.card-temp.warm {
  color: #fbbf24;
}

.card-temp.hot {
  color: #ff6b35;
}

.card-temp.offline {
  color: #6b7280;
  font-size: 2rem;
}

.card-hardware {
  font-size: 0.72rem;
  color: #9ca3af;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 0.75rem;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.65rem;
  color: #6b7280;
}

.card-last-seen {
  letter-spacing: 0.04em;
}

.card-click-hint {
  color: #4b5563;
  font-size: 0.6rem;
}

/* ── Empty State ──────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.empty-icon {
  font-size: 3rem;
  color: #374151;
  margin-bottom: 1rem;
  animation: spin-slow 8s linear infinite;
}

@keyframes spin-slow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.empty-title {
  font-size: 1rem;
  color: #9ca3af;
  margin: 0 0 0.5rem;
}

.empty-desc {
  font-size: 0.78rem;
  color: #6b7280;
  margin: 0;
}

/* ── Footer ───────────────────────────────────────────── */
.dashboard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.65rem;
  color: #4b5563;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fbbf24;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.connection-status.connected .connection-dot {
  background: #39ff14;
  box-shadow: 0 0 6px #39ff14;
}

.connection-status.error .connection-dot {
  background: #ff4444;
}

/* ── Detail Drawer ────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.drawer-overlay.visible {
  opacity: 1;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 201;
  width: min(420px, 92vw);
  height: 100vh;
  background: linear-gradient(180deg, #151c2c 0%, #111827 100%);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: -16px 0 64px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.detail-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.drawer-label {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: #6b7280;
  margin: 0 0 0.25rem;
}

.drawer-title {
  font-size: 1rem;
  font-weight: 700;
  color: #f3f4f6;
  margin: 0;
  word-break: break-all;
}

.drawer-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #9ca3af;
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.drawer-close:hover {
  border-color: rgba(255, 68, 68, 0.4);
  color: #ff4444;
}

.drawer-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.drawer-field-label {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6b7280;
}

.drawer-field-value {
  font-size: 0.85rem;
  color: #e5e7eb;
  word-break: break-all;
}

.drawer-temp {
  font-size: 2.5rem;
  font-weight: 700;
  color: #39ff14;
}

.drawer-temp.hot {
  color: #ff6b35;
}

.drawer-temp.offline {
  color: #6b7280;
  font-size: 1.5rem;
}

.drawer-uuid {
  font-size: 0.72rem;
  color: #9ca3af;
  background: #090d16;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  word-break: break-all;
}

.drawer-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
  margin: 0.25rem 0;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 640px) {
  .dashboard-header {
    padding: 1rem;
  }

  .dashboard-main {
    padding: 1rem;
  }

  .header-right {
    gap: 1rem;
  }

  .header-stat-value {
    font-size: 1rem;
  }
}

/* ── Card metrics styling ── */
.card-metrics {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-metric-uptime {
  font-size: 0.72rem;
  color: #39ff14;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
}

.card-metric-ram {
  font-size: 0.68rem;
  color: #d1d5db;
  letter-spacing: 0.04em;
}

/* ── Note Textarea and Save Button ── */
.drawer-note-input {
  width: 100%;
  height: 80px;
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #e5e7eb;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.6rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.drawer-note-input:focus {
  border-color: rgba(57, 255, 20, 0.4);
}

.save-note-button {
  align-self: flex-start;
  padding: 0.55rem 1rem;
  background: linear-gradient(135deg, #1a2e1a 0%, #0f1f0f 100%);
  border: 1px solid rgba(57, 255, 20, 0.25);
  border-radius: 6px;
  color: #39ff14;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  margin-top: 0.5rem;
}

.save-note-button:hover {
  background: linear-gradient(135deg, #1f3a1f 0%, #142814 100%);
  box-shadow: 0 0 12px rgba(57, 255, 20, 0.15);
}

.save-note-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.note-status-text {
  font-size: 0.7rem;
  margin: 0.35rem 0 0;
  transition: opacity 0.2s;
}

.note-status-text.success {
  color: #39ff14;
}

.note-status-text.error {
  color: #ff4444;
}
