/* ═══════════════════════════════════════════════════════════════════════════
   ABBYY Vantage OCR — Premium Dark UI
   ═══════════════════════════════════════════════════════════════════════════ */

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

:root {
  --bg-primary:    #0c0d12;
  --bg-surface:    rgba(255, 255, 255, 0.04);
  --bg-surface-2:  rgba(255, 255, 255, 0.06);
  --bg-glass:      rgba(255, 255, 255, 0.05);
  --border:        rgba(255, 255, 255, 0.08);
  --border-focus:  rgba(129, 140, 248, 0.5);
  --text-primary:  #e8e8ed;
  --text-secondary:#8b8b9e;
  --text-muted:    #55556a;
  --accent:        #818cf8;
  --accent-2:      #c084fc;
  --accent-glow:   rgba(129, 140, 248, 0.15);
  --success:       #34d399;
  --success-bg:    rgba(52, 211, 153, 0.08);
  --error:         #f87171;
  --error-bg:      rgba(248, 113, 113, 0.08);
  --warn:          #fbbf24;
  --warn-bg:       rgba(251, 191, 36, 0.08);
  --radius:        14px;
  --radius-sm:     10px;
  --radius-xs:     6px;
  --shadow:        0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow:   0 0 40px rgba(129, 140, 248, 0.08);
  --transition:    all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ─── Background Gradient ───────────────────────────────────────────────── */
.bg-gradient {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(129, 140, 248, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 50%, rgba(192, 132, 252, 0.06), transparent),
    radial-gradient(ellipse 50% 30% at 10% 80%, rgba(99, 102, 241, 0.05), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ─── Page Container ────────────────────────────────────────────────────── */
.page {
  position: relative; z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* ─── Header ────────────────────────────────────────────────────────────── */
.header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 2rem;
}
.header-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(12px);
}
h1 {
  font-size: 1.5rem; font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle {
  font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px;
}

/* ─── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.65rem; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.04em;
  vertical-align: middle; margin-left: 6px;
}
.badge-api     { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(129,140,248,0.2); }
.badge-region  { background: rgba(52,211,153,0.1); color: var(--success); border: 1px solid rgba(52,211,153,0.2); }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(52,211,153,0.15); }
.badge-neutral { background: var(--bg-surface-2); color: var(--text-secondary); border: 1px solid var(--border); }

/* ─── Cards (Glassmorphism) ─────────────────────────────────────────────── */
.card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.card:hover { border-color: rgba(255,255,255,0.12); }
.card-success { border-color: rgba(52,211,153,0.25); box-shadow: var(--shadow), 0 0 30px rgba(52,211,153,0.05); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-label {
  font-size: 0.72rem; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ─── Grid ──────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.col-full { grid-column: 1 / -1; }

/* ─── Form Fields ───────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; }
label {
  font-size: 0.78rem; font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
input[type=text], input[type=password], select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-surface-2);
}
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238b8b9e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select option { background: #1a1b23; color: var(--text-primary); }
.hint { font-size: 0.7rem; color: var(--text-muted); margin-top: 5px; }

/* ─── Drop Zone ─────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed rgba(129,140,248,0.2);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  position: relative;
  overflow: hidden;
}
.drop-zone::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(129,140,248,0.04), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}
.drop-zone:hover::before, .drop-zone.over::before { opacity: 1; }
.drop-zone:hover, .drop-zone.over {
  border-color: var(--accent);
  background: rgba(129,140,248,0.03);
}
.drop-zone-inner { position: relative; z-index: 1; }
.drop-icon {
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  transition: var(--transition);
}
.drop-zone:hover .drop-icon { color: var(--accent); transform: translateY(-4px); }
.drop-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.drop-sub { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 8px; }
.drop-hint {
  display: inline-block; font-size: 0.68rem; font-weight: 500;
  padding: 3px 10px; border-radius: 20px;
  background: var(--bg-surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
input[type=file] { display: none; }

/* ─── File Info ─────────────────────────────────────────────────────────── */
.file-info {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 12px;
  animation: fadeIn 0.3s ease;
}
.file-info-icon { font-size: 1.5rem; }
.file-info-meta { flex: 1; min-width: 0; }
.file-name {
  display: block; font-size: 0.875rem; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-size { font-size: 0.75rem; color: var(--text-muted); }
.file-remove {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.15);
  border-radius: 6px;
  color: var(--error);
  cursor: pointer;
  transition: var(--transition);
}
.file-remove:hover { background: rgba(248,113,113,0.15); }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; width: 100%;
  transition: var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 20px rgba(129,140,248,0.25);
}
.btn-primary:hover {
  box-shadow: 0 6px 30px rgba(129,140,248,0.35);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-download {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 16px;
  width: auto;
  font-size: 0.78rem;
  border-radius: var(--radius-xs);
  text-decoration: none;
  flex-shrink: 0;
}
.btn-download:hover {
  background: var(--accent-glow);
  border-color: rgba(129,140,248,0.3);
  color: var(--accent);
}

/* ─── Alert ─────────────────────────────────────────────────────────────── */
.alert {
  display: flex; gap: 12px;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  animation: slideDown 0.4s ease;
}
.alert-error {
  background: var(--error-bg);
  border: 1px solid rgba(248,113,113,0.2);
}
.alert-icon {
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(248,113,113,0.15);
  border-radius: 50%;
  font-size: 0.7rem; font-weight: 700;
  color: var(--error);
}
.alert-content strong { font-size: 0.85rem; color: var(--error); display: block; margin-bottom: 4px; }
.alert-content ul { padding-left: 1.1rem; }
.alert-content li { font-size: 0.8rem; color: rgba(248,113,113,0.85); margin-top: 2px; }
.alert-content li:nth-child(n+2) { 
  color: var(--text-secondary); 
  background: var(--bg-surface); 
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 8px;
  border-left: 3px solid var(--accent);
  list-style: none;
}

/* ─── Results ───────────────────────────────────────────────────────────── */
.result-file {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.result-file:last-child { border-bottom: none; }
.result-icon { font-size: 1.6rem; flex-shrink: 0; }
.result-meta { flex: 1; min-width: 0; }
.result-meta strong {
  font-size: 0.88rem; font-weight: 500;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-meta span { font-size: 0.72rem; color: var(--text-muted); }
.tag {
  display: inline-block; font-size: 0.6rem; font-weight: 700;
  padding: 1px 7px; border-radius: 4px;
  margin-left: 8px; vertical-align: middle;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.tag-Docx { background: rgba(59,130,246,0.12); color: #60a5fa; }
.tag-Pdf  { background: rgba(248,113,113,0.12); color: var(--error); }
.tag-Json { background: rgba(251,191,36,0.12); color: var(--warn); }
.tag-Text { background: var(--bg-surface-2); color: var(--text-secondary); }
.tag-Xlsx { background: rgba(52,211,153,0.12); color: var(--success); }

/* ─── Log ───────────────────────────────────────────────────────────────── */
.log-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.log-item {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 0.8rem;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}
.log-item:hover { background: var(--bg-surface); }
.log-icon { flex-shrink: 0; font-size: 1rem; }
.log-body { flex: 1; min-width: 0; }
.log-label { font-weight: 600; color: var(--text-primary); }
.log-detail {
  font-size: 0.72rem; color: var(--text-muted);
  margin-top: 2px;
  word-break: break-all;
}
.log-time {
  font-size: 0.65rem; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.log-info    .log-label { color: var(--accent); }
.log-success .log-label { color: var(--success); }
.log-warn    .log-label { color: var(--warn); }

/* ─── Spinner ───────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── Footer ────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.footer p { font-size: 0.72rem; color: var(--text-muted); }
.footer a { color: var(--text-secondary); text-decoration: none; transition: var(--transition); }
.footer a:hover { color: var(--accent); }

/* ─── Animations ────────────────────────────────────────────────────────── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

.card    { animation: fadeIn 0.4s ease both; }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
form .card:first-child { animation-delay: 0.15s; }
form .card:last-of-type { animation-delay: 0.2s; }
.btn-primary { animation: fadeIn 0.4s ease 0.25s both; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .page { padding: 1.5rem 1rem 3rem; }
  h1 { font-size: 1.25rem; }
  .result-file { flex-wrap: wrap; }
  .btn-download { width: 100%; justify-content: center; }
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
