/* ----------------------------------------------------
 * Design System Config & Global Variables
 * ---------------------------------------------------- */
:root {
  --bg-color: #0b0f19;
  --panel-bg: rgba(17, 24, 39, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  
  --primary-color: #8b5cf6;     /* Purple / Violet */
  --primary-glow: rgba(139, 92, 246, 0.15);
  
  --secondary-color: #06b6d4;   /* Cyan */
  --secondary-glow: rgba(6, 182, 212, 0.15);
  
  --success-color: #10b981;     /* Green */
  --error-color: #ef4444;       /* Red */
  --warning-color: #f59e0b;     /* Orange */
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------------------
 * Base Reset & Layout
 * ---------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding: 2rem 1.5rem;
}

/* ----------------------------------------------------
 * Glow Ambient Orbs (Background Glow Effect)
 * ---------------------------------------------------- */
.glow-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  animation: float 20s infinite alternate ease-in-out;
}

#orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--primary-color) 0%, transparent 80%);
  top: -100px;
  right: -100px;
}

#orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--secondary-color) 0%, transparent 80%);
  bottom: -200px;
  left: -150px;
  animation-duration: 25s;
  animation-delay: -5s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(80px, 50px) scale(1.2);
  }
}

/* ----------------------------------------------------
 * App Container
 * ---------------------------------------------------- */
.app-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ----------------------------------------------------
 * Header Styles
 * ---------------------------------------------------- */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 1.5rem 2rem;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.icon-wrapper {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 8px 20px -5px var(--primary-color);
}

.icon-wrapper i {
  color: #fff;
  width: 26px;
  height: 26px;
}

.pulse-icon {
  animation: pulse-glow 2s infinite alternate ease-in-out;
}

@keyframes pulse-glow {
  0% { opacity: 0.7; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.05); }
}

.logo-text h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #fff 40%, #e2e8f0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

.status-badge-container {
  display: flex;
  gap: 1rem;
}

.status-badge {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 100px;
  padding: 0.6rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.active {
  background-color: var(--success-color);
  box-shadow: 0 0 10px var(--success-color);
}

.status-dot.offline {
  background-color: var(--error-color);
  box-shadow: 0 0 10px var(--error-color);
  animation: blink-warn 1.5s infinite ease-in-out;
}

@keyframes blink-warn {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ----------------------------------------------------
 * Stats Summary Cards Grid
 * ---------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.stat-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 1.8rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
}

.stat-card:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 40px -5px rgba(0, 0, 0, 0.4);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.stat-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-icon-bg {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.stat-icon-bg.purple {
  background: rgba(139, 92, 246, 0.12);
  color: var(--primary-color);
}

.stat-icon-bg.cyan {
  background: rgba(6, 182, 212, 0.12);
  color: var(--secondary-color);
}

.stat-icon-bg.green {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success-color);
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  letter-spacing: -1px;
}

.stat-value .unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}

.stat-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ----------------------------------------------------
 * Dashboard Main & Panels Layout
 * ---------------------------------------------------- */
.dashboard-main {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr;
  gap: 1.5rem;
}

@media (max-width: 1200px) {
  .dashboard-main {
    grid-template-columns: 1fr;
  }
}

.left-panel, .right-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Cards (Panel Cards) */
.panel-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 1.8rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.card-header {
  margin-bottom: 1.5rem;
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.card-header h2 i {
  color: var(--secondary-color);
}

.card-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
}

/* ----------------------------------------------------
 * Form Controls (MQTT Publish panel)
 * ---------------------------------------------------- */
.publish-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input, .form-group textarea {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text-main);
  padding: 0.8rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-smooth);
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--secondary-color);
  box-shadow: 0 0 12px var(--secondary-glow);
  background: rgba(15, 23, 42, 0.8);
}

.form-group textarea {
  height: 100px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* Button UI */
.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  border: none;
  border-radius: 10px;
  padding: 0.8rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: var(--transition-smooth);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff;
  box-shadow: 0 4px 15px -3px var(--primary-color);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px -3px var(--primary-color);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--error-color);
  color: #fff;
  box-shadow: 0 4px 15px -3px var(--error-color);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.publish-result {
  margin-top: 1rem;
  padding: 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: none;
  animation: fadeIn 0.3s ease;
}

.publish-result.success {
  background: rgba(16, 185, 129, 0.15);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.publish-result.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ----------------------------------------------------
 * Real-time Chart Card
 * ---------------------------------------------------- */
.chart-container {
  position: relative;
  width: 100%;
  height: 250px;
  margin-top: 1rem;
}

/* ----------------------------------------------------
 * Log Card & Table Elements
 * ---------------------------------------------------- */
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.filter-bar {
  margin-bottom: 1.2rem;
}

.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.filter-bar input {
  width: 100%;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text-main);
  padding: 0.8rem 1rem 0.8rem 2.8rem;
  outline: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.filter-bar input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 12px var(--primary-glow);
  background: rgba(15, 23, 42, 0.8);
}

/* Table Design */
.table-wrapper {
  overflow-y: auto;
  max-height: 480px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.3);
}

/* 스크롤바 커스터마이징 */
.table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.log-table th {
  background: rgba(15, 23, 42, 0.7);
  padding: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--panel-border);
}

.log-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  word-break: break-all;
}

.log-table tbody tr {
  transition: var(--transition-smooth);
}

.log-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-table tbody tr.new-row {
  animation: highlightRow 1.5s ease-out;
}

@keyframes highlightRow {
  0% {
    background: rgba(6, 182, 212, 0.2);
  }
  100% {
    background: transparent;
  }
}

.log-table td.topic-cell {
  font-family: var(--font-mono);
  color: var(--secondary-color);
  font-weight: 500;
}

.log-table td.payload-cell {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  padding: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.log-table td.time-cell {
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.no-data {
  text-align: center;
  padding: 3rem !important;
  color: var(--text-muted);
}

.no-data i {
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  color: var(--text-dim);
}

/* Spinner Loader */
.loader-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--secondary-color);
  animation: spin 1s ease-in-out infinite;
  display: inline-block;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
