/* ==========================================
   DESIGN SYSTEM & VARIABLES
   ========================================== */
:root {
  --bg-primary: #080c14;
  --bg-secondary: #0f172a;
  --panel-bg: rgba(15, 23, 42, 0.45);
  --panel-border: rgba(255, 255, 255, 0.07);
  --panel-glow: rgba(99, 102, 241, 0.05);
  
  /* HSL Tailored Brand Colors */
  --color-primary: #6366f1; /* Indigo */
  --color-primary-glow: rgba(99, 102, 241, 0.35);
  --color-secondary: #a855f7; /* Violet */
  --color-accent: #06b6d4; /* Cyan */
  --color-accent-glow: rgba(6, 182, 212, 0.25);
  
  /* Status Colors */
  --color-success: #10b981; /* Emerald */
  --color-warning: #f59e0b; /* Amber */
  --color-danger: #ef4444; /* Rose */
  --color-inactive: #64748b; /* Slate */

  /* Text Colors */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #475569;
  
  /* Typography */
  --font-brand: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
}

/* ==========================================
   RESET & BASE STYLES
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

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

/* Custom Webkit scrollbar for premium aesthetics */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ==========================================
   AMBIENT GLOW EFFECT ORBS
   ========================================== */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  opacity: 0.28;
  pointer-events: none;
  animation: orbFloat 25s infinite alternate ease-in-out;
}
.orb-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
  top: -10%;
  left: -5%;
}
.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--color-secondary) 0%, transparent 70%);
  bottom: 10%;
  right: -10%;
  animation-duration: 35s;
}
.orb-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--color-accent) 0%, transparent 70%);
  top: 40%;
  left: 30%;
  animation-duration: 20s;
}

@keyframes orbFloat {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(50px, 40px) scale(1.15); }
  100% { transform: translate(-30px, -20px) scale(0.9); }
}

/* ==========================================
   GLASSMORPHISM STRUCTURAL UTILITY
   ========================================== */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3), inset 0 1px 1px 0 rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-lg);
  position: relative;
  overflow: hidden;
}
.glass-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: inherit;
  background: radial-gradient(800px circle at var(--x, 0px) var(--y, 0px), rgba(255,255,255,0.06), transparent 40%);
  pointer-events: none;
}

/* ==========================================
   APP HEADER
   ========================================== */
.app-header {
  border-bottom: 1px solid var(--panel-border);
  background: rgba(8, 12, 20, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.logo-icon {
  font-size: 1.8rem;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-primary) 50%, var(--color-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}
.logo-text h1 {
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.logo-text span {
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--color-accent);
  display: block;
  font-weight: 600;
}
.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition-smooth);
}
.nav-link:hover, .nav-link.active {
  color: var(--text-main);
}
.special-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 0.45rem 1rem;
  border-radius: 50px;
  color: var(--text-main);
}
.special-link:hover {
  background: rgba(99, 102, 241, 0.25);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}
.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--color-success);
  border-radius: 50%;
  display: inline-block;
  animation: pulseLight 1.8s infinite;
}

@keyframes pulseLight {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================
   MAIN DASHBOARD GRID
   ========================================== */
.dashboard-main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem;
}

/* 1. Stats Counter Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.stat-info h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-number {
  font-family: var(--font-brand);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

/* 2. Operations Split Columns */
.dashboard-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
}

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

/* ==========================================
   CONTROL PANEL & FORMS (LEFT)
   ========================================== */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.form-card {
  padding: 1.75rem;
}
.form-card h2 {
  font-family: var(--font-brand);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.section-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
input, select {
  width: 100%;
  background: rgba(8, 12, 20, 0.4);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 0.65rem 0.85rem;
  border-radius: var(--border-radius-md);
  font-family: var(--font-body);
  font-size: 0.85rem;
  transition: var(--transition-smooth);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
  background: rgba(8, 12, 20, 0.7);
}

/* Fieldset Styling */
.credentials-fieldset {
  border: 1px solid var(--panel-border);
  padding: 1rem;
  border-radius: var(--border-radius-md);
  margin-bottom: 1.5rem;
  background: rgba(255, 255, 255, 0.01);
}
.credentials-fieldset legend {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-secondary);
  padding: 0 0.5rem;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: var(--border-radius-md);
  font-family: var(--font-brand);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: white;
  box-shadow: 0 4px 15px var(--color-primary-glow);
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}
.btn-secondary {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-primary) 100%);
  color: white;
  box-shadow: 0 4px 15px var(--color-accent-glow);
}
.btn-secondary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
}
.btn-refresh {
  width: auto;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 0.45rem 1rem;
}
.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ==========================================
   CONTENT PANEL & DYNAMIC LIST (RIGHT)
   ========================================== */
