:root {
  /* Shopify Polaris Theme Design Tokens */
  --bg-primary: #f6f6f7;
  --bg-sidebar: #ffffff;
  --border-glass: #ebebeb;
  --bg-glass: #ffffff;
  
  --primary: #1c1d1f;
  --primary-hover: #303134;
  --primary-glow: rgba(28, 29, 31, 0.1);
  
  --text-main: #202223;
  --text-muted: #6d7175;
  --text-inverse: #ffffff;
  
  --success: #008060;
  --success-glow: rgba(0, 128, 96, 0.1);
  --accent-orange: #b55d00;
  --accent-purple: #5c6ac4;
  --accent-blue: #004899;
  --danger: #d82c0d;
  --danger-glow: rgba(216, 44, 13, 0.15);
  
  --font-body: -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
  
  --shadow-premium: 0 1px 3px rgba(0, 0, 0, 0.05);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

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

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

/* Hide Glow Orbs under Polaris light theme */
.glow-orb {
  display: none !important;
}

/* Master App Container */
.app-container {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  z-index: 10;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-primary);
}

/* 1. Sidebar Panel Layout */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
  justify-content: space-between;
  z-index: 20;
}

.sidebar-header {
  margin-bottom: 24px;
}

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

.logo-icon {
  width: 28px;
  height: 28px;
  color: #008060;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-main {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #202223;
}

.logo-sub {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
}

.nav-item {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  color: #202223;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  width: 100%;
  transition: all 0.15s ease;
  text-align: left;
  position: relative;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
  color: #5c6f84;
}

.nav-item:hover {
  background: #f1f2f4;
  color: #202223;
}

.nav-item.active {
  background: #edeeef;
  color: #202223;
  font-weight: 600;
}

.nav-item.active svg {
  color: #1c1d1f;
}

.badge {
  background: #ebebeb;
  color: #202223;
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}

.nav-item.active .badge {
  background: #dfdfdf;
}

/* Sidebar Footer & connection cards */
.sidebar-footer {
  margin-top: auto;
}

.api-status-card {
  background: #fafafb;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

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

.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 0 2px rgba(0, 128, 96, 0.2);
}

.status-dot.offline {
  background-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(216, 44, 13, 0.2);
}

.status-label {
  font-size: 12.5px;
  font-weight: 500;
}

.status-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

/* 2. Main Work Panel Content */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 30px 40px;
  z-index: 10;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.content-header h1 {
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 600;
  color: #202223;
  margin-bottom: 2px;
}

.content-header .subtitle {
  color: var(--text-muted);
  font-size: 13px;
}

/* Button UI Components */
.btn {
  background: none;
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: #ffffff;
  border-color: #babfc3;
  color: #202223;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
  background: #f6f6f7;
  border-color: #8c9196;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text-inverse);
}

.btn-danger:hover {
  background: #bc2200;
  border-color: #bc2200;
}

.btn-block {
  width: 100%;
}

.justify-center {
  justify-content: center;
}

.flex-btn svg {
  width: 16px;
  height: 16px;
}

.sync-icon.animating {
  animation: rotateSync 1.2s linear infinite;
}

@keyframes rotateSync {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Viewport for tab switching */
.view-viewport {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.tab-view {
  display: none;
  flex-grow: 1;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
}

/* Polaris Card components */
.glass-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-premium);
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
}

.glass-card .card-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.glass-card .card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: #202223;
}

.header-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Stats Metric Cards grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-premium);
}

