/* =====================================================
   DOI Retriever — Dark Mode Glassmorphism Design
   ===================================================== */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --border-glass: rgba(255, 255, 255, 0.1);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Glows */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

.bg-glow-1 {
  width: 600px;
  height: 600px;
  background: var(--accent);
  top: -200px;
  right: -200px;
  animation: float 15s ease-in-out infinite;
}

.bg-glow-2 {
  width: 500px;
  height: 500px;
  background: #8b5cf6;
  bottom: -150px;
  left: -150px;
  animation: float 20s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(30px, -30px); }
  66% { transform: translate(-20px, 20px); }
}

/* Container */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px;
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 48px;
  animation: fadeIn 0.8s ease-out;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.logo-icon {
  font-size: 40px;
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

.logo h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-primary);
}

.accent {
  background: linear-gradient(135deg, var(--accent), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 400;
}

/* Search Box */
.search-section {
  flex: 1;
}

.search-box {
  margin-bottom: 32px;
  animation: fadeIn 0.8s ease-out 0.2s both;
}

.input-wrapper {
  display: flex;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(20px);
  transition: var(--transition);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3), 0 0 0 3px var(--accent-glow);
}

#doiInput {
  flex: 1;
  padding: 18px 24px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  outline: none;
}

#doiInput::placeholder {
  color: var(--text-muted);
}

#searchBtn {
  padding: 18px 32px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border: none;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

#searchBtn:hover {
  background: linear-gradient(135deg, var(--accent-light), #8b5cf6);
  transform: translateX(2px);
}

#searchBtn:active {
  transform: scale(0.98);
}

#searchBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-loader {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#searchBtn.loading .btn-text { display: none; }
#searchBtn.loading .btn-loader { display: block; }

.hint {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.hint code {
  background: var(--bg-glass);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Loading */
.loading-section {
  text-align: center;
  padding: 40px 0;
  animation: fadeIn 0.5s ease-out;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-glass);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

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

.loading-text {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 24px;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 300px;
  margin: 0 auto;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
  transition: var(--transition);
}

.step.active {
  color: var(--accent-light);
}

.step.done {
  color: var(--success);
}

.step-icon {
  width: 24px;
  text-align: center;
}

/* Result Card */
.result-section {
  animation: slideUp 0.6s ease-out;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.result-badge {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  letter-spacing: 0.5px;
}

.result-status {
  color: var(--success);
  font-size: 14px;
  font-weight: 500;
}

.paper-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.paper-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.meta-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.meta-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.meta-text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.meta-text a {
  color: var(--accent-light);
  text-decoration: none;
  transition: var(--transition);
}

.meta-text a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-download {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--success), #059669);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  flex: 1;
  justify-content: center;
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.btn-download:active {
  transform: scale(0.98);
}

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  flex: 1;
  justify-content: center;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Error */
.error-section {
  animation: slideUp 0.6s ease-out;
}

.error-card {
  background: var(--bg-card);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  backdrop-filter: blur(20px);
}

.error-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
}

.error-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.error-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.error-meta {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-glass);
  text-align: left;
}

.error-meta-note {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.error-meta h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.error-meta p {
  font-size: 13px;
}

/* Mirror Panel */
.footer {
  margin-top: auto;
  padding-top: 40px;
  text-align: center;
}

.mirror-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 8px 18px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  margin-bottom: 12px;
}

.mirror-toggle:hover {
  border-color: var(--text-muted);
  color: var(--text-secondary);
}

.mirror-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}

.mirror-indicator.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.mirror-indicator.offline {
  background: var(--error);
}

.mirror-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(20px);
  animation: fadeIn 0.3s ease-out;
}

.mirror-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mirror-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.mirror-item .mirror-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.mirror-dot.ok { background: var(--success); }
.mirror-dot.fail { background: var(--error); }

.mirror-loading {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 8px;
}

.footer-note {
  color: var(--text-muted);
  font-size: 12px;
}

/* Translate Button */
.btn-translate {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  flex: 1;
  justify-content: center;
}

.btn-translate:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.btn-translate:active { transform: scale(0.98); }

.btn-translate.loading {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Translation Section */
.translate-section {
  margin-top: 20px;
  animation: slideUp 0.4s ease-out;
}

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

.translate-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.translate-actions {
  display: flex;
  gap: 8px;
}

.btn-small {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-small:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Progress Bar */
.translate-progress {
  margin-bottom: 20px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-glass);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
  background-size: 200% 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
  animation: progressShimmer 2s linear infinite;
}

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

.progress-text {
  color: var(--text-muted);
  font-size: 13px;
}

/* Translation Content */
.translate-content {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(20px);
  max-height: 70vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.translate-content::-webkit-scrollbar {
  width: 6px;
}

.translate-content::-webkit-scrollbar-track {
  background: transparent;
}

.translate-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.translated-page {
  animation: fadeIn 0.4s ease-out;
}

.page-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 2px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 20px;
}

.translated-page:first-child .page-divider {
  padding-top: 0;
}

/* Typography cho nội dung dịch */
.page-content {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.8;
  margin-bottom: 24px;
}

.page-content h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-light);
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-glass);
}

.page-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 22px 0 10px;
}

.page-content h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 18px 0 8px;
}

.page-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.page-content em {
  color: var(--text-secondary);
  font-style: italic;
}

.page-content code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent-light);
}

.page-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}

.page-content table td,
.page-content table th {
  padding: 8px 12px;
  border: 1px solid var(--border-glass);
  text-align: left;
}

.page-content table tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

.page-content ul, .page-content ol {
  padding-left: 20px;
  margin: 12px 0;
}

.page-content li {
  margin-bottom: 6px;
}

.page-content p {
  margin-bottom: 12px;
}

.page-content blockquote.figure-placeholder {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08));
  border-left: 4px solid #3b82f6;
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.page-content table thead th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  padding: 10px 12px;
}

.page-content hr {
  border: none;
  border-top: 1px solid var(--border-glass);
  margin: 20px 0;
}

/* Hình ảnh trích từ PDF */
.page-figures {
  margin: 16px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.extracted-figure {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}

.extracted-figure img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Utilities */
.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Responsive */
@media (max-width: 640px) {
  .container { padding: 24px 16px; }
  .logo h1 { font-size: 28px; }
  .logo-icon { font-size: 32px; }
  .subtitle { font-size: 14px; }

  .input-wrapper {
    flex-direction: column;
    border-radius: var(--radius-sm);
  }

  #doiInput { padding: 16px 18px; }

  #searchBtn {
    padding: 14px;
    justify-content: center;
    border-top: 1px solid var(--border-glass);
  }

  .result-card { padding: 20px; }
  .paper-title { font-size: 17px; }

  .result-actions {
    flex-direction: column;
  }

  .translate-content {
    padding: 16px;
    max-height: 60vh;
  }

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

