/* ═══════════════════════════════════════════════════════════
   NuvemSync — Premium Dark UI
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS Variables / Design Tokens ─────────────────────── */
:root {
  /* Primary palette */
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #4834D4;
  --primary-glow: rgba(108, 92, 231, 0.3);

  /* Success / Green */
  --success: #00B894;
  --success-light: #55EFC4;
  --success-dark: #00956E;

  /* Warning */
  --warning: #FDCB6E;
  --warning-dark: #E17055;

  /* Danger */
  --danger: #FF6B6B;
  --danger-dark: #EE5A24;

  /* Neutrals */
  --bg-base: #0B0E17;
  --bg-surface: #111827;
  --bg-elevated: #1A2235;
  --bg-card: rgba(26, 34, 53, 0.7);
  --bg-hover: rgba(108, 92, 231, 0.08);

  --border: rgba(255, 255, 255, 0.06);
  --border-active: rgba(108, 92, 231, 0.4);

  --text-primary: #F1F2F6;
  --text-secondary: #A0A8C0;
  --text-muted: #636E85;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  /* Transitions */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Background Effects ────────────────────────────────── */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108, 92, 231, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(0, 184, 148, 0.08), transparent),
    radial-gradient(ellipse 40% 30% at 10% 60%, rgba(108, 92, 231, 0.06), transparent);
  pointer-events: none;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}

/* ─── App Container ─────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* ─── Header ────────────────────────────────────────────── */
.header {
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

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

.logo-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Status Badges */
.status-badges {
  display: flex;
  gap: 10px;
}

.badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  transition: var(--transition);
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}

.badge-connected .badge-dot {
  background: var(--success);
  box-shadow: 0 0 8px rgba(0, 184, 148, 0.6);
  animation: pulse-dot 2s infinite;
}

.badge-error .badge-dot {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.6);
}

.badge-loading .badge-dot {
  background: var(--warning);
  animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Error Banner ──────────────────────────────────────── */
.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius);
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.2);
  color: var(--danger);
  margin-bottom: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}

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

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.card-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-header h2 svg {
  color: var(--primary-light);
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 100px;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ─── Filters ───────────────────────────────────────────── */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  padding: 20px 24px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.filter-group select,
.filter-group input {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
  appearance: none;
}

.filter-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23636E85' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.filter-group select:focus,
.filter-group input:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 2px 12px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--primary-glow);
}

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

.btn-success {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  color: white;
  box-shadow: 0 2px 12px rgba(0, 184, 148, 0.3);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0, 184, 148, 0.4);
}

.btn-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ─── Header Actions ────────────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.export-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ─── Table ─────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.orders-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.orders-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.th-check {
  width: 40px;
  text-align: center !important;
}

.orders-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

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

.orders-table tbody tr:hover:not(.empty-row) {
  background: var(--bg-hover);
}

.orders-table tbody tr.selected {
  background: rgba(108, 92, 231, 0.12);
  border-left: 3px solid var(--primary);
}

.orders-table td:first-child {
  text-align: center;
}

.order-number {
  font-weight: 700;
  color: var(--primary-light);
  font-size: 0.9rem;
}

.order-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.customer-name {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.customer-email {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.order-total {
  font-weight: 700;
  color: var(--success-light);
  font-size: 0.92rem;
}

.products-info {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.8rem;
}

/* Status Pills */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pill-open { background: rgba(108, 92, 231, 0.15); color: var(--primary-light); }
.pill-closed { background: rgba(160, 168, 192, 0.15); color: var(--text-muted); }
.pill-cancelled { background: rgba(255, 107, 107, 0.15); color: var(--danger); }

.pill-paid { background: rgba(0, 184, 148, 0.15); color: var(--success-light); }
.pill-pending { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.pill-refunded { background: rgba(225, 112, 85, 0.15); color: var(--warning-dark); }
.pill-voided { background: rgba(255, 107, 107, 0.15); color: var(--danger); }

.pill-unpacked { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.pill-shipped { background: rgba(0, 184, 148, 0.15); color: var(--success-light); }
.pill-unshipped { background: rgba(160, 168, 192, 0.15); color: var(--text-muted); }
.pill-delivered { background: rgba(0, 184, 148, 0.2); color: var(--success); }

/* ─── Empty State ───────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 16px;
  color: var(--text-muted);
}

.empty-state svg {
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 360px;
}

/* ─── Loading ───────────────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 14, 23, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  border-radius: var(--radius);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.orders-card {
  position: relative;
}

/* ─── Modal ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

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

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-header h3 svg {
  color: var(--success);
}

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

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* Modal result items */
.result-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.result-stat {
  text-align: center;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.result-stat .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

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

.stat-total .stat-value { color: var(--primary-light); }
.stat-success .stat-value { color: var(--success-light); }
.stat-failed .stat-value { color: var(--danger); }

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.result-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.result-icon.success {
  background: rgba(0, 184, 148, 0.15);
  color: var(--success);
}

.result-icon.error {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
}

.result-details {
  flex: 1;
  min-width: 0;
}

.result-details strong {
  color: var(--text-primary);
}

.result-details small {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.result-error-msg {
  color: var(--danger);
  font-size: 0.78rem;
  word-break: break-word;
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  #app {
    padding: 0 12px 40px;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-actions {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  .export-group {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  .btn-success {
    width: 100%;
    justify-content: center;
  }

  .filters-grid {
    grid-template-columns: 1fr 1fr;
  }

  .result-summary {
    grid-template-columns: 1fr;
  }
}
