/* Design System Tokens (Clean Facebook Marketplace-inspired Light Theme) */
:root {
  --bg-primary: #f0f2f5;
  --bg-secondary: #f0f2f5;
  --card-bg: #ffffff;
  --card-border: #e4e6eb;
  --text-primary: #050505;      /* Facebook Black */
  --text-secondary: #65676b;    /* Facebook Gray */
  --text-muted: #8a8d91;        /* Facebook Muted Gray */
  
  /* Facebook Blue Accent */
  --accent: #1877f2;
  --accent-light: #166fe5;
  --accent-glow: rgba(24, 119, 242, 0.08);
  --accent-gradient: linear-gradient(135deg, #1877f2, #3b82f6);
  
  --success: #31a24c;      /* Green */
  --error: #fa3e3e;        /* Red */
  --warning: #f59e0b;      /* Amber */
  --info: #1877f2;         /* Blue */

  --border-radius-lg: 14px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition-smooth: all 0.2s ease-in-out;
}

/* Base resets & layout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* Floating background blobs (subtle theme matched) */
.bg-blob {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(150px);
  z-index: -1;
  opacity: 0.15; /* Much softer opacity to fit the professional Facebook theme */
  pointer-events: none;
  animation: floatBlobs 25s infinite alternate ease-in-out;
}

.blob-1 {
  background: #1877f2; /* Facebook Blue */
  top: -100px;
  left: -100px;
}

.blob-2 {
  background: #4cc9f0; /* Soft Cyan */
  bottom: 50px;
  right: -50px;
  animation-delay: -5s;
}

.blob-3 {
  background: #a5b4fc; /* Light Indigo */
  top: 30%;
  left: 45%;
  width: 300px;
  height: 300px;
  animation-delay: -10s;
}

@keyframes floatBlobs {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 40px) scale(1.1); }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

.app-container {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: calc(100vh - 5rem);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.header-instruction {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  padding: 6px 16px;
  line-height: 1.4;
  background: rgba(24, 119, 242, 0.04);
  border: 1px solid rgba(24, 119, 242, 0.08);
  border-radius: 30px;
  max-width: 420px;
  box-sizing: border-box;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: url('logo.png') no-repeat center center;
  background-size: cover;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(24, 119, 242, 0.2);
}

.logo-area h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.75px;
  color: var(--text-primary);
}

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

.header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
  transition: var(--transition-smooth);
  cursor: pointer;
}

.nav-link:hover {
  background: #fff;
  border-color: var(--accent-light);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(24, 119, 242, 0.05);
}

.nav-link.active {
  color: var(--accent);
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-link.fb-status.offline {
  color: var(--error);
  font-weight: 700;
}

.nav-link.fb-status.offline:hover {
  border-color: var(--error);
  box-shadow: 0 6px 15px rgba(250, 62, 62, 0.08);
}

.nav-link.fb-status.online {
  color: var(--success);
  font-weight: 700;
}

.nav-link.fb-status.online:hover {
  border-color: var(--success);
  box-shadow: 0 6px 15px rgba(49, 162, 76, 0.08);
}

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

.indicator-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 10px var(--success);
  animation: pulse 2s infinite ease-in-out;
}

.indicator-dot.offline {
  background-color: var(--text-muted);
}

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

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* Glassmorphism Cards */
.glass {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  padding: 1.75rem;
  box-shadow: 0 10px 30px 0 rgba(31, 38, 135, 0.04);
}

/* Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 2rem;
  flex-grow: 1;
}

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

.flex-grow-card {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.25px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--accent-gradient);
  border-radius: 4px;
}

.m-0 { margin: 0; }
.mt-4 { margin-top: 1.5rem; }

/* Image Dropzone */
.dropzone {
  border: 2px dashed rgba(0, 0, 0, 0.08);
  border-radius: var(--border-radius-md);
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  background: rgba(255, 255, 255, 0.4);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 25px rgba(255, 77, 109, 0.05);
}

.file-input-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
}

.upload-icon {
  width: 54px;
  height: 54px;
  stroke: var(--text-secondary);
  margin-bottom: 14px;
  transition: var(--transition-smooth);
}

.dropzone:hover .upload-icon {
  stroke: var(--accent);
  transform: translateY(-3px);
}

.dropzone-content .primary-text {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
}

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

/* Previews */
.image-preview-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
  margin-top: 1.25rem;
}

.preview-wrapper {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-image-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: var(--transition-smooth);
}

.remove-image-btn:hover {
  background: var(--error);
  color: #fff;
}

/* Forms layout */
.form-group {
  margin-bottom: 1.5rem;
  position: relative;
}

.form-row {
  display: flex;
  gap: 1.25rem;
}

.form-group.half {
  flex: 1;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.25px;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: #ffffff;
  border: 1px solid #ced4da;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  box-shadow: none;
  transition: var(--transition-smooth);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

.input-char-counter {
  position: absolute;
  bottom: -20px;
  right: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 14px 28px;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  gap: 8px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 18px rgba(255, 77, 109, 0.35);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(255, 77, 109, 0.5);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-primary);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.btn-secondary:hover:not(:disabled) {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 6px 15px rgba(0,0,0,0.05);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--text-secondary);
}

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

