/* Reset and Variables */
:root {
  --bg-dark: #07050d;
  --card-bg: rgba(18, 14, 28, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f3f1f6;
  --text-muted: #958ea0;
  --cyan: #00f0ff;
  --purple: #d000ff;
  --crimson: #ff0055;
  --green: #00ffaa;
  --gradient-neon: linear-gradient(135deg, var(--cyan) 0%, var(--purple) 100%);
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --glow-cyan: 0 0 15px rgba(0, 240, 255, 0.35);
  --glow-purple: 0 0 15px rgba(208, 0, 255, 0.35);
  --glow-green: 0 0 12px rgba(0, 255, 170, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* Background Animated Blobs */
.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(130px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.65;
}

.bg-blob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.12) 0%, rgba(0, 0, 0, 0) 70%);
  top: -100px;
  left: -100px;
  animation: floatBlob 25s infinite alternate;
}

.bg-blob-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(208, 0, 255, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
  bottom: 10%;
  right: -200px;
  animation: floatBlob 30s infinite alternate-reverse;
}

.bg-blob-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255, 0, 127, 0.07) 0%, rgba(0, 0, 0, 0) 70%);
  top: 30%;
  left: 30%;
}

@keyframes floatBlob {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(65px, 45px) scale(1.1); }
  100% { transform: translate(-45px, -65px) scale(0.9); }
}

/* Container & Layout */
.app-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.glass {
  background: var(--card-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--card-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
}

/* Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-radius: 16px;
  margin-bottom: 2rem;
}

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

.logo-icon {
  background: var(--gradient-neon);
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow-cyan);
}

.logo-icon i {
  color: #fff;
  width: 24px;
  height: 24px;
}

.logo-area h1 {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.logo-area h1 span {
  background: var(--gradient-neon);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.status-badge-container {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.5rem 1rem;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.status-indicator.online {
  background-color: var(--green);
  box-shadow: var(--glow-green);
}

.status-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
}

.btn-logout-header {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 30px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s;
}

.btn-logout-header:hover {
  background: rgba(255, 0, 85, 0.15);
  border-color: var(--crimson);
  color: #ff99bb;
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.2);
}

.btn-logout-header i {
  width: 15px;
  height: 15px;
}

/* Authentication Panels */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 75vh;
  width: 100%;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 2.2rem;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  text-align: center;
}

.auth-header {
  margin-bottom: 2rem;
}

.auth-logo-icon {
  background: var(--gradient-neon);
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow-cyan);
  margin: 0 auto 1.25rem;
}

.auth-logo-icon i {
  color: #fff;
  width: 28px;
  height: 28px;
}

.auth-header h2 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.auth-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.auth-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.3rem;
  border-radius: 8px;
  margin-bottom: 1.8rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 0.6rem 0;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.3s;
}

.auth-tab.active {
  background: var(--gradient-neon);
  color: white;
  box-shadow: var(--glow-cyan);
}

.auth-error-msg {
  background: rgba(255, 0, 85, 0.1);
  border: 1px solid var(--crimson);
  color: #ff99bb;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.btn-block {
  width: 100%;
  margin-top: 1rem;
}

/* Grid Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.grid-column {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Card Styling */
.card {
  border-radius: 16px;
  padding: 1.8rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.8rem;
}

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

.card-header h2 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Forms controls */
.form-group {
  margin-bottom: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-align: left;
}

.tooltip-trigger {
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
}

.tooltip-trigger i {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  opacity: 0.7;
}

.tooltip-trigger:hover i {
  color: var(--cyan);
}

input, select {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.3s;
}

input:focus, select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
}

input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

/* Buttons */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  border: none;
}

.btn-primary {
  background: var(--gradient-neon);
  color: white;
  box-shadow: var(--glow-cyan);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-cyan), var(--glow-purple);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
  background: rgba(255, 0, 85, 0.12);
  border-color: var(--crimson);
  color: #ff99bb;
}

/* Multi-URL AIOMetadata List */
#aiometa-url-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.aiometa-url-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.aiometa-url-row input {
  flex: 1;
}

.btn-remove-url {
  flex-shrink: 0;
  background: rgba(255, 0, 85, 0.08);
  border: 1px solid rgba(255, 0, 85, 0.2);
  color: var(--crimson);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-remove-url:hover {
  background: rgba(255, 0, 85, 0.25);
  box-shadow: 0 0 8px rgba(255, 0, 85, 0.3);
}

.btn-remove-url i {
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.btn-add-source {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 240, 255, 0.06);
  border: 1px dashed rgba(0, 240, 255, 0.3);
  color: var(--cyan);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.25rem;
}

.btn-add-source:hover {
  background: rgba(0, 240, 255, 0.12);
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

.btn-add-source i {
  width: 14px;
  height: 14px;
}

.url-source-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 2px 6px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 56px;
  text-align: center;
}


/* Setup Info details */
.setup-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  text-align: left;
}

.copy-field-container {
  margin-bottom: 1.25rem;
}

.copy-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
  text-align: left;
}

.copy-input-row {
  display: flex;
  gap: 0.5rem;
}

.copy-input-row input {
  background: rgba(0, 0, 0, 0.3);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-color: rgba(255, 255, 255, 0.05);
  color: var(--cyan);
  cursor: default;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy:hover {
  background: var(--gradient-neon);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--glow-cyan);
}

.btn-copy i {
  width: 18px;
  height: 18px;
}

/* System Logs Console */
.tall-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.logs-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 450px;
}

.logs-console {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  flex: 1;
  padding: 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: #bfa6ff;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.01);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gradient-neon);
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--gradient-neon);
  color: white;
  padding: 0.8rem 2.2rem;
  border-radius: 30px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), var(--glow-cyan);
  z-index: 9999;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(30px);
}

.hidden {
  display: none !important;
}

/* Footer */
.app-footer {
  margin-top: 3rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Responsive queries */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .app-container {
    padding: 1rem;
  }
  
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.2rem;
  }
  
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .auth-wrapper {
    min-height: 80vh;
  }
}

/* ---- Sync Status Card ---- */
.sync-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 0.75rem;
}

.sync-stat {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.sync-stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--cyan);
  line-height: 1;
}

.sync-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.sync-progress-track {
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.sync-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 999px;
  transition: width 0.5s ease;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.sync-progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  text-align: right;
}

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

.sync-spinning {
  animation: spin 1.2s linear infinite;
}

@media (max-width: 600px) {
  .sync-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}
