/* ============================================================
   Tech Bridge24 — Book Creator Widget
   All classes prefixed with tb-book- to avoid conflicts
   ============================================================ */

/* ── Trigger Button ─────────────────────────────────────── */
.tb-book-trigger {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed) !important;
  color: #fff !important;
  border: none !important;
  padding: .65rem 1.75rem !important;
  border-radius: 50px !important;
  font-weight: 600 !important;
  font-size: .92rem !important;
  transition: all .3s !important;
  box-shadow: 0 4px 15px rgba(139,92,246,.35) !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: .5rem !important;
}
.tb-book-trigger:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 25px rgba(139,92,246,.5) !important;
  color: #fff !important;
}

/* ── Overlay ──────────────────────────────────────────── */
.tb-book-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.75);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s, visibility .3s;
}
.tb-book-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Modal ─────────────────────────────────────────────── */
.tb-book-modal {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: scale(.92) translateY(20px);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}
.tb-book-overlay.active .tb-book-modal {
  transform: scale(1) translateY(0);
}
.tb-book-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.06);
  color: #64748b;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  z-index: 2;
  line-height: 1;
}
.tb-book-close:hover {
  background: rgba(239,68,68,.12);
  color: #ef4444;
}

/* ── Modal Header ──────────────────────────────────────── */
.tb-book-header {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
  padding: 2rem 2rem 1.5rem;
  border-radius: 20px 20px 0 0;
}
.tb-book-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}
.tb-book-header p {
  margin: .4rem 0 0;
  font-size: .88rem;
  opacity: .7;
}

/* ── Modal Body (Form) ─────────────────────────────────── */
.tb-book-body {
  padding: 1.75rem 2rem 2rem;
}
.tb-book-field {
  margin-bottom: 1.25rem;
}
.tb-book-field label {
  display: block;
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: .4rem;
  color: #0f172a;
}
.tb-book-field select,
.tb-book-field textarea {
  width: 100%;
  padding: .65rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: .92rem;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
  color: #334155;
}
.tb-book-field select:focus,
.tb-book-field textarea:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139,92,246,.12);
}
.tb-book-field textarea {
  resize: vertical;
  min-height: 80px;
}
.tb-book-field .tb-book-hint {
  font-size: .78rem;
  color: #94a3b8;
  margin-top: .3rem;
}
.tb-book-submit {
  width: 100%;
  padding: .8rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all .3s;
  box-shadow: 0 4px 20px rgba(139,92,246,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
}
.tb-book-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(139,92,246,.45);
}
.tb-book-submit:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Loading / Generating View ─────────────────────────── */
.tb-book-loading {
  text-align: center;
  padding: 3rem 2rem;
}
.tb-book-loading-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: inline-block;
  animation: tbBookPulse 1.2s ease-in-out infinite;
}
@keyframes tbBookPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: .7; }
}
.tb-book-loading h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: #0f172a;
}
.tb-book-loading p {
  color: #64748b;
  font-size: .9rem;
  margin-bottom: 1.5rem;
}
.tb-book-progress-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  max-width: 400px;
  margin: 0 auto 1rem;
}
.tb-book-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8b5cf6, #a78bfa, #8b5cf6);
  background-size: 200% 100%;
  border-radius: 3px;
  transition: width .4s ease;
  animation: tbBookShimmer 1.5s linear infinite;
}
@keyframes tbBookShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.tb-book-progress-text {
  font-size: .82rem;
  color: #94a3b8;
  margin-top: .3rem;
}

/* ── Book Preview View ─────────────────────────────────── */
.tb-book-preview {
  padding: 2rem;
}
.tb-book-preview-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #f1f5f9;
}
.tb-book-preview-header .tb-book-cover-icon {
  font-size: 3rem;
  margin-bottom: .75rem;
}
.tb-book-preview-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: .3rem;
  color: #0f172a;
}
.tb-book-preview-header .tb-book-author {
  font-size: .9rem;
  color: #64748b;
}
.tb-book-preview-header .tb-book-meta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: .75rem;
  font-size: .8rem;
  color: #94a3b8;
}
.tb-book-preview-header .tb-book-meta span {
  display: flex;
  align-items: center;
  gap: .3rem;
}
.tb-book-chapter {
  margin-bottom: 1.75rem;
  page-break-inside: avoid;
}
.tb-book-chapter-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #8b5cf6;
  margin-bottom: .75rem;
  padding-bottom: .35rem;
  border-bottom: 2px solid #f1f5f9;
}
.tb-book-chapter-number {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: .15rem;
}
.tb-book-paragraph {
  font-size: .95rem;
  line-height: 1.75;
  color: #334155;
  margin-bottom: 1rem;
  text-align: justify;
}
.tb-book-paragraph:first-child::first-letter {
  font-size: 2.6em;
  font-weight: 700;
  float: left;
  line-height: .9;
  padding-right: 6px;
  color: #8b5cf6;
}

/* ── Preview Actions ───────────────────────────────────── */
.tb-book-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 2px solid #f1f5f9;
}
.tb-book-btn {
  padding: .7rem 1.5rem;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: all .25s;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  flex: 1;
  justify-content: center;
}
.tb-book-btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: #fff;
  box-shadow: 0 4px 15px rgba(139,92,246,.3);
}
.tb-book-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(139,92,246,.45);
  color: #fff;
}
.tb-book-btn-secondary {
  background: #f1f5f9;
  color: #475569;
}
.tb-book-btn-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* ── Print / PDF Styles ────────────────────────────────── */
@media print {
  body.tb-book-printing * { visibility: hidden; }
  body.tb-book-printing .tb-book-print-content,
  body.tb-book-printing .tb-book-print-content * { visibility: visible; }
  body.tb-book-printing .tb-book-print-content {
    position: fixed;
    inset: 0;
    padding: 2cm;
    font-family: Georgia, 'Times New Roman', serif;
    color: #1a1a1a;
    background: #fff;
  }
  body.tb-book-printing .tb-book-print-content .tb-book-chapter-title {
    color: #333;
    border-bottom-color: #ccc;
  }
  body.tb-book-printing .tb-book-print-content .tb-book-paragraph:first-child::first-letter {
    color: #333;
  }
  body.tb-book-printing .tb-book-print-content .tb-book-preview-header {
    border-bottom-color: #ccc;
  }
  body.tb-book-printing .tb-book-print-content .tb-book-cover-icon { display: none; }
}

/* ── Scrollbar styling for modal ────────────────────────── */
.tb-book-modal::-webkit-scrollbar { width: 6px; }
.tb-book-modal::-webkit-scrollbar-track { background: transparent; }
.tb-book-modal::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.tb-book-modal::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 576px) {
  .tb-book-header { padding: 1.5rem 1.25rem 1.25rem; }
  .tb-book-body { padding: 1.25rem; }
  .tb-book-preview { padding: 1.25rem; }
  .tb-book-header h2 { font-size: 1.2rem; }
  .tb-book-actions { flex-direction: column; }
}
