/* ========================================================
   DESIGN SYSTEM & VARIABLES
   ======================================================== */
:root {
  --font-family-title: 'Outfit', sans-serif;
  --font-family-body: 'Inter', sans-serif;

  /* Premium harmonious dark color palette */
  --bg-app: #070913;
  --bg-card: rgba(20, 24, 45, 0.45);
  --bg-card-hover: rgba(28, 33, 62, 0.55);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-focused: rgba(255, 255, 255, 0.2);

  --color-text-primary: #f3f4f6;
  --color-text-secondary: #9ca3af;
  
  /* Glowing Neon Colors */
  --color-primary: #3b82f6;
  --color-primary-glow: rgba(59, 130, 246, 0.5);
  
  --color-cyan: #06b6d4;
  --color-cyan-glow: rgba(6, 182, 212, 0.4);

  --color-purple: #8b5cf6;
  --color-purple-glow: rgba(139, 92, 246, 0.4);

  --color-success: #10b981;
  --color-success-glow: rgba(16, 185, 129, 0.4);

  --color-warning: #f59e0b;
  --color-warning-glow: rgba(245, 158, 11, 0.4);

  --color-error: #ef4444;
  --color-error-glow: rgba(239, 68, 68, 0.4);

  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================================
   BASE STYLES
   ======================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--color-text-primary);
  font-family: var(--font-family-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Ambient glow backgrounds */
.glow-bg {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.25;
  pointer-events: none;
}

.glow-purple {
  top: -100px;
  right: -100px;
  background-color: var(--color-purple);
}

.glow-cyan {
  bottom: -150px;
  left: -150px;
  background-color: var(--color-cyan);
}

/* ========================================================
   LAYOUT & CONTAINER
   ======================================================== */
.app-container {
  width: 100%;
  max-width: 1100px;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 1.5rem;
}

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

.logo-icon {
  font-size: 2.5rem;
  animation: pulse-glow 2s infinite alternate;
}

.app-header h1 {
  font-family: var(--font-family-title);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--color-text-primary);
}

.app-header h1 span {
  background: linear-gradient(135deg, var(--color-cyan), var(--color-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* System Live Status Badge */
.system-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-warning);
  box-shadow: 0 0 10px var(--color-warning);
}

.system-badge.connected .badge-dot {
  background-color: var(--color-success);
  box-shadow: 0 0 10px var(--color-success);
  animation: pulse-green 1.5s infinite;
}

.system-badge.connecting .badge-dot {
  background-color: var(--color-warning);
  box-shadow: 0 0 10px var(--color-warning);
  animation: pulse-orange 1.5s infinite;
}

.system-badge.offline .badge-dot {
  background-color: var(--color-error);
  box-shadow: 0 0 10px var(--color-error);
}

/* ========================================================
   DASHBOARD GRID & CARDS
   ======================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .system-badge {
    align-self: flex-end;
  }
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 2rem;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  min-height: 480px;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

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

.card-header h2 {
  font-family: var(--font-family-title);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ========================================================
   STATE VIEWS (Status column)
   ======================================================== */
.connection-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.state-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
  animation: fadeIn 0.4s ease-out;
  width: 100%;
}

.status-icon {
  font-size: 3rem;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

.icon-error {
  background: rgba(239, 68, 68, 0.15);
  border: 2px solid var(--color-error);
  color: var(--color-error);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.1);
}

.icon-success {
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid var(--color-success);
  color: var(--color-success);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.1);
  animation: scaleUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.state-view h3 {
  font-family: var(--font-family-title);
  font-size: 1.3rem;
}

.text-success {
  color: var(--color-success);
}

.state-view p {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 320px;
}

/* Spinner Loader */
.loader {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--color-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.1);
  margin-bottom: 0.5rem;
}

/* QR Code Display */
.qr-container {
  position: relative;
  background: white;
  padding: 1rem;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 15px var(--color-cyan-glow);
  width: 200px;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--color-cyan);
  transition: var(--transition-smooth);
}

#qr-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.qr-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(7, 9, 19, 0.95);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 16px;
  font-weight: 500;
  font-size: 0.9rem;
}

.instructions {
  font-size: 0.85rem !important;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.session-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.session-box code {
  color: var(--color-cyan);
}

/* ========================================================
   FORM ELEMENTS
   ======================================================== */
form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

input[type="text"],
textarea {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  color: var(--color-text-primary);
  font-family: var(--font-family-body);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
  width: 100%;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-cyan);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 12px var(--color-cyan-glow);
}

textarea {
  resize: vertical;
}

.help-text {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* File Drop Area */
.file-drop-area {
  position: relative;
  border: 2px dashed var(--border-glass);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  transition: var(--transition-smooth);
  background: rgba(255, 255, 255, 0.01);
  cursor: pointer;
}

.file-drop-area:hover {
  border-color: var(--color-purple);
  background: rgba(255, 255, 255, 0.03);
}

.file-drop-area input[type="file"] {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}

.file-dummy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.file-icon {
  font-size: 1.5rem;
  transition: var(--transition-smooth);
}

.file-drop-area:hover .file-icon {
  transform: translateY(-2px);
}

.file-message {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

/* ========================================================
   BUTTONS
   ======================================================== */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-family: var(--font-family-body);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-cyan), var(--color-purple));
  color: white;
  box-shadow: 0 5px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.5);
  transform: translateY(-1px);
}

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

.btn-danger:hover {
  background: var(--color-error);
  color: white;
  box-shadow: 0 5px 15px var(--color-error-glow);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-block {
  width: 100%;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ========================================================
   ALERTS / NOTIFICATIONS
   ======================================================== */
.feedback-alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  animation: fadeIn 0.3s ease-out;
}

.feedback-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid var(--color-success);
  color: #a7f3d0;
}

.feedback-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--color-error);
  color: #fca5a5;
}

/* ========================================================
   FOOTER
   ======================================================== */
.app-footer {
  text-align: center;
  border-top: 1px solid var(--border-glass);
  padding-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.tech-stack {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ========================================================
   ANIMATIONS & UTILITIES
   ======================================================== */
.hidden {
  display: none !important;
}

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

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

@keyframes scaleUp {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes pulse-glow {
  0% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(6, 182, 212, 0.2)); }
  100% { transform: scale(1.05); filter: drop-shadow(0 0 15px var(--color-cyan-glow)); }
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulse-orange {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
