/* ==========================================================================
   Obsidian-Dark Premium Design System (CSS Variables & Core Styles)
   ========================================================================== */

:root {
  /* Color Palette (Tailored dark hues and vibrant accents) */
  --bg-base: #09090b;
  --bg-surface: rgba(20, 20, 25, 0.7);
  --bg-surface-inner: rgba(30, 30, 40, 0.5);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --primary: #8b5cf6;       /* Violet glow */
  --primary-hover: #a78bfa;
  --primary-dark: #6d28d9;
  --secondary: #27272a;     /* Zinc dark */
  --secondary-hover: #3f3f46;
  
  --accent-blue: #06b6d4;   /* Cyan glow */
  --success: #10b981;       /* Emerald Green */
  --warning: #f59e0b;       /* Amber */
  --error: #ef4444;         /* Rose Red */
  
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dark: #18181b;
  
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Gradient Background Orbs */
.glow-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.15;
  mix-blend-mode: screen;
  animation: float 25s infinite alternate ease-in-out;
}

.orb-1 {
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  width: 600px;
  height: 600px;
  top: -150px;
  right: -100px;
}

.orb-2 {
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
  width: 500px;
  height: 500px;
  bottom: -100px;
  left: -100px;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(50px, 40px) scale(1.1); }
  100% { transform: translate(-30px, -50px) scale(0.95); }
}

/* Glassmorphism Classes */
.glass {
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: 16px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.glass:hover {
  border-color: var(--border-hover);
}

.glass-inner {
  background: var(--bg-surface-inner);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
}

/* App Layout */
.app-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  font-size: 32px;
}

.brand-text h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.header-status {
  display: flex;
  gap: 16px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}

.status-dot.success { background-color: var(--success); }
.status-dot.success::after { border: 1px solid var(--success); }

.status-dot.warning { background-color: var(--warning); }
.status-dot.warning::after { border: 1px solid var(--warning); }

.status-dot.error { background-color: var(--error); }
.status-dot.error::after { border: 1px solid var(--error); }

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Main Content Grid */
.app-main {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
}

.main-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  padding: 24px;
}

.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.section-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Forms & Inputs */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

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

.input-group input,
.input-group select {
  width: 100%;
  padding: 12px 16px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--primary);
  background-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

/* Explicit style for dropdown option elements to avoid invisible text in dark mode on Windows */
select option {
  background-color: #18181b; /* Zinc dark background */
  color: #f4f4f5;            /* White text */
}

/* Buttons */
.button-row {
  display: flex;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 8px;
}

.primary-btn {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
  flex: 1;
}

.primary-btn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.4);
}

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

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

.success-btn {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  flex: 1;
}

.success-btn:hover {
  background-color: rgba(16, 185, 129, 0.25);
}

.error-btn {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.error-btn:hover {
  background-color: rgba(239, 68, 68, 0.25);
}

.text-btn {
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
}

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

.full-width {
  width: 100%;
}

/* Logging Console Box */
.console-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 480px;
}

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

.console-body {
  flex: 1;
  background-color: #050508;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-y: auto;
  max-height: 400px;
  color: #38bdf8; /* Light blue base for logs */
}

.console-line {
  margin-bottom: 6px;
  word-break: break-all;
  white-space: pre-wrap;
}

.console-line.system-msg {
  color: var(--text-muted);
}

.console-line.ocr-msg {
  color: var(--warning);
}

.console-line.success-msg {
  color: var(--success);
}

.console-line.error-msg {
  color: var(--error);
}

/* Tables and Data View */
.app-bottom {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-header {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}

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

.tab-btn.active {
  color: var(--primary-hover);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.table-container {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

th, td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.01);
}

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

/* Badges and tags */
.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.completed { background-color: rgba(16, 185, 129, 0.12); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge.failed { background-color: rgba(239, 68, 68, 0.12); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge.pending { background-color: rgba(245, 158, 11, 0.12); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge.processing { background-color: rgba(6, 182, 212, 0.12); color: var(--accent-blue); border: 1px solid rgba(6, 182, 212, 0.2); }

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal {
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

@keyframes zoomIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.captcha-modal {
  text-align: center;
}

.captcha-modal h2 {
  color: var(--warning);
  font-size: 20px;
  margin-bottom: 12px;
}

.captcha-modal p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.captcha-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.captcha-img-wrapper {
  background-color: #fff;
  border-radius: 8px;
  padding: 6px;
  display: inline-flex;
}

.captcha-img-wrapper img {
  height: 60px;
  display: block;
}

/* Detail Modal */
.detail-modal {
  max-width: 800px;
}

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

.modal-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

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

.modal-body.scrollable {
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-section h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.detail-section p {
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 8px;
}

.detail-section p strong {
  font-weight: 500;
  color: var(--text-muted);
}

.full-width {
  grid-column: span 2;
}

.margin-top {
  margin-top: 16px;
}

.order-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: background-color var(--transition-fast);
}

.order-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

.order-info h4 {
  font-size: 14px;
  font-weight: 600;
}

.order-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.order-link {
  color: var(--accent-blue);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

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

/* Spinner */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-hover);
}