.stat-icon-wrapper {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-wrapper svg {
  width: 20px;
  height: 20px;
}

.stat-icon-wrapper.blue { background: #e0f2fe; color: #0369a1; }
.stat-icon-wrapper.orange { background: #ffedd5; color: #c2410c; }
.stat-icon-wrapper.purple { background: #f3e8ff; color: #6b21a8; }
.stat-icon-wrapper.green { background: #dcfce7; color: #15803d; }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-title {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  color: #202223;
  margin: 1px 0;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Dashboard Columns details */
.dashboard-details {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
}

.map-illustration {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  height: 240px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.oman-map-svg {
  width: 80%;
  height: 80%;
}

.oman-outline {
  stroke: #c9cccf;
  fill: #fafafb;
  stroke-dasharray: 2px;
}

.map-node circle.ripple {
  animation: rippleNode 2.5s infinite ease-out;
  transform-origin: center;
}

@keyframes rippleNode {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}

.pulse-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--success-glow);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--success);
  border: 1px solid rgba(0, 128, 96, 0.15);
}

.pulse-dot {
  width: 5px;
  height: 5px;
  background-color: var(--success);
  border-radius: 50%;
}

.map-stats-overlay {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 10px;
}

.overlay-stat {
  background: #ffffff;
  border: 1px solid #ebebeb;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.overlay-stat .label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.overlay-stat .val {
  font-size: 11px;
  font-weight: 600;
  color: #202223;
}

/* Lists and Tables */
.recent-list-container {
  max-height: 240px;
  overflow-y: auto;
}

.simple-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.simple-table th {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 8px 12px;
  border-bottom: 1px solid #ebebeb;
  background: #fafafb;
}

.simple-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid #ebebeb;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px !important;
  font-size: 13px;
}

.text-link-btn {
  background: none;
  border: none;
  color: #008060;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.text-link-btn:hover {
  text-decoration: underline;
}

/* Orders View details & Datatables */
.datatable {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.datatable th {
  font-size: 13px;
  font-weight: 500;
  color: #202223;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-glass);
  background: #fafafb;
}

.datatable td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid #ebebeb;
  vertical-align: middle;
}

.datatable tbody tr:hover {
  background: #fafafb;
}

.order-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 500;
}

.order-badge.unfulfilled { background: #e0f2fe; color: #0369a1; }
.order-badge.created { background: #ffedd5; color: #c2410c; }
.order-badge.ofd { background: #f3e8ff; color: #6b21a8; }
.order-badge.delivered { background: #dcfce7; color: #15803d; }
.order-badge.neutral { background: #f1f2f4; color: #5c6f84; }

.align-right { text-align: right; }
.bold { font-weight: 500; color: #202223; }
.tracking-code { font-family: var(--font-mono); font-size: 12px; color: #202223; }

/* Datatable Filters */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
}

.search-box {
  position: relative;
  flex-grow: 1;
  max-width: 400px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  background: #ffffff;
  border: 1px solid #babfc3;
  border-radius: var(--radius-md);
  padding: 8px 12px 8px 36px;
  color: var(--text-main);
  font-size: 13px;
  transition: all 0.15s ease;
}

.search-box input:focus {
  outline: none;
  border-color: #008060;
  box-shadow: 0 0 0 2px rgba(0, 128, 96, 0.15);
}

.dropdown-filter {
  background: #ffffff;
  border: 1px solid #babfc3;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropdown-filter:focus {
  outline: none;
  border-color: #008060;
}

.empty-message-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 0;
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  opacity: 0.6;
  margin-bottom: 12px;
}

.empty-message-box h4 {
  font-size: 14px;
  color: #202223;
  margin-bottom: 4px;
  font-weight: 600;
}

.empty-message-box p {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Webhook Simulator Layout */
.simulator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  flex-grow: 1;
}

.action-card-group {
  background: #fafafb;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.action-card-group h4 {
  font-size: 13.5px;
  color: #202223;
  margin-bottom: 4px;
  font-weight: 600;
}

.action-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 10px 0 20px 0;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #ebebeb;
}

.divider span {
  padding: 0 10px;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.flex-grow {
  flex-grow: 1;
}

.alert-box {
  border-left: 3px solid transparent;
}

.danger-box {
  background: #fff8f8;
  border-color: var(--danger);
  border-left-width: 3px;
  padding: 12px;
  border-radius: var(--radius-md);
  border-top: 1px solid #f9e2e2;
  border-right: 1px solid #f9e2e2;
  border-bottom: 1px solid #f9e2e2;
}

.danger-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Code Payload Inspector */
.terminal-card {
  display: flex;
  flex-direction: column;
}

.badge-neutral {
  background: #f1f2f4;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
}

.payload-preview-container {
  flex-grow: 1;
  background: #0f141c;
  border: 1px solid #1e2633;
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #34d399;
  max-height: 480px;
}

.json-code {
  white-space: pre-wrap;
  word-break: break-all;
}

/* Credentials tab forms */
.credentials-container {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
}

.info-box {
  background: #f4f6fa;
  border-color: var(--accent-blue);
  border-left-width: 3px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  border-top: 1px solid #e1e6f0;
  border-right: 1px solid #e1e6f0;
  border-bottom: 1px solid #e1e6f0;
}

.alert-content h5 {
  font-size: 13.5px;
  color: #202223;
  margin-bottom: 2px;
  font-weight: 600;
}

.alert-content p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Form Styles */
.credential-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
}

.form-group input {
  background: #ffffff;
  border: 1px solid #babfc3;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  transition: all 0.15s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #008060;
  box-shadow: 0 0 0 2px rgba(0, 128, 96, 0.15);
}

.form-subtext {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Help Content cards */
.help-card {
  align-self: start;
}

.help-content p {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-list li {
  font-size: 12px;
  color: var(--text-main);
  position: relative;
  padding-left: 16px;
  line-height: 1.4;
}

.help-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  top: 0;
  color: #008060;
  font-weight: 700;
}

.help-list code {
  background: #f1f2f4;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Button Spinners */
.btn-spinner {
  width: 16px;
  height: 16px;
  animation: rotateSync 1s linear infinite;
}

.hidden {
  display: none !important;
}

/* 5. Developer Terminal Logs shell */
.console-card {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.terminal-shell {
  background: #0f141c;
  border: 1px solid #1e2633;
  border-radius: var(--radius-lg);
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 400px;
  max-height: 480px;
}

.terminal-header {
  background: #161e2b;
  border-bottom: 1px solid #1e2633;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.shell-dot.red { background-color: #ff5f56; }
.shell-dot.yellow { background-color: #ffbd2e; }
.shell-dot.green { background-color: #27c93f; }

.shell-title {
  font-size: 11px;
  color: #7f8fa4;
  margin-left: 8px;
}

.terminal-body {
  padding: 16px;
  overflow-y: auto;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-line {
  font-size: 12px;
  line-height: 1.4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.log-time {
  color: #52637a;
  user-select: none;
}

.log-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
}

.badge-info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warn { background: rgba(249, 115, 22, 0.15); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.3); }
.badge-error { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-req { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-res { background: rgba(14, 165, 233, 0.15); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.3); }

.log-message {
  color: #abb2bf;
  word-break: break-all;
}

.log-details {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 2px;
  color: #818cf8;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Custom Webkit scrollbar styles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}
