/* Root Design Variables */
:root {
  --bg-main: #0a0d14;
  --bg-card: rgba(22, 28, 45, 0.7);
  --bg-card-hover: rgba(30, 37, 59, 0.85);
  --bg-modal: #0d1222;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(139, 92, 246, 0.2);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-placeholder: #6b7280;
  
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.4);
  --accent: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.4);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
}

/* Reset & Core Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Dashboard Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Header styling */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

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

.logo-area .icon {
  font-size: 2rem;
  animation: pulse-glow 2s infinite alternate;
}

.logo-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.system-status {
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.status-dot.success { background-color: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.warning { background-color: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-dot.danger { background-color: var(--danger); box-shadow: 0 0 8px var(--danger); }

/* Main Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

/* Top Stats Row spanning across full width */
.stats-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.5);
}

.stat-icon {
  font-size: 2.2rem;
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-info h3 {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-info p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.stat-card.success h3 { color: var(--success); }
.stat-card.warning h3 { color: var(--warning); }
.stat-card.danger h3 { color: var(--danger); }

/* Sidebar Control Panel */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
}

.panel-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-main);
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Button Classes */
.btn {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-align: center;
  display: inline-block;
}

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

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--accent-glow);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--text-muted);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.4);
}

.btn-clear {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

/* Config display list */
.config-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.config-item .label {
  color: var(--text-muted);
}

.config-item .value {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
}

/* Products Table Layout */
.table-panel {
  grid-column: 1 / 2;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

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

.table-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.search-bar input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 16px;
  color: var(--text-main);
  font-size: 0.88rem;
  width: 280px;
  transition: all 0.2s;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.table-wrapper {
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
}

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

.product-table th, 
.product-table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.product-table th {
  color: var(--text-muted);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.01);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.product-table tbody tr {
  transition: background-color 0.2s;
}

.product-table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.pending { background-color: rgba(255, 255, 255, 0.06); color: var(--text-muted); }
.badge.success { background-color: var(--success-bg); color: var(--success); }
.badge.dry-run { background-color: rgba(59, 130, 246, 0.15); color: var(--primary); }
.badge.failed { background-color: var(--danger-bg); color: var(--danger); }

/* Table Loading Message */
.table-loading {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 40px !important;
}

/* Live Terminal Panel */
.terminal-panel {
  grid-column: 1 / -1;
}

.terminal-card {
  padding: 0;
  background: #060911;
  overflow: hidden;
  border-color: rgba(139, 92, 246, 0.15);
}

.terminal-header {
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.terminal-header h2 {
  font-size: 0.95rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: var(--accent);
}

.terminal-body {
  padding: 20px 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: #cbd5e1;
  height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-color: #03060a;
}

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

.log-line.system { color: var(--text-placeholder); }
.log-line.error { color: var(--danger); }
.log-line.success { color: var(--success); }
.log-line.info { color: var(--primary); }

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Modal Styling */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(8px);
}

.modal-content {
  background-color: var(--bg-modal);
  margin: 40px auto;
  border: 1px solid var(--border-color);
  width: 90%;
  max-width: 1300px;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  animation: slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

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

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

.close-modal {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: var(--text-muted);
  cursor: pointer;
}

.close-modal:hover {
  color: var(--text-main);
}

.modal-body-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 24px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.column-before, 
.column-after {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.column-before {
  border-right: 1px solid var(--border-color);
  padding-right: 24px;
}

.col-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-color);
}

.column-after .col-title {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.meta-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.field-value {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
}

.field-value.highlight {
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.3);
}

.field-html {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  overflow-y: auto;
  max-height: 250px;
}

.field-html.highlight {
  background: rgba(139, 92, 246, 0.03);
  border-color: rgba(139, 92, 246, 0.3);
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-bubble {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
}

.modal-footer {
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.01);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#modal-status-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Animations */
@keyframes pulse-glow {
  0% { transform: scale(1); filter: drop-shadow(0 0 2px var(--primary)); }
  100% { transform: scale(1.05); filter: drop-shadow(0 0 8px var(--accent)); }
}

@keyframes slide-up {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Responsive adjustments */
@media(max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .table-panel {
    grid-column: 1 / -1;
  }
  .control-panel {
    grid-row: 2;
  }
  .modal-body-layout {
    grid-template-columns: 1fr;
  }
  .column-before {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-right: 0;
    padding-bottom: 24px;
  }
}