.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-text:hover {
  color: var(--accent);
}

/* Custom Checkbox Cards */
.platforms-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.platform-checkbox-card {
  cursor: pointer;
}

.platform-checkbox-card input[type="checkbox"] {
  display: none;
}

.platform-card-content {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.05);
  padding: 14px 12px;
  border-radius: var(--border-radius-md);
  transition: var(--transition-smooth);
  box-shadow: 0 4px 10px rgba(0,0,0,0.01);
}

.platform-checkbox-card input[type="checkbox"]:checked + .platform-card-content {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 8px 20px var(--accent-glow);
}

.platform-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

.fb-logo { background-color: #1877f2; }
.ebay-logo { background: linear-gradient(45deg, #e53238, #0064d2, #f5af02, #86b817); }
.offerup-logo { background-color: #00a87e; }
.nd-logo { background-color: #1fca7e; }

.platform-card-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Console logs wrapper */
.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.console-wrapper {
  background: #0f172a; /* Slate 900 (High contrast dark terminal) */
  border-radius: var(--border-radius-md);
  padding: 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 280px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.console-logs {
  overflow-y: auto;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.console-line {
  word-break: break-all;
  white-space: pre-wrap;
}

.system-line { color: #94a3b8; }
.info-line { color: #f8fafc; }
.success-line { color: #34d399; font-weight: 600; }
.error-line { color: #f87171; font-weight: 600; }
.warning-line { color: #fbbf24; }
.setup-line { color: #c084fc; font-weight: 600; }

/* Modal Styling */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

.modal-content {
  max-width: 460px;
  width: 100%;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.1);
  text-align: center;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.modal-description {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
}

/* Mobile Navigation Drawer & responsive overrides */
.mobile-nav {
  display: none; /* Desktop hidden */
}

@media (max-width: 768px) {
  body {
    padding: 1rem 1rem 2rem 1rem; /* Removed extra bottom padding since bottom tab bar is removed */
  }

  .app-container {
    gap: 1.25rem;
    min-height: auto;
  }

  .app-header {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding-bottom: 1.25rem;
  }

  .logo-area h1 {
    font-size: 1.6rem;
  }

  .session-statuses {
    width: 100%;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .status-indicator {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  /* Grid turns into block, layout is managed by tab switching classes */
  .dashboard-grid {
    display: block;
  }

  /* We use display contents to treat left/right panels as wrapper groupings,
     allowing us to toggle visibility of cards directly using .mobile-active */
  .left-panel, .right-panel {
    display: contents;
  }

  /* Hide all cards by default unless they are active in the current tab */
  .left-panel > div,
  .right-panel > div {
    display: none !important;
  }

  /* Display active card in the current tab */
  .left-panel > div.mobile-active,
  .right-panel > div.mobile-active {
    display: block !important;
  }

  /* Enable flex display for logs terminal if it is active */
  .right-panel > div.mobile-active.flex-grow-card {
    display: flex !important;
  }

  /* Make form layout fit mobile width */
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .action-buttons {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Mobile Bottom Tab Bar design */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    height: 64px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    z-index: 100;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    gap: 4px;
    flex: 1;
    height: 100%;
    transition: var(--transition-smooth);
    border-radius: 20px;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
    transition: var(--transition-smooth);
  }

  .mobile-nav-item.active {
    color: var(--accent);
  }

  .mobile-nav-item.active .nav-icon {
    transform: translateY(-2px);
    stroke: var(--accent);
  }
}

/* Gear/Icon Button style */
.btn-icon {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.04);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
  transition: var(--transition-smooth);
  width: 40px;
  height: 40px;
}

.btn-icon:hover {
  background: #fff;
  border-color: var(--accent-light);
  color: var(--accent);
  transform: scale(1.05) rotate(30deg);
  box-shadow: 0 6px 15px rgba(255, 77, 109, 0.1);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
  transition: var(--transition-smooth);
}

/* Primary Analyzed Badge for the first preview image */
.preview-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(24, 119, 242, 0.3);
  z-index: 2;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* Wizard Progress Indicator */
.wizard-progress {
  display: flex;
  gap: 12px;
  margin: 0;
  padding: 0 4px;
}

.progress-bar-step {
  flex: 1;
  height: 6px;
  background-color: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  transition: var(--transition-smooth);
}

.progress-bar-step.active {
  background-color: var(--accent);
  box-shadow: 0 2px 6px rgba(24, 119, 242, 0.3);
}

.progress-bar-step.completed {
  background-color: rgba(24, 119, 242, 0.4);
}

/* Animation Keyframes */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes popScale {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Spinner and Checklist Styles */
.spinner {
  animation: spin 1s infinite linear;
}

.friendly-step-item {
  animation: popScale 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards;
}