.content-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.section-header-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.75rem;
}
.section-header-panel h2 {
  font-family: var(--font-brand);
  font-size: 1.25rem;
  font-weight: 700;
}
.section-header-panel p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* 1. Company Layout Panel */
.company-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.company-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.75rem;
}
.company-title h3 {
  font-family: var(--font-brand);
  font-size: 1.2rem;
  font-weight: 600;
}
.company-id {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 0.15rem;
}
.btn-delete {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--color-danger);
  width: auto;
  padding: 0.3rem 0.75rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
}
.btn-delete:hover {
  background: rgba(239, 68, 68, 0.25);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}

/* 2. Integrations Nested Items */
.integrations-subgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.integration-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}
.integration-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.platform-pill {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  letter-spacing: 0.5px;
}
.platform-WOOCOMMERCE { background: rgba(99, 102, 241, 0.15); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.25); }
.platform-AMAZON { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.25); }
.platform-MIRAVIA { background: rgba(6, 182, 212, 0.15); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.25); }

/* Custom Badge Status Dot */
.status-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}
.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-badge.status-ACTIVE { color: var(--color-success); }
.status-badge.status-ACTIVE::before { background-color: var(--color-success); box-shadow: 0 0 8px var(--color-success); }
.status-badge.status-INACTIVE { color: var(--color-inactive); }
.status-badge.status-INACTIVE::before { background-color: var(--color-inactive); }
.status-badge.status-ERROR { color: var(--color-danger); }
.status-badge.status-ERROR::before { background-color: var(--color-danger); box-shadow: 0 0 8px var(--color-danger); }

/* Integration Dynamic Credentials Info */
.creds-info {
  background: rgba(0, 0, 0, 0.2);
  padding: 0.55rem;
  border-radius: var(--border-radius-sm);
  font-family: monospace;
  font-size: 0.65rem;
  color: var(--text-muted);
  border: 1px dashed rgba(255, 255, 255, 0.03);
  word-break: break-all;
}

/* Trigger Sync Panel inside Integration card */
.sync-trigger-panel {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sync-trigger-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.sync-trigger-inputs input {
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  border-radius: var(--border-radius-sm);
}
.btn-trigger {
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--border-radius-sm);
}

/* Empty & Loading States */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.empty-state p {
  font-family: var(--font-brand);
  font-size: 1.1rem;
  font-weight: 600;
}
.empty-state span {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 400px;
}

/* ==========================================
   TOAST NOTIFICATIONS (TOASTS)
   ========================================== */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
}
.toast {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  border-radius: var(--border-radius-md);
  padding: 0.85rem 1.25rem;
  color: var(--text-main);
  min-width: 300px;
  max-width: 450px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  position: relative;
}
.toast::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
}
.toast-success::after { background-color: var(--color-success); }
.toast-danger::after { background-color: var(--color-danger); }
.toast-info::after { background-color: var(--color-accent); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast-fade-out {
  animation: slideOut 0.3s ease-in forwards;
}
@keyframes slideOut {
  to { transform: translateX(120%); opacity: 0; }
}

/* ==========================================
   MODAL OVERLAY & CARD (ORDERS VIEWER)
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(8, 12, 20, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 90%;
  max-width: 900px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-family: var(--font-brand);
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
}

/* Orders Table */
.orders-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.orders-table th {
  padding: 0.75rem 1rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--panel-border);
}

.orders-table td {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: top;
}

.orders-table tr:hover {
  background: rgba(255, 255, 255, 0.01);
}

.order-items-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.order-items-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.order-item-sku {
  font-family: monospace;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.15rem 0.35rem;
  border-radius: var(--border-radius-sm);
  color: var(--color-accent);
  font-size: 0.75rem;
}

.order-item-qty {
  font-size: 0.75rem;
  color: var(--text-muted);
}

