/* ============================================================
   USA PDF Tool — Lightweight Edition
   Shared Dark Theme Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #293548;
  --border: rgba(148,163,184,.12);
  --border-hover: rgba(99,102,241,.5);
  --primary: #6366f1;
  --primary-glow: rgba(99,102,241,.25);
  --primary-hover: #7c7ff3;
  --accent: #06b6d4;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.22s cubic-bezier(.4,0,.2,1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- HEADER ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,23,42,.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 24px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  flex-shrink: 0;
}
.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.header-nav {
  display: flex;
  gap: 4px;
}
.header-nav a {
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}
.header-nav a:hover, .header-nav a.active {
  color: var(--text);
  background: var(--bg3);
}

/* ---- MAIN LAYOUT ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
.page-header {
  text-align: center;
  padding: 56px 24px 40px;
}
.page-header h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #f1f5f9 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.page-header p {
  color: var(--text-muted);
  font-size: 17px;
  max-width: 520px;
  margin: 0 auto;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(99,102,241,.12);
  border: 1px solid rgba(99,102,241,.3);
  color: var(--primary);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* ---- TOOL GRID (homepage) ---- */
.tools-section { padding: 0 0 64px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  margin-bottom: 16px;
  padding: 0 4px;
}
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}
.tool-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  text-decoration: none !important;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.tool-card, .tool-card * {
  text-decoration: none !important;
}
.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-glow), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.tool-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,.35), 0 0 0 1px var(--border-hover);
}
.tool-card:hover::before { opacity: 1; }
.tool-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  position: relative;
  z-index: 1;
}
.tool-card-body { position: relative; z-index: 1; }
.tool-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.tool-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.tool-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}
.tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--bg3);
  color: var(--text-dim);
}
.arrow-icon {
  color: var(--primary);
  opacity: 0;
  transform: translateX(-4px);
  transition: all var(--transition);
  font-size: 18px;
}
.tool-card:hover .arrow-icon {
  opacity: 1;
  transform: translateX(0);
}

/* ---- TOOL PAGE LAYOUT ---- */
.tool-page {
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
}
.tool-workspace {
  flex: 1;
  padding: 40px 24px 64px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.tool-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}
.tool-title-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}
.tool-title-row h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.tool-title-row p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

/* ---- DROP ZONE ---- */
.drop-zone {
  border: 2px dashed #991b1b;
  border-radius: var(--radius);
  padding: 42px 18px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: #b91c1c;
  color: #ffffff;
  position: relative;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: #7f1d1d !important;
  background: #991b1b !important;
  box-shadow: 0 14px 40px rgba(120,15,22,0.30) !important;
}
.drop-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.drop-zone-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}
.drop-zone h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #ffffff;
}
.drop-zone p {
  color: #ffffff;
  font-size: 14px;
}
.drop-zone .btn-browse {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 20px;
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}

/* Hover state: strong red and high-contrast text */
.drop-zone:hover h2,
.drop-zone.dragover h2 {
  color: #ffffff !important;
}
.drop-zone:hover p,
.drop-zone.dragover p {
  color: #fde2e2 !important;
}
.drop-zone:hover .drop-zone-icon,
.drop-zone.dragover .drop-zone-icon {
  color: #ffffff !important;
  transform: scale(1.06);
}
.drop-zone:hover .btn-browse,
.drop-zone.dragover .btn-browse {
  background: rgba(255,255,255,0.18) !important;
  color: #ffffff !important;
  border-color: rgba(255,255,255,0.30) !important;
  box-shadow: 0 8px 18px rgba(0,0,0,0.12) !important;
}

.usapdftool-ad-banner {
  box-sizing: border-box;
  padding: 0 12px;
}

.usapdftool-ad-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid rgba(148,163,184,.16);
  border-radius: 18px;
  padding: 18px 22px;
  width: 100%;
  max-width: 100%;
  color: #111827;
  box-shadow: 0 18px 40px rgba(15,23,42,.08);
}

.usapdftool-ad-banner-top .usapdftool-ad-card,
.usapdftool-ad-banner-bottom .usapdftool-ad-card {
  background: linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(249,250,251,.96) 100%);
}

@media (max-width: 680px) {
  .usapdftool-ad-card {
    padding: 16px 14px;
  }
}

/* ---- FILE LIST ---- */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
.file-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.file-item-icon { font-size: 22px; flex-shrink: 0; }
.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-size { font-size: 12px; color: var(--text-muted); }
.file-item-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
}
.file-item-remove:hover { color: var(--error); background: rgba(239,68,68,.1); }

