/* ========================================
   DocToMD — Light Minimal Theme
   ======================================== */

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

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --error: #dc2626;
  --error-light: #fef2f2;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.06);
  --max-width: 720px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Header --- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.engine-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  transition: background 0.3s;
}

.engine-status.ready .status-dot { background: var(--success); }
.engine-status.error .status-dot { background: var(--error); }

/* --- Main --- */
.main {
  flex: 1;
  padding-top: 32px;
  padding-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Drop Zone --- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-icon {
  width: 48px;
  height: 48px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.drop-zone.dragover .drop-icon { color: var(--primary); }

.drop-text {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.drop-subtext {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.drop-formats {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-icon {
  padding: 6px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-icon:hover { background: var(--bg); }

/* --- Tabs --- */
.tab-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tab {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.tab:not(:last-child) { border-right: 1px solid var(--border); }
.tab.active { background: var(--primary); color: #fff; }
.tab:hover:not(.active) { background: var(--bg); }

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

/* --- File List --- */
.file-list {
  list-style: none;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg); }
.file-item.active { background: var(--primary-light); }

.file-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  flex-shrink: 0;
}

.file-item-icon.pdf { background: #ef4444; }
.file-item-icon.docx { background: #2563eb; }
.file-item-icon.xlsx { background: #16a34a; }
.file-item-icon.pptx { background: #f59e0b; }
.file-item-icon.html { background: #8b5cf6; }
.file-item-icon.csv { background: #06b6d4; }
.file-item-icon.epub { background: #ec4899; }
.file-item-icon.default { background: #6b7280; }

.file-item-info {
  flex: 1;
  min-width: 0;
}

.file-item-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.file-item-status {
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.file-item-error {
  font-size: 11px;
  color: var(--error);
  margin-top: 2px;
  word-break: break-word;
}

.file-item-status.pending { color: var(--text-secondary); }
.file-item-status.converting { color: var(--primary); }
.file-item-status.done { color: var(--success); }
.file-item-status.error { color: var(--error); }

/* --- Progress Bar --- */
.progress-bar {
  width: 80px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* --- Result Panel --- */
.result-body {
  max-height: 500px;
  overflow: auto;
}

.result-raw {
  margin: 0;
  padding: 16px 20px;
  font-size: 13px;
  line-height: 1.7;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-wrap: break-word;
  background: transparent;
}

.result-raw code {
  font-family: inherit;
}

.result-preview {
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
}

.result-preview h1 { font-size: 24px; margin: 16px 0 8px; }
.result-preview h2 { font-size: 20px; margin: 14px 0 6px; }
.result-preview h3 { font-size: 17px; margin: 12px 0 4px; }
.result-preview p { margin: 0 0 12px; }
.result-preview ul, .result-preview ol { margin: 0 0 12px; padding-left: 24px; }
.result-preview pre { background: var(--bg); border-radius: var(--radius-sm); padding: 12px; margin: 0 0 12px; overflow-x: auto; }
.result-preview code { font-family: var(--font-mono); font-size: 13px; }
.result-preview table { width: 100%; border-collapse: collapse; margin: 0 0 12px; }
.result-preview th, .result-preview td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: 13px; }
.result-preview th { background: var(--bg); font-weight: 600; }
.result-preview blockquote { border-left: 3px solid var(--primary); padding-left: 14px; color: var(--text-secondary); margin: 0 0 12px; }
.result-preview img { max-width: 100%; border-radius: var(--radius-sm); }

/* --- History --- */
.history-list {
  list-style: none;
}

.history-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child { border-bottom: none; }

.history-item-info {
  flex: 1;
  min-width: 0;
}

.history-item-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.history-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
}

.toast.show {
  opacity: 1;
}

/* --- Footer --- */
.footer {
  padding: 20px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .drop-zone { padding: 32px 16px; }
  .card-header { padding: 12px 16px; }
  .file-item { padding: 10px 16px; }
  .history-item { padding: 10px 16px; }
  .result-raw { padding: 12px 16px; }
  .result-preview { padding: 16px; }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .card-actions {
    flex-wrap: wrap;
  }

  .result-body { max-height: 400px; }
}

/* --- Animations --- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-dot.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* --- Scrollbar --- */
.result-body::-webkit-scrollbar { width: 6px; }
.result-body::-webkit-scrollbar-track { background: transparent; }
.result-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.result-body::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
