/* ═══════════════════════════════════════════════════════
   Batchdoc-Runner — "Precision Studio" Design System
   A bold, professional aesthetic inspired by creative
   editing suites: dark sidebar, crisp workspace,
   amber accent on deep navy.
   ═══════════════════════════════════════════════════════ */

/* ── Fonts ─────────────────────────────────────────── */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/DMSans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/DMSans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Source Code Pro';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/SourceCodePro-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Keep Inter + JetBrains Mono as fallback */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/Inter-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/Inter-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/JetBrainsMono-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Design Tokens ─────────────────────────────────── */
:root {
  /* Typography — DM Sans as primary, Inter as CJK fallback */
  --font-sans: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Source Code Pro', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-display: 'DM Sans', sans-serif;

  /* ── Color Palette: Deep Navy + Warm Amber ── */

  /* Backgrounds — warm-tinted neutrals */
  --bg-page: #f0f2f5;
  --bg-surface: #ffffff;
  --bg-muted: #f7f8fa;
  --bg-inset: #eef0f4;
  --bg-overlay: rgba(10, 15, 30, 0.6);

  /* Dark sidebar palette */
  --sidebar-bg: #111827;
  --sidebar-surface: rgba(255, 255, 255, 0.06);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #e2e8f0;
  --sidebar-text-muted: #94a3b8;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(245, 158, 11, 0.15);

  /* Text hierarchy */
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --text-placeholder: #9ca3af;
  --text-inverse: #f9fafb;

  /* Accent: Deep Indigo primary + Amber highlight */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-active: #3730a3;
  --accent-subtle: #eef2ff;
  --accent-ring: rgba(79, 70, 229, 0.18);
  --accent-gradient: linear-gradient(145deg, #1e1b4b 0%, #312e81 40%, #4f46e5 100%);

  /* Warm amber for highlights / CTAs */
  --highlight: #f59e0b;
  --highlight-hover: #d97706;
  --highlight-subtle: #fffbeb;
  --highlight-ring: rgba(245, 158, 11, 0.2);

  /* Semantic */
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: rgba(5, 150, 105, 0.25);
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: rgba(220, 38, 38, 0.25);
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: rgba(217, 119, 6, 0.25);
  --info-bg: #eef2ff;
  --info-border: rgba(79, 70, 229, 0.2);

  /* Borders */
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --border-focus: rgba(79, 70, 229, 0.5);

  /* Shadows — warmer tones */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 25px 65px rgba(10, 15, 30, 0.15);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.15);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;
  --duration-slow: 0.4s;
}

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

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
  letter-spacing: -0.01em;
}

/* ── Typography ────────────────────────────────────── */
code, pre, .font-mono {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

/* ── Button System ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
  text-decoration: none;
  min-height: 38px;
  user-select: none;
  letter-spacing: 0;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35), var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.2);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.btn-success {
  background: var(--success);
  color: white;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(5, 150, 105, 0.3);
}

.btn-success:hover:not(:disabled) {
  background: #047857;
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.35);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger-bg);
  color: #991b1b;
  border-color: var(--danger-border);
}

.btn-danger:hover:not(:disabled) {
  background: #fecaca;
  border-color: rgba(220, 38, 38, 0.4);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* Highlight CTA button — amber */
.btn-highlight {
  background: var(--highlight);
  color: #451a03;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
  font-weight: 700;
}

.btn-highlight:hover:not(:disabled) {
  background: var(--highlight-hover);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 30px;
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  padding: 7px;
  min-height: unset;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 14px;
  flex-shrink: 0;
}

/* Loading state */
.btn.loading {
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-secondary.loading::after,
.btn-ghost.loading::after,
.btn-danger.loading::after {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--accent);
}

/* ── Form Controls ─────────────────────────────────── */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  transition:
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

.form-control:hover {
  border-color: var(--border-strong);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-control::placeholder {
  color: var(--text-placeholder);
}

select.form-control {
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 72px;
}

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

/* ── Notices / Alerts ──────────────────────────────── */
.notice {
  display: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  background: var(--bg-muted);
  color: var(--text-muted);
  animation: fadeIn var(--duration-normal) var(--ease-out) both;
}

.notice.error {
  display: block;
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: #7f1d1d;
}

.notice.success {
  display: block;
  border-color: var(--success-border);
  background: var(--success-bg);
  color: #064e3b;
}

.notice.info {
  display: block;
  border-color: var(--info-border);
  background: var(--info-bg);
  color: #3730a3;
}

/* ── Cards & Panels ────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.panel-interactive {
  transition:
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
}

.panel-interactive:hover {
  border-color: rgba(79, 70, 229, 0.2);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ── Modal Framework ───────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  animation: fadeIn var(--duration-fast) ease both;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0,0,0,0.05);
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalEnter var(--duration-slow) var(--ease-out) both;
}

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

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

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

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.22);
}

/* ── Keyframes ─────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

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

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

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

@keyframes ping {
  75%, 100% { transform: scale(2.2); opacity: 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 4px rgba(79, 70, 229, 0.2); }
  50% { box-shadow: 0 0 16px rgba(79, 70, 229, 0.35); }
}

/* ── Status Indicators ─────────────────────────────── */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.inactive {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.status-dot.warning {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1);
}

/* ── Utilities ─────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Reduced Motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive: Mobile ────────────────────────────── */
@media (max-width: 640px) {
  .btn {
    padding: 9px 14px;
    font-size: 13px;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
}