/* ---- CONTROLS ---- */
.controls {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.control-group { display: flex; flex-direction: column; gap: 8px; }
.control-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.control-group input[type=text],
.control-group input[type=number],
.control-group input[type=password],
.control-group input[type=range],
.control-group select,
.control-group textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
}
.control-group input:focus,
.control-group select:focus,
.control-group textarea:focus {
  border-color: var(--primary);
}
.control-group input[type=range] { padding: 6px 0; cursor: pointer; }
.range-display {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  text-align: right;
}
.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---- ACTION BAR ---- */
.action-bar {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,.35);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99,102,241,.45);
}
.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg2); border-color: var(--border-hover); }
.btn-success {
  background: linear-gradient(135deg, var(--success), #16a34a);
  color: #fff;
  box-shadow: 0 4px 14px rgba(34,197,94,.3);
}
.btn-success:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(34,197,94,.4); }
.btn-danger {
  background: rgba(239,68,68,.12);
  color: var(--error);
  border: 1px solid rgba(239,68,68,.2);
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.2); }
.btn-icon { font-size: 18px; }

/* ---- PROGRESS ---- */
.progress-wrap {
  margin-top: 20px;
  display: none;
}
.progress-wrap.visible { display: block; }
.progress-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width .3s ease;
  width: 0%;
}

/* ---- RESULT ---- */
.result-box {
  margin-top: 24px;
  background: rgba(34,197,94,.07);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: var(--radius);
  padding: 24px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.result-box.visible { display: flex; }
.result-icon { font-size: 40px; }
.result-box h3 { font-size: 18px; font-weight: 600; }
.result-box p { font-size: 14px; color: var(--text-muted); }

/* ---- PAGE PREVIEW ---- */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.page-thumb {
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.page-thumb canvas { width: 100%; height: auto; display: block; }
.page-thumb.selected { border-color: var(--primary); }
.page-thumb:hover { border-color: var(--border-hover); transform: scale(1.02); }
.page-num {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px;
  background: var(--bg2);
}
.page-thumb.selected .page-num { color: var(--primary); font-weight: 600; }
.page-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.page-thumb.selected .page-check { display: flex; }

/* ---- TOAST ---- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .25s ease;
  min-width: 280px;
}
.toast.success { border-color: rgba(34,197,94,.3); }
.toast.error { border-color: rgba(239,68,68,.3); }
.toast.info { border-color: rgba(99,102,241,.3); }
@keyframes slideIn { from { opacity:0; transform: translateX(24px); } }

/* ---- CANVAS EDITOR ---- */
.canvas-container {
  position: relative;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  display: inline-block;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.canvas-container canvas { display: block; }
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
}
.tool-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-btn:hover, .tool-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---- COLOR PICKER ---- */
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
}
.color-swatch.selected { border-color: var(--primary); }
.color-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- FOOTER ---- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .header-nav { display: none; }
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .control-row { grid-template-columns: 1fr; }
  .page-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .action-bar { flex-direction: column; }
  .btn { justify-content: center; }
}

/* ---- EMBEDDED MODE ---- */
.is-embedded .site-header,
.is-embedded .site-footer {
  display: none !important;
}
.is-embedded .tool-page {
  min-height: auto;
}
.is-embedded .tool-workspace {
  padding-top: 20px;
}

/* ---- PREMIUM SUCCESS DOWNLOAD MODAL ---- */
.download-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.download-modal.active {
  opacity: 1;
  pointer-events: auto;
}
.download-modal-card {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  width: 92%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  transform: scale(0.92) translateY(15px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}
.download-modal.active .download-modal-card {
  transform: scale(1) translateY(0);
}
.download-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.download-modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition);
}
.close-modal-btn:hover {
  background: var(--bg3);
  color: var(--text);
}
.success-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: var(--success);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 18px;
}
.file-info-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.file-icon {
  font-size: 28px;
  line-height: 1;
}
.file-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.file-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  word-break: break-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-size {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}
.btn-main-download {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff !important;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  box-shadow: 0 4px 12px var(--primary-glow);
  transition: all var(--transition);
  border: none;
  cursor: pointer;
}
.btn-main-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--primary-glow);
}
.edit-more-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-bottom: 20px;
}
.edit-more-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.tools-handoff-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.handoff-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text) !important;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
  font-weight: 500;
}
.handoff-btn:hover {
  background: var(--bg3);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.handoff-btn-icon {
  font-size: 16px;
}
.modal-ad-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}
.modal-ad-section h4 {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  text-align: center;
  font-weight: 600;
}
.ad-box {
  min-height: 90px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-align: center;
  width: 100%;
}

