/* =========================================
   QUILL SNOW THEME v1.3.6
   Imported for complete Quill editor styling
   ========================================= */
@import url('quill.snow.css');

/* =========================================
   PROFESSIONAL TBOOK BUILDER INTERFACE
   ========================================= */

/* Global Reset and Base Styles */
html body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  min-height: 100vh;
  color: #4a5568;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  text-align: center;
  scroll-behavior: smooth;
  background: linear-gradient(135deg, #fafafb 0%, #d3e9fe 100%);
  color: #212529;
}

.chapter-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: #4a5568;
  margin-bottom: 1rem;
}

/*==================================
   BOOK_FORM.HTML BUILDER STYLES
   ============================== */
.notes {
  margin: 15px 0; 
  padding: 15px; 
  background-color: #e8f4fd; 
  border-left: 4px solid #007bff; 
  border-radius: 4px;
  font-size: 18px;
  line-height: 1.4;
}

.notes-big {
  margin-top: 10px;
  padding: .5rem 1rem .5rem 1rem;
  font-size: clamp(1.1rem, 1.5vw + 0.7rem, 1.5rem);
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
  border-radius: 4px;
  text-align: center;
}
.info-container {
  margin-top: 15px;
  margin-left: 3rem;
  margin-right: 3rem;
  padding: 12px;
  background-color: #c9e9ef;
  border: 1px solid #bee5eb;
  border-radius: 4px;
  text-align: center;
  justify-content: center;
}
.text1 {
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  padding: .5rem 1rem .5rem 1rem;
}
.text2 {
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  margin: 0 0 20px 0;
}
.text3 {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 20px 0;
}
.enter-book-details {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  padding: .5rem 1rem .5rem 1rem;
}
.book-title {
  font-size: 2rem;
  text-align: center;
  padding: .5rem 1rem .5rem 1rem;
}
/* Form Section Containers */
.form-section {
  margin: 20px 0;
  padding: 15px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
}

/* Form Inputs */
input[type="text"],
input[type="url"],
input[type="file"],
select,
textarea {
  width: 100%;
  max-width: 600px;
  padding: 1rem;
  margin: 0.5rem auto 0 auto;
  border: 3px solid #93bbea;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #ffffff;
  transition: all 0.3s ease;
  box-sizing: border-box;
  display: block;
}

/* Responsive form inputs */
@media (max-width: 767px) {
  input[type="text"],
  input[type="url"],
  input[type="file"],
  select,
  textarea {
    max-width: none;
    margin: 0.5rem 0 0 0;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  input[type="text"],
  input[type="url"],
  input[type="file"],
  select,
  textarea {
    max-width: 500px;
  }
}

input[type="text"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #4299e1;
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

input[type="text"]:hover,
input[type="url"]:hover,
select:hover,
textarea:hover {
  border-color: #5a6c7d;
}

.selected-cover-file {
  display: none;
  margin: 10px 0;
  padding: 8px;
  background-color: #e8f4fd;
  border: 3px solid #93bbea !important;
  color: #007bff;
  font-size: 14px;
}
/* ==============================
   EXISTING CHAPTERS LIST STYLES
   (moved from book_chapter.html)
   Scoped to builder interface only
   ============================== */
.chapters-full-width {
  width: 100vw;
  max-width: none;
  margin-left: calc(-50vw + 50%);
  padding: 20px;
  background: rgba(248, 250, 252, 0.3);
}

.chapters-title {
  text-align: center;
  color: #2d3748;
  margin-bottom: 30px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  font-size: clamp(1.3rem, 2vw + 0.8rem, 2rem);
}

.chapters-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.chapter-row {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 2em;
  padding: 25px;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chapter-main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chapter-header-section {
  display: flex;
  gap: 20px;
  align-items: start;
}

.chapter-image-wrapper {
  flex: 0 0 200px;
  width: 200px;
}

.chapter-info-wrapper {
  margin: 0 0 8px 0; 
  color: #2d3748; 
  font-size: 20px;
  flex: 1;
  min-width: 0;
  text-align: center;
}

.chapter-content-preview {
  background: rgba(248, 250, 252, 0.8);
  border-radius: 8px;
  padding: 20px;
  margin: 15px 0;
  color: #2d3748;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.chapter-actions {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: start;
  padding-top: 15px;
  border-top: 1px solid #e2e8f0;
}

.reorder-controls {
  flex: 0 0 auto;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  padding: 15px 20px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  min-width: 160px;
}

/* Style reorder buttons to match action buttons */
.reorder-controls button {
  background: linear-gradient(135deg, #fafafb 0%, #d3e9fe 100%);
  border-bottom: 2px solid #111;
  color: #333;
  backdrop-filter: blur(10px);
  padding: 0.8rem 1.5rem;
  text-decoration: none !important;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1.2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
  margin: 0 5px;
  min-width: 45px;
}

.reorder-controls button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.action-buttons {
  flex: 1;
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Style action buttons to match fixed-buttons (sidebar) styling */
.action-buttons button {
  background: linear-gradient(135deg, #fafafb 0%, #d3e9fe 100%);
  border-bottom: 2px solid #111;
  color: #333;
  backdrop-filter: blur(10px);
  padding: 0.8rem 1.5rem;
  text-decoration: none !important;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  white-space: nowrap;
  cursor: pointer;
  margin: 0;
}

.action-buttons button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

/* Mobile */
@media (max-width: 768px) {
  .chapters-full-width {
    padding: 15px;
  }
  .chapters-section {
    padding: 0 10px;
  }
  .chapter-row {
    padding: 20px;
    gap: 15px;
  }
  .chapter-header-section {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
  .chapter-image-wrapper {
    flex: none;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
  }
  .chapter-actions {
    flex-direction: column;
    gap: 15px;
  }
  .reorder-controls {
    min-width: auto;
    width: 100%;
  }
  .action-buttons {
    flex-direction: column;
    gap: 10px;
  }
  .action-buttons button {
    min-width: auto;
    width: 100%;
    font-size: 13px;
    padding: 12px;
    margin: 0;
  }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  .chapter-header-section {
    gap: 25px;
  }
  .chapter-image-wrapper {
    flex: 0 0 180px;
    width: 180px;
  }
  .chapter-actions {
    flex-wrap: wrap;
    gap: 15px;
  }
  .action-buttons {
    gap: 12px;
  }
  .action-buttons button {
    min-width: 130px;
  }
}

/* Desktop */
@media (min-width: 1025px) {
  .chapter-header-section {
    gap: 30px;
  }
  .chapter-image-wrapper {
    flex: 0 0 220px;
    width: 220px;
  }
  .chapter-actions {
    gap: 25px;
  }
  .reorder-controls {
    min-width: 180px;
  }
  .action-buttons button {
    min-width: 150px;
  }
}

/* Large desktop */
@media (min-width: 1400px) {
  .chapters-section {
    max-width: 1300px;
  }
  .chapter-row {
    padding: 30px;
    gap: 25px;
  }
  .chapter-header-section {
    gap: 35px;
  }
  .chapter-image-wrapper {
    flex: 0 0 240px;
    width: 240px;
  }
}

/* Hover and content styles */
.chapter-image-wrapper img,
.chapter-image-wrapper > section {
  transition: all 0.3s ease;
  border-radius: 8px;
}

/* ==========================================
   Editing Alert Bar and Info Banners
   ========================================== */

/* Editing alert shown when a chapter is being edited */
.edit-alert {
  background-color: #e7f3ff;
  border: 1px solid #b3d9ff;
  padding: 10px;
  margin-bottom: 1em;
  border-radius: 5px;
}

.edit-alert .edit-cancel-link {
  float: right;
  color: #666;
  text-decoration: none;
  font-size: 12px;
}

.edit-alert .edit-cancel-link:hover {
  text-decoration: underline;
  color: #333;
}

/* Generic info banner */
.info-banner {
  padding: 12px 15px;
  border-radius: 5px;
  margin-bottom: 15px;
}

/* Warning (yellow) variants */
.info-banner.warning {
  background-color: #fff3cd;
  border: 2px solid #ffc107;
  border-left: 5px solid #ff6b35;
  color: #856404;
}

/* Compact version of warning banner (no full border, only left accent) */
.info-banner.warning.compact {
  border: none;
  border-left: 4px solid #ffc107;
  padding: 10px 12px;
  margin-bottom: 10px;
}

/* Informational (blue) variant */
.info-banner.info {
  background-color: #e7f3ff;
  border-left: 4px solid #007bff;
  font-size: 14px;
  margin-top: 10px;
}

/* Typography inside banners */
.info-banner {
  color: inherit;
  margin-top: 0;
  margin-bottom: 0.5em;
}

.info-banner p {
  color: inherit;
  margin-bottom: 0;
}

/* Container for main content */
> * {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header Styling */
header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  text-align: center;
  padding: 2rem 0;
  margin-bottom: 3rem;
}
header img {
  background-color: aliceblue;
  width: 100px;
  height: 100px;
}
.chapter-management {
  font-size: 2.5rem;
  font-weight: 700;
  color: #2d3748;
  margin: 0 0 1rem 0;
  text-shadow: none;
  text-transform: none;
  letter-spacing: -0.5px;
  text-align: center;
}

.add-a-chapter {
  font-size: 2.2rem;
  font-weight: 400;
  color: #718096;
  margin: 0;
  text-shadow: none;
  text-transform: none;
  background: none;
  padding: 0;
  text-align: center;
}

/* Form Container */
form {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 3rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  margin: 2rem auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
}

/* Form Labels */
label {
  display: block;
  margin: 2rem auto 0.5rem auto;
  font-weight: 600;
  font-size: 1.5rem;
  color: #2d3748;
  letter-spacing: 0.3px;
  text-align: center;
  max-width: 600px;
}


.customize-theme-active {
  color: #856404; 
  margin-top: 0;
  font-size: clamp(1.1rem, 1.5vw + 0.7rem, 1.5rem);
}

/* Buttons */
button,
.button {
  background: linear-gradient(135deg, #fafafb 0%, #d3e9fe 100%);
  border: none;
  border-bottom: 2px solid #111;
  color: #333;
  backdrop-filter: blur(10px);
  padding: 0.8rem 1.5rem;
  text-decoration: none !important;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  white-space: nowrap;
  cursor: pointer;
}

button:hover,
.button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(66, 153, 225, 0.4);
}

/* Disabled button state */
button:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  pointer-events: none; /* Prevent any click events */
}

button:disabled:hover,
.button:disabled:hover {
  transform: none; /* Prevent hover transform on disabled buttons */
  box-shadow: 0 4px 15px rgba(66, 153, 225, 0.3); /* Keep original shadow */
}

/* Special Button Variants */
button.delete-chapter {
  background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
  box-shadow: 0 4px 15px rgba(245, 101, 101, 0.3);
}

button.delete-chapter:hover {
  box-shadow: 0 8px 25px rgba(245, 101, 101, 0.4);
}

/* App Description Section */
.app-description {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 2.5rem;
  margin: 2rem auto;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  justify-content: center;
}

.app-description p {
  font-size: 1.2rem;
  line-height: 1.7;
  color: #4a5568;
  margin-bottom: 2rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.app-description .justify-content-center {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.customize-theme-important {
  color: #856404; 
  margin-bottom: 0; 
  font-weight: 500;
}
.app-description .button {
  background: rgba(66, 153, 225, 0.1);
  color: #4299e1;
  border: 2px solid #4299e1;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-block;
}

.app-description .button:hover {
  background: #4299e1;
  color: white;
  transform: translateY(-2px);
}

/* Fixed Action Buttons */
.fixed-buttons {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fixed-buttons button {
  background: linear-gradient(135deg, #fafafb 0%, #d3e9fe 100%);
  border-bottom: 2px solid #111;
  color: #333;
  backdrop-filter: blur(10px);
  padding: 0.8rem 1.5rem;
  text-decoration: none !important;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  display: inline-block;
}

.fixed-buttons a:hover,
.fixed-buttons button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}


/* Quick action buttons styling */
.fixed-buttons a.quick-action {
  font-weight: 600;
  transition: all 0.2s ease;
}

.fixed-buttons a.quick-action:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2);
}

.fixed-buttons a.quick-action:active {
  transform: translateY(-1px) scale(0.98);
}

/* Footer */
footer {
  text-align: center;
  margin-top: 4rem;
  padding: 1rem;
  background: rgb(255, 255, 255);
  backdrop-filter: blur(10px);
  color: #718096;
  font-size: 0.9rem;
  border-radius: 16px;
}

/* Paragraphs and Text */
p {
  margin-bottom: 1rem;
  color: #4a5568;
}

/* Links */
a {
  color: #4299e1;
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: #3182ce;
}

/* Information Boxes */
section[style*="background-color: #e8f4fd"],
section[style*="background-color: #fff3cd"],
section[style*="background-color: #d1ecf1"],
section[style*="background-color: #d4edda"] {
  background: rgba(66, 153, 225, 0.1) !important;
  border: 1px solid rgba(66, 153, 225, 0.2) !important;
  border-radius: 12px !important;
  padding: 1.5rem !important;
  margin: 1.5rem auto !important;
  color: #2d3748 !important;
  border-left: 4px solid #4299e1 !important;
  max-width: 800px !important;
  text-align: center !important;
}

/* Project Management Section */
section[style*="border: 1px solid #ddd"] {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 16px !important;
  padding: 2rem !important;
  margin: 2rem 0 !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

/* Checkboxes */
input[type="checkbox"] {
  width: auto !important;
  margin-right: 0.5rem;
  transform: scale(1.2);
}

/* Checkbox Labels */
.checkbox-label {
  display: flex !important;
  align-items: center;
  font-weight: normal !important;
  margin-bottom: 8px !important;
  margin-top: 0 !important;
  text-align: left !important;
}

/* Meta cover image styling */
.meta-cover-image {
  max-width: 300px;
  height: auto;
  display: block;
  margin: 15px auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Theme selector styling */
.theme-select {
  background-color: #f8f9fa !important;
  color: #495057 !important;
  padding: 1rem !important;
  border-radius: 8px !important;
  border: 3px solid #93bbea !important;
  font-size: 1rem !important;
  font-family: inherit !important;
  width: 100% !important;
  max-width: 600px !important;
  margin: 0.5rem auto 0 auto !important;
  display: block !important;
  box-sizing: border-box !important;
}

/* Theme selector options */
.theme-select option {
  background-color: #f8f9fa !important;
  color: #495057 !important;
  padding: 8px !important;
}

/* Button variants */
.button.success {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
  box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3) !important;
}

.button.success:hover {
  box-shadow: 0 8px 25px rgba(40, 167, 69, 0.4) !important;
}

.button.danger {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
  box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3) !important;
}
.text-danger {
  color: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
  font-weight: 400;
}
.button.danger:hover {
  box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4) !important;
}

.button.info {
  background: linear-gradient(135deg, #17a2b8 0%, #138496 100%) !important;
  box-shadow: 0 4px 15px rgba(23, 162, 184, 0.3) !important;
}

.button.info:hover {
  box-shadow: 0 8px 25px rgba(23, 162, 184, 0.4) !important;
}

/* File inputs */
input[type="file"] {
  padding: 0.8rem;
  border: 2px dashed #e1e8ed;
  background: #f8f9fa;
  cursor: pointer;
}

input[type="file"]:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}

/* Post-form content styling */
form ~ * {
  text-align: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
  max-width: 800px !important;
}

form ~ section,
form ~ button {
  text-align: center !important;
}

/* Project management and post-form sections */
form ~ section {
  text-align: center !important;
}

form ~ section p {
  text-align: center !important;
}

/* Warning button colors for specific actions */
button[onclick*="clearForm"],
.button[onclick*="clearForm"] {
  background: linear-gradient(135deg, #f6d55c 0%, #ed8b00 100%) !important;
  color: #2d3748 !important;
  box-shadow: 0 4px 15px rgba(246, 213, 92, 0.3) !important;
}

button[onclick*="clearForm"]:hover,
.button[onclick*="clearForm"]:hover {
  box-shadow: 0 8px 25px rgba(246, 213, 92, 0.4) !important;
}

/* Delete project button - red warning */
a[onclick*="confirm"],
button[onclick*="confirm"],
.button[onclick*="confirm"] {
  background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%) !important;
  color: white !important;
  box-shadow: 0 4px 15px rgba(245, 101, 101, 0.3) !important;
}

a[onclick*="confirm"]:hover,
button[onclick*="confirm"]:hover,
.button[onclick*="confirm"]:hover {
  box-shadow: 0 8px 25px rgba(245, 101, 101, 0.4) !important;
}

/* Reader view button styling */
form ~ section a {
  background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%) !important;
  color: white !important;
  border-radius: 8px !important;
  padding: 12px 24px !important;
  text-decoration: none !important;
  font-weight: 600 !important;
  display: inline-block !important;
  margin: 0.5rem !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 4px 15px rgba(66, 153, 225, 0.3) !important;
}

form ~ section a:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 25px rgba(66, 153, 225, 0.4) !important;
}

/* Download backup button - keep green */
a[href*="download_project"] {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%) !important;
  color: white !important;
  box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3) !important;
}

a[href*="download_project"]:hover {
  box-shadow: 0 8px 25px rgba(72, 187, 120, 0.4) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  {
    padding: 0 10px;
  }
  
  form {
    padding: 2rem;
    margin: 1rem auto;
  }

  .app-description .justify-content-center {
    flex-direction: column;
  }
  
  .fixed-buttons {
    position: static;
    flex-direction: row;
    justify-content: center;
    margin: 1rem 0;
  }
  
  .fixed-buttons a {
    font-size: 0.8rem;
    padding: 0.6rem 1rem;
  }
}

/* Additional responsive breakpoints for fixed buttons */
@media (max-width: 1200px) {
  .fixed-buttons {
    right: 15px;
  }
  
  .fixed-buttons a {
    font-size: 0.85rem;
    padding: 0.7rem 1.3rem;
  }
}

@media (max-width: 1024px) {
  .fixed-buttons {
    right: 10px;
    gap: 8px;
  }
  
  .fixed-buttons a {
    font-size: 0.8rem;
    padding: 0.65rem 1.2rem;
  }
}

@media (max-width: 900px) {
  .fixed-buttons {
    position: fixed; /* Keep them fixed instead of static */
    right: 8px;
    gap: 6px;
  }
  
  .fixed-buttons a {
    font-size: 0.75rem;
    padding: 0.6rem 1rem;
    border-radius: 8px;
  }
}

@media (max-width: 768px) {
  /* Override the previous static positioning for very small screens */
  .fixed-buttons {
    position: static;
    flex-direction: row;
    justify-content: center;
    margin: 1rem 0;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .fixed-buttons a {
    font-size: 0.7rem;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .fixed-buttons a {
    font-size: 0.65rem;
    padding: 0.4rem 0.6rem;
    min-width: 100px;
    /* Truncate long text on very small screens */
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Chapter and Editor Components (for book_chapter.html) */
.chapter-actions {
  margin-top: 15px;
  text-align: center;
}

.editor-selector {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.editor-selector button {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  border: 2px solid #667eea;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  margin-right: 1rem;
  transition: all 0.3s ease;
}

.editor-selector button.active,
.editor-selector button:hover {
  background: #667eea;
  color: white;
}

.editor-container {
  min-height: 400px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Text Center Utility */
.text-center {
  text-align: center;
}

/* =========================================
   EDITOR AREA STYLES (for book_chapter.html)
   ========================================= */

/* Editor area exclusion - ensure editor content uses theme CSS only */
.editor-area {
  /* Reset any inherited builder styles that might interfere with editors */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  font-size: initial;
  line-height: initial;
  color: initial;
  background: initial;
  width: 100%;
  box-sizing: border-box;
}

/* Responsive editor area */
@media (max-width: 767px) {
  .editor-area {
    margin: 0;
    padding: 0;
  }
  
  .editor-area #quillEditorContainer,
  .editor-area #htmlEditorContainer {
    min-height: 400px;
  }
  
  .editor-area #quillEditor {
    height: 380px !important;
  }
  
  .editor-area #htmlTextarea {
    height: 380px !important;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .editor-area #quillEditorContainer,
  .editor-area #htmlEditorContainer {
    min-height: 450px;
  }
  
  .editor-area #quillEditor {
    height: 430px !important;
  }
  
  .editor-area #htmlTextarea {
    height: 430px !important;
  }
}

/* Ensure only one editor container is visible at a time */
.editor-area #quillEditorContainer.hidden,
.editor-area #htmlEditorContainer.hidden {
  display: none !important;
  visibility: hidden !important;
}

/* Default states - Quill visible by default */
.editor-area #quillEditorContainer {
  display: block !important;
}

.editor-area #htmlEditorContainer {
  display: none !important;
}

/* Override when HTML mode is active */
.editor-area.html-mode #quillEditorContainer {
  display: none !important;
  visibility: hidden !important;
}

.editor-area.html-mode #htmlEditorContainer {
  display: block !important;
  visibility: visible !important;
}

/* Ensure HTML textarea uses monospace font */
.editor-area #htmlTextarea {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
}

/* =========================================
   QUILL EDITOR ISOLATION (moved from template)
   Ensures builder UI styles do not leak into Quill
   ========================================= */

/* Core Quill elements - complete reset within builder interface */
.ql-container,
.ql-editor,
.quill-editor,
.editor-area,
.editor-container,
#quillEditorContainer,
#quillEditor {
  text-align: left !important;
  margin: 0 !important;
  padding: initial !important;
  background: initial !important;
  color: initial !important;
  font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif !important;
  font-size: 14px !important;
  line-height: 1.42 !important;
  border: initial !important;
  border-radius: initial !important;
  box-shadow: initial !important;
  max-width: none !important;
  width: auto !important;
  display: block !important;
  float: none !important;
  position: static !important;
  transform: none !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  font-weight: normal !important;
}

/* Reorder Quill elements to put toolbar at bottom */
#quillEditorContainer {
  position: relative !important;
  overflow: visible !important; /* Changed from auto to visible - allows dropdowns to escape */
  max-height: 80vh !important;
}

/* Target the actual Quill editor div where toolbar and container are created */
/* This is critical - Quill creates .ql-toolbar and .ql-container as children of #quillEditor */
#quillEditor {
  display: flex !important;
  flex-direction: column-reverse !important;
  min-height: 500px !important;
  overflow: visible !important;
  position: relative !important;
}

/* Quill container - let it grow with content */
.ql-container {
  flex: 1 1 auto !important;
  overflow-y: auto !important; /* Move the scrolling here instead of parent */
  overflow-x: visible !important; /* Allow horizontal overflow for dropdowns */
  order: 2 !important; /* Ensure container comes after toolbar in visual order */
  max-height: calc(80vh - 80px) !important; /* Account for toolbar height */
}

/* Quill editor content area - primary user typing surface */
.ql-editor {
  text-align: left !important;
  font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif !important;
  font-size: 14px !important;
  line-height: 1.42 !important;
  color: #333 !important;
  background: white !important;
  padding: 12px 15px !important;
  border: none !important;
  outline: none !important;
  overflow-y: auto !important;
  tab-size: 4 !important;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  min-height: 480px !important;
  max-height: none !important;
  height: auto !important;
}

/* Make <br> tags properly render as single line breaks in Quill editor */
/* The key is to ensure they maintain their natural line-breaking behavior */
.ql-editor br {
  display: inline;
  line-height: inherit;
}

/* Don't add any pseudo-elements that might interfere */
.ql-editor br::before,
.ql-editor br::after {
  content: none;
}

/* Visual distinction between single-spaced and double-spaced paragraphs */
/* Single-spaced paragraphs (default) */
.ql-editor p {
  margin-bottom: 0.5em;
  line-height: 1.5;
}

/* Paragraphs containing <br> tags get tighter internal spacing */
/* This shows the difference between paragraph breaks and line breaks */
.ql-editor p:has(br) {
  line-height: 1.2;
  margin-bottom: 0.8em;
}

/* Alternative: Add a subtle visual indicator for paragraphs with br tags */
.ql-editor p:has(br) {
  border-left: 2px solid rgba(66, 153, 225, 0.15);
  padding-left: 8px;
}

/* =========================================
   HEADER DIFFERENTIATION IN EDITOR
   Clear visual hierarchy for h1-h6
   ========================================= */

.ql-editor h1 {
  font-size: 2.5em !important;
  font-weight: 700 !important;
  color: #1a202c !important;
  margin-top: 1em !important;
  margin-bottom: 0.5em !important;
  padding-bottom: 0.3em !important;
  border-bottom: 3px solid #4299e1 !important;
  line-height: 1.2 !important;
}

.ql-editor h2 {
  font-size: 2em !important;
  font-weight: 600 !important;
  color: #2d3748 !important;
  margin-top: 0.9em !important;
  margin-bottom: 0.45em !important;
  padding-bottom: 0.25em !important;
  border-bottom: 2px solid #90cdf4 !important;
  line-height: 1.25 !important;
}

.ql-editor h3 {
  font-size: 1.6em !important;
  font-weight: 600 !important;
  color: #4a5568 !important;
  margin-top: 0.8em !important;
  margin-bottom: 0.4em !important;
  line-height: 1.3 !important;
}

.ql-editor h4 {
  font-size: 1.35em !important;
  font-weight: 600 !important;
  color: #4a5568 !important;
  margin-top: 0.75em !important;
  margin-bottom: 0.35em !important;
  line-height: 1.35 !important;
}

.ql-editor h5 {
  font-size: 1.15em !important;
  font-weight: 600 !important;
  color: #718096 !important;
  margin-top: 0.7em !important;
  margin-bottom: 0.3em !important;
  line-height: 1.4 !important;
}

.ql-editor h6 {
  font-size: 1em !important;
  font-weight: 700 !important;
  color: #718096 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  margin-top: 0.65em !important;
  margin-bottom: 0.25em !important;
  line-height: 1.4 !important;
}


/* Quill toolbar layout and interaction */
.ql-toolbar {
  border: 2px solid #0056b3 !important;
  border-top: 3px solid #003d82 !important;
  box-sizing: border-box !important;
  font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif !important;
  padding: 10px 15px !important;
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: flex-start !important;
  align-items: center !important;
  min-height: 52px !important;
  line-height: 1.2 !important;
  background: linear-gradient(to bottom, #007bff, #0056b3) !important;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15) !important;
  /* Sticky to bottom of scrolling container */
  position: sticky !important;
  bottom: 0 !important;
  order: 0 !important; /* Toolbar should appear first in visual order due to column-reverse */
  z-index: 1000 !important;
}

.ql-toolbar .ql-formats {
  display: inline-block !important;
  vertical-align: top !important;
  margin-right: 15px !important;
  text-align: left !important;
  padding: 4px !important;
}

.ql-toolbar .ql-formats:last-child {
  margin-right: 0 !important;
}

/* Toolbar controls */
.ql-toolbar button,
.ql-toolbar .ql-picker {
  background: rgba(255, 255, 255, 0.95) !important;
  border: 1px solid #65a0cd !important;
  cursor: pointer !important;
  display: inline-block !important;
  height: 36px !important;
  padding: 6px 8px !important;
  min-width: 42px !important;
  text-align: center !important;
  margin: 3px 5px !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  color: #111 !important;
  border-radius: 5px !important;
  vertical-align: top !important;
  outline: none !important;
  line-height: 1.2 !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  position: relative !important;
}

/* Ensure SVG icons and text are properly sized */
.ql-toolbar button svg,
.ql-toolbar .ql-picker svg {
  width: 18px !important;
  height: 18px !important;
  fill: currentColor !important;
}

/* Make sure button text is readable - including pseudo-elements */
.ql-toolbar button::before,
.ql-toolbar .ql-picker-label::before {
  font-size: 18px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
}



/* Ensure picker labels themselves are large enough */
.ql-toolbar .ql-picker-label {
  font-size: 18px !important;
  font-weight: 700 !important;
}

.ql-toolbar button:hover,
.ql-toolbar .ql-picker:hover {
  background: #e0e0e0 !important;
  border-radius: 4px !important;
  transition: background 0.2s ease !important;
  color: #222 !important;
}

.ql-toolbar button.ql-active,
.ql-toolbar .ql-picker.ql-active {
  background: #007bff !important;
  color: white !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 4px rgba(0,123,255,0.25) !important;
  font-weight: 600 !important;
}

.ql-toolbar .ql-color .ql-picker-label,
.ql-toolbar .ql-background .ql-picker-label {
  color: #222 !important;
  font-weight: 900 !important;
  font-size: 20px !important;
  line-height: 1.2 !important;
  min-height: 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.ql-toolbar .ql-color,
.ql-toolbar .ql-background {
  border: 1px solid #ddd !important;
  background: white !important;
  min-width: 42px !important;
  height: 36px !important;
}

.ql-toolbar .ql-color:hover,
.ql-toolbar .ql-background:hover {
  background: #f0f0f0 !important;
  border-color: #bbb !important;
}

.ql-toolbar .ql-picker-label svg {
  width: 18px !important;
  height: 18px !important;
  fill: currentColor !important;
}

.ql-toolbar .ql-picker-label {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: #111 !important;
  min-height: 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 6px 8px !important;
  border: none !important;
  background: none !important;
}

.ql-toolbar .ql-header {
  min-width: 80px !important;
  width: auto !important;
}

.ql-toolbar .ql-picker-options {
  background: white !important;
  border: 2px solid #007bff !important;
  border-radius: 6px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
  padding: 8px 0 !important;
  min-width: 120px !important;
  z-index: 1000 !important;
  /* Make dropdowns open upward since toolbar is at bottom */
  bottom: 100% !important;
  top: auto !important;
  margin-bottom: 5px !important;
}

/* Ensure expanded picker shows dropdown above */
.ql-toolbar .ql-picker.ql-expanded .ql-picker-options {
  bottom: 100% !important;
  top: auto !important;
}

.ql-toolbar .ql-picker-item {
  padding: 8px 16px !important;
  color: #333 !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  border-bottom: 1px solid #f0f0f0 !important;
}

.ql-toolbar .ql-picker-item:hover {
  background: #f8f9fa !important;
  color: #007bff !important;
}

.ql-toolbar .ql-picker-item.ql-selected {
  background: #007bff !important;
  color: white !important;
}

/* Container styling to prevent inheritance */
.ql-container {
  border: 1px solid #ccc !important;
  border-top: none !important;
  box-sizing: border-box !important;
  font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif !important;
  font-size: 14px !important;
  height: auto !important;
  margin: 0 !important;
  position: relative !important;
  background: white !important;
}

/* Reset any form styling that might interfere */
form .ql-toolbar,
form .ql-container,
form .ql-editor,
form #quillEditorContainer,
form #quillEditor {
  text-align: left !important;
  background: white !important;
  color: #333 !important;
  font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif !important;
  max-width: none !important;
  margin: 0 !important;
}

/* Ensure HTML editor textarea remains readable */
#htmlTextarea {
  text-align: left !important;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
  background: white !important;
  color: #333 !important;
  max-width: none !important;
}


/* =========================================
   MEDIA GALLERY UI (used in book_chapter.html)
   ========================================= */

/* Gallery container optional hook */
.media-gallery {
  /* Hook class for media gallery containers */
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 15px;
}

/* Card wrapper for both photos and videos */
.media-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  width: 200px;
  border: 1px solid #ddd;
  padding: 8px;
  gap: 6px;
}

.media-card.photo {
  border: 2px solid #ddd;
}

.media-card.video {
  border: 2px solid #28a745;
}

/* Thumbnail image */
.media-thumb {
  width: 120px;
  height: 80px;
  object-fit: cover;
  display: block;
}

/* Buttons area under thumbnail */
.media-card-buttons {
  padding: 6px;
  text-align: center;
  background: #f8f9fa;
}

.media-card-label {
  font-size: 10px;
  color: #666;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-card-size {
  font-size: 9px;
  color: #999;
  margin-bottom: 4px;
}

/* Buttons */
.media-card .media-btn {
  border: none !important;
  padding: 2px 6px !important;
  border-radius: 3px !important;
  font-size: 10px !important;
  cursor: pointer;
  font-weight: normal !important;
  margin: 0 !important;
  box-shadow: none !important;
  transform: none !important;
  transition: opacity 0.2s ease !important;
  display: inline-block;
  text-decoration: none !important;
}

.media-card .media-btn:hover {
  opacity: 0.8;
  transform: none !important;
  box-shadow: none !important;
}

.media-card .media-btn + .media-btn {
  margin-left: 4px !important;
}

.media-card .media-btn-insert-blue {
  background-color: #007bff !important;
  color: #000000 !important;
}

.media-card .media-btn-insert-green {
  background-color: #28a745 !important;
  color: #000000 !important;
}

.media-card .media-btn-delete {
  background-color: #dc3545 !important;
  color: #000000 !important;
}

.media-btn-gray {
  background-color: #6c757d;
  color: #000000;
}

/* Video preview tile */
.media-video-preview {
  width: 120px;
  height: 80px;
  background: linear-gradient(135deg, #28a745, #34ce57);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
}

/* Empty-state message */
.no-media-message {
  color: #888;
  font-style: italic;
  text-align: center;
  margin: 20px 0;
}

/* JS loaded indicator badge */
#js-loaded-indicator {
  position: fixed;
  top: 10px;
  right: 10px;
  background: #28a745;
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 10000;
  opacity: 0.8;
}

/* Preview box (used by previewContent) */
.preview-box {
  margin-top: 1em;
  padding: 1em;
  border: 1px solid #ddd;
  background-color: #f9f9f9;
  border-radius: 5px;
}

/* Chapter header image sections */
.chapter-image-selected {
  display: none;
  margin: 10px 0;
  padding: 8px;
  background-color: #e8f4fd;
  border-radius: 4px;
  color: #007bff;
  font-size: 14px;
  border: 1px solid #b3d9ff;
}

.chapter-image-selected .file-summary {
  text-align: center;
  margin-bottom: 10px;
}

.chapter-image-preview {
  margin-top: 10px;
  text-align: center;
}

.chapter-image-preview img {
  max-width: 500px;
  max-height: 400px;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: block;
  margin: 0 auto;
}

/* Ensure explicit class also applies when used directly */
.chapter-image-preview-img {
  max-width: 500px;
  max-height: 400px;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: block;
  margin: 0 auto;
}

.chapter-image-current {
  margin-top: 8px;
  padding: 8px;
  background-color: #f0f8ff;
  border: 1px solid #b3d9ff;
  border-radius: 4px;
}

.chapter-image-current .current-filename {
  color: #0066cc;
  display: block;
  margin-bottom: 8px;
  text-align: center;
}

.chapter-image-current .current-preview {
  text-align: center;
  margin-bottom: 15px;
}

.chapter-image-placeholder {
  margin-top: 8px;
  padding: 8px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  color: #6c757d;
  font-size: 14px;
}

/* Medium padding variant for media buttons */
.media-btn-md {
  padding: 8px 16px;
}

/* Flash messages - Enhanced version */
#flash-messages {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 999999 !important;
  margin: 0 auto !important;
  padding: 0;
  max-width: 600px;
  width: 90%;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 15px;
  pointer-events: auto !important;
}

.flash-message {
  border-radius: 12px;
  padding: 20px 25px;
  position: relative;
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
  font-size: 18px;
  font-weight: 700;
  backdrop-filter: blur(10px);
  margin: 0;
  animation: slideInBounce 0.8s ease-out;
  width: 100%;
  box-sizing: border-box;
}

.flash-error {
  background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
  color: #721c24;
  border: 3px solid #f5c6cb;
  box-shadow: 0 8px 25px rgba(220, 53, 69, 0.3), 0 0 20px rgba(220, 53, 69, 0.2);
  animation: flashErrorPulse 2s ease-out, slideInBounce 0.8s ease-out, shake 0.8s ease-in-out, fadeOut 1s ease-out 7s forwards !important;
}

.flash-success {
  background: linear-gradient(135deg, #d1e7dd 0%, #badbcc 100%);
  color: #0f5132;
  border: 3px solid #badbcc;
  box-shadow: 0 8px 25px rgba(25, 135, 84, 0.3), 0 0 20px rgba(25, 135, 84, 0.2);
  animation: flashSuccessPulse 2s ease-out, slideInBounce 0.8s ease-out, fadeOut 1s ease-out 7s forwards;
}

.flash-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.flash-icon {
  font-size: 28px;
  animation: pulse 1s infinite;
}

.flash-close {
  position: absolute;
  right: 15px;
  top: 15px;
  background: rgba(255,255,255,0.8);
  border: none;
  font-size: 24px;
  color: inherit;
  cursor: pointer;
  padding: 5px 8px;
  line-height: 1;
  font-weight: bold;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.flash-message:hover {
  transform: translateY(-3px) scale(1.02);
  transition: all 0.3s ease;
}

.flash-message button:hover {
  background: rgba(255,255,255,1) !important;
  transform: scale(1.1);
}

.flash-close:hover {
  background: rgba(255,255,255,1);
  transform: scale(1.1);
}

.flash-more-note {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: #6c757d;
  padding: 15px 20px;
  border: 2px solid #dee2e6;
  border-radius: 12px;
  font-size: 16px;
  text-align: center;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

/* Alert styles for redemption page and other pages */
.alert {
  position: relative;
  padding: 15px;
  margin: 20px auto;
  border-radius: 8px;
  max-width: 600px;
  width: 90%;
  box-sizing: border-box;
  font-size: 16px;
  text-align: center;
}

.alert-success {
  background: linear-gradient(135deg, #d1e7dd 0%, #badbcc 100%);
  color: #0f5132;
  border: 2px solid #badbcc;
}

.alert-error {
  background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
  color: #721c24;
  border: 2px solid #f5c6cb;
}

@keyframes slideInBounce {
  0% {
    opacity: 0;
    transform: translateY(-50px) scale(0.8);
  }
  60% {
    opacity: 1;
    transform: translateY(5px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes flashErrorPulse {
  0%, 100% {
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.3), 0 0 20px rgba(220, 53, 69, 0.2);
  }
  50% {
    box-shadow: 0 12px 35px rgba(220, 53, 69, 0.5), 0 0 30px rgba(220, 53, 69, 0.4);
    transform: translateY(-2px);
  }
}

@keyframes flashSuccessPulse {
  0%, 100% {
    box-shadow: 0 8px 25px rgba(25, 135, 84, 0.3), 0 0 20px rgba(25, 135, 84, 0.2);
  }
  50% {
    box-shadow: 0 12px 35px rgba(25, 135, 84, 0.5), 0 0 30px rgba(25, 135, 84, 0.4);
    transform: translateY(-2px);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes shake {
  0%, 20%, 40%, 60%, 80% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-8px);
  }
}

@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
    pointer-events: none;
  }
}

@media (max-width: 768px) {
  #flash-messages {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 95%;
  }
  
  .flash-message {
    font-size: 16px !important;
    padding: 15px 20px !important;
  }
  
  .flash-message span:first-child {
    font-size: 24px !important;
  }
}

/* Media library container and header */
.media-library-container {
  margin-bottom: 2em;
  padding: 15px;
  border: 2px dashed #ddd;
  border-radius: 8px;
  background-color: #fafafa;
  justify-content: center;
}

/* ============================================
   STICKY MEDIA LIBRARY SIDEBAR (NEW)
   ============================================ */

.media-library-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 280px;
  height: 100vh;
  background: linear-gradient(to bottom, #f8f9fa, #ffffff);
  border-right: 2px solid #dee2e6;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Always hidden by default, show when active */
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0.3s ease;
}

/* Show when active class is added by JavaScript */
.media-library-sidebar.active {
  transform: translateX(0);
  visibility: visible;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
}

.media-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  border-bottom: 2px solid #003d82;
  flex-shrink: 0;
}

.media-sidebar-title {
  color: white;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  text-transform: uppercase;
  text-align: center;
}

.media-sidebar-header .media-refresh-btn {
  background: rgba(255, 255, 255, 0.2) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  padding: 6px 10px !important;
  font-size: 16px !important;
  border-radius: 6px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.media-sidebar-header .media-refresh-btn:hover {
  background: rgba(255, 255, 255, 0.3) !important;
  transform: scale(1.05);
}

.media-sidebar-upload {
  padding: 20px 15px;
  background: white;
  border-bottom: 1px solid #dee2e6;
  flex-shrink: 0;
}

/* Media sidebar buttons match standard button styling */
.media-sidebar-upload button {
  width: 100%;
  margin-bottom: 12px;
  padding: 14px 12px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: linear-gradient(135deg, #fafafb 0%, #d3e9fe 100%);
  border-bottom: 2px solid #111;
  color: #333;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.media-sidebar-upload button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.media-sidebar-upload button:last-of-type {
  margin-bottom: 0;
}

.media-upload-hint {
  font-size: 11px;
  color: #6c757d;
  text-align: center;
  margin-top: 15px;
  padding-top: 12px;
  line-height: 1.5;
  border-top: 1px solid #e9ecef;
}

.media-library-sidebar .media-gallery {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 15px;
  background: white;
}

.media-library-sidebar .upload-loading {
  padding: 10px 15px;
  background: #fff3cd;
  border-top: 1px solid #ffc107;
  text-align: center;
  font-size: 12px;
  color: #856404;
  flex-shrink: 0;
}

/* ============================================
   ACTIONS SIDEBAR (RIGHT)
   ============================================ */

.actions-sidebar {
  position: fixed;
  right: 0;
  top: 0;
  width: 300px;
  height: 100vh;
  background: linear-gradient(to bottom, #f8f9fa, #ffffff);
  border-left: 2px solid #dee2e6;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Always hidden by default, show when active */
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0.3s ease;
}

/* Show when active class is added by JavaScript */
.actions-sidebar.active {
  transform: translateX(0);
  visibility: visible;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
}

.actions-sidebar-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px;
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  border-bottom: 2px solid #1e7e34;
  flex-shrink: 0;
}

.actions-sidebar-title {
  color: white;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
}

.actions-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: white;
}

/* Fixed buttons inside actions sidebar */
.actions-sidebar .fixed-buttons {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.actions-sidebar .fixed-buttons a,
.actions-sidebar .fixed-buttons button {
  margin: 0;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
  font-size: 0.9rem;
  padding: 12px 16px;
  white-space: normal;
}

/* Main content area - responsive with hover sidebars */
.main-content-area {
  min-height: 100vh;
  padding: 20px;
  box-sizing: border-box;
  width: 100%;
  /* Use full width on mobile, constrained width on larger screens */
  max-width: none;
  margin: 0;
  /* Smooth transitions for responsive changes */
  transition: padding 0.3s ease, max-width 0.3s ease;
}

/* Media cards in sidebar - optimized for narrow width */
.media-library-sidebar .media-card {
  width: 100%;
  margin-bottom: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.media-library-sidebar .media-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.media-library-sidebar .media-thumb {
  width: 100%;
  height: auto;
  max-height: 150px;
  object-fit: cover;
  display: block;
}

.media-library-sidebar .media-video-preview {
  width: 100%;
  height: 120px;
  background: linear-gradient(135deg, #9f7aea, #805ad5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-library-sidebar .media-video-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-library-sidebar .media-card-buttons {
  padding: 12px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.media-library-sidebar .media-card-label {
  font-size: 11px;
  color: #495057;
  margin-bottom: 4px;
  font-weight: 500;
  word-break: break-word;
}

.media-library-sidebar .media-card-size {
  font-size: 10px;
  color: #6c757d;
  margin-bottom: 8px;
}

.media-library-sidebar .media-btn {
  width: 100%;
  padding: 10px 8px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  text-align: center;
  display: block;
  margin: 0 !important;
  transition: all 0.2s ease !important;
}

.media-library-sidebar .media-btn:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

/* Scrollbar styling for sidebar */
.media-library-sidebar .media-gallery::-webkit-scrollbar {
  width: 8px;
}

.media-library-sidebar .media-gallery::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.media-library-sidebar .media-gallery::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

.media-library-sidebar .media-gallery::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

.media-library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.media-library-label {
  font-weight: bold;
  color: #333;
  margin: 0;
}

.media-library-description {
  color: #666;
  font-size: 14px;
  margin-bottom: 15px;
}

.media-library-description small {
  color: #888;
}

.media-upload-area {
  margin-bottom: 15px;
}

.media-upload-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

/* .media-upload-group - Wrapper for input and button pairs (no styles needed currently) */

.media-input {
  margin-bottom: 5px;
}

.media-upload-info {
  color: #666;
  font-size: 12px;
}

.upload-loading {
  display: none;
  color: #007bff;
  font-style: italic;
}
/* Login page specific styles */
.login-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

/* Login page fix - proper flexbox layout */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 20px;
}

/* ==============================
   QUILL EDITOR ENHANCEMENTS
   ============================== */

/* Video elements in Quill editor */
#quillEditor video {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin: 8px 0;
}

/* Quill toolbar enhancements */
.ql-toolbar .ql-emphasis {
  background-color: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
}

.ql-toolbar .ql-emphasis:hover {
  background-color: rgba(255, 215, 0, 0.2);
  border-radius: 3px;
}

/* ==============================
   MODAL OVERLAY STYLES
   ============================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  min-width: 400px;
  width: auto;
  text-align: center;
  animation: slideIn 0.3s ease-out;
}

.warning-modal {
  border: 3px solid #ff6b35;
}

.warning-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.warning-title {
  margin: 0 0 15px 0;
  color: #d63031;
  font-size: 24px;
  font-weight: bold;
}

.warning-message {
  margin: 0 0 20px 0;
  font-size: 16px;
  line-height: 1.5;
  color: #333;
}

.warning-button {
  background-color: #d63031;
  color: rgb(0, 0, 0);
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s ease;
}

.warning-button:hover {
  background-color: #b92d32;
}

/* Loading Modal Styles */
.loading-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  background-color: rgba(0, 0, 0, 0.7) !important;
  z-index: 999999 !important;
  display: none !important;
  justify-content: center !important;
  align-items: center !important;
  animation: fadeIn 0.3s ease-out;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  /* Ensure no parent transform affects this */
  will-change: auto !important;
}

.loading-modal.active {
  display: flex !important;
}

.loading-content {
  background: white !important;
  padding: 30px !important;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  text-align: center !important;
  border: 2px solid #007bff;
  animation: slideIn 0.3s ease-out;
  max-width: 500px;
  min-width: 300px;
  width: auto;
  margin: 0 auto !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}

.loading-icon {
  font-size: 48px;
  margin: 0 auto 15px auto;
  text-align: center;
}

.loading-title {
  font-size: 18px;
  font-weight: bold;
  margin: 0 auto 10px auto;
  text-align: center;
  color: #2d3748;
}

.loading-message {
  color: #666;
  font-size: 14px;
  margin: 0 auto;
  text-align: center;
}

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

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

/* =========================================
   QUILL VIDEO ALIGNMENT SUPPORT
   ========================================= */

/* Video wrapper alignment classes for Quill editor */
.ql-editor section.ql-align-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.ql-editor section.ql-align-right {
  display: block;
  margin-left: auto;
  margin-right: 0;
  text-align: right;
}

.ql-editor section.ql-align-justify {
  display: block;
  width: 100%;
  text-align: justify;
}

/* Default left alignment for video wrappers */
.ql-editor section[data-video-wrapper="true"] {
  display: block;
  max-width: 100%;
  margin: 10px 0;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.2s;
}

/* Video elements inside the wrapper */
.ql-editor section[data-video-wrapper="true"] video {
  max-width: 100%;
  height: auto;
  display: block;
  width: 100%;
}

/* Selection state for video wrapper */
.ql-editor section[data-video-wrapper="true"].ql-selected,
.ql-editor section[data-video-wrapper="true"]:focus {
  border-color: #007bff;
  outline: none;
}

/* Hover effect for video wrapper in editor */
.ql-editor section[data-video-wrapper="true"]:hover {
  border-color: #007bff;
  outline: none;
}

/* Ensure video alignment works in preview and published content */
video.ql-align-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

video.ql-align-right {
  display: block;
  margin-left: auto;
  margin-right: 0;
}

video.ql-align-justify {
  display: block;
  width: 100%;
}

/* Support for inline text-align styles as fallback */
video[style*="text-align: center"] {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

video[style*="text-align: right"] {
  display: block;
  margin-left: auto;
  margin-right: 0;
}

video[style*="text-align: justify"] {
  display: block;
  width: 100%;
}

/* Hover effect for video wrapper in editor */
.ql-editor section[data-video-wrapper="true"]:hover {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Tooltips */
.tooltip {
  position: relative; /* Needed for positioning the tooltiptext */
  display: inline-block; /* Allows the tooltip to wrap around its content */
  border-bottom: 1px dotted black; /* Optional: adds a visual cue */
}

.tooltip .tooltiptext {
  visibility: hidden; /* Hidden by default */
  width: 120px; /* Adjust width as needed */
  background-color: #555; /* Dark background */
  color: #fff; /* White text */
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;

  /* Positioning the tooltip */
  position: absolute;
  z-index: 1; /* Ensures it appears above other content */
  bottom: 125%; /* Positions above the hover element */
  left: 50%;
  margin-left: -60px; /* Centers the tooltip */

  opacity: 0; /* Starts invisible for smooth transition */
  transition: opacity 0.3s; /* Smooth fade-in effect */
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%; /* Positions the arrow below the tooltip box */
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #555 transparent transparent transparent; /* Creates a downward-pointing arrow */
}

.tooltip:hover .tooltiptext {
  visibility: visible; /* Shows the tooltip on hover */
  opacity: 1; /* Fades in the tooltip */
}

/* ============================================
   RESPONSIVE SIDEBAR CONTROLS
   ============================================ */

/* Mobile menu toggle buttons */
.sidebar-toggle {
  display: none;
  position: fixed;
  z-index: 1001;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  font-size: 18px;
  line-height: 1;
  color: #4a5568;
}

.sidebar-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle-left {
  top: 20px;
  left: 20px;
}

.sidebar-toggle-right {
  top: 20px;
  right: 20px;
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 850;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Hover trigger zone with visible arrows */
.sidebar-hover-trigger {
  display: none;
  position: fixed;
  width: 30px;
  height: 100vh;
  z-index: 899;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  /* Temporary debug background - remove later */
  /* background: rgba(255, 0, 0, 0.1); */
}

.sidebar-hover-trigger-left-zone {
  left: 0;
  top: 0;
}

.sidebar-hover-trigger-left-zone:hover {
  background: linear-gradient(to right, rgba(66, 153, 225, 0.15), transparent);
}

.sidebar-hover-trigger-right-zone {
  right: 0;
  top: 0;
}

.sidebar-hover-trigger-right-zone:hover {
  background: linear-gradient(to left, rgba(40, 167, 69, 0.15), transparent);
}

/* Left trigger visual indicators */
.sidebar-hover-trigger-left-zone::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 120px;
  background: linear-gradient(to bottom, transparent, rgba(66, 153, 225, 0.6), transparent);
  border-radius: 0 6px 6px 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-hover-trigger-left-zone:hover::after {
  opacity: 1;
}

.sidebar-hover-trigger-left-zone::before {
  content: '📸';
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: rgba(66, 153, 225, 0.8);
  background: rgba(255, 255, 255, 0.9);
  padding: 8px;
  border-radius: 0 8px 8px 0;
  border: 2px solid rgba(66, 153, 225, 0.3);
  animation: pulseHint 4s ease-in-out infinite;
  animation-delay: 3s;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-hover-trigger-left-zone:hover::before {
  animation: none;
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

/* Right trigger visual indicators */
.sidebar-hover-trigger-right-zone::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 120px;
  background: linear-gradient(to bottom, transparent, rgba(40, 167, 69, 0.6), transparent);
  border-radius: 6px 0 0 6px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-hover-trigger-right-zone:hover::after {
  opacity: 1;
}

.sidebar-hover-trigger-right-zone::before {
  content: '⚡';
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: rgba(40, 167, 69, 0.8);
  background: rgba(255, 255, 255, 0.9);
  padding: 8px;
  border-radius: 8px 0 0 8px;
  border: 2px solid rgba(40, 167, 69, 0.3);
  animation: pulseHint 4s ease-in-out infinite;
  animation-delay: 3.5s;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-hover-trigger-right-zone:hover::before {
  animation: none;
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

/* Pulse animation to hint at the hover areas */
@keyframes pulseHint {
  0%, 100% { 
    opacity: 0.3; 
    transform: translateY(-50%) scale(1);
  }
  50% { 
    opacity: 0.9; 
    transform: translateY(-50%) scale(1.05);
  }
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Large Desktop - Full sidebar experience */
@media (min-width: 1200px) {
  .media-library-sidebar {
    width: 300px;
  }
  
  .actions-sidebar {
    width: 320px;
  }
  
  .main-content-area {
    margin-left: 300px;
    margin-right: 320px;
  }
}

/* ============================================
   RESPONSIVE DESIGN - HOVER SIDEBARS
   ============================================ */

/* All screen sizes - consistent hover behavior */
@media (min-width: 768px) {
  /* Show hover trigger zones */
  .sidebar-hover-trigger {
    display: block !important;
  }
  
  /* Keep sidebar toggles visible for accessibility but make them less prominent */
  .sidebar-toggle-left,
  .sidebar-toggle-right {
    display: block;
    opacity: 0.4;
    transition: opacity 0.2s ease;
  }
  
  .sidebar-toggle-left:hover,
  .sidebar-toggle-right:hover {
    opacity: 1;
  }
  
  /* Tablet: Constrain max-width and center content */
  .main-content-area {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 30px;
  }
}

/* Desktop - Make hover triggers always available */
@media (min-width: 1024px) {
  .sidebar-hover-trigger {
    display: block !important;
  }
  
  /* Hide toggle buttons on desktop since hover works better */
  .sidebar-toggle-left,
  .sidebar-toggle-right {
    display: none;
  }
  
  /* Desktop: Larger max-width for better use of space */
  .main-content-area {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 40px;
  }
}

/* Large Desktop: Even more space for content */
@media (min-width: 1200px) {
  .main-content-area {
    max-width: 1200px;
    padding: 20px 50px;
  }
}

/* Very Large Desktop: Maximum comfortable reading width */
@media (min-width: 1400px) {
  .main-content-area {
    max-width: 1300px;
    padding: 20px 60px;
  }
}

/* ============================================
   INTERMEDIATE RESPONSIVE BREAKPOINTS
   ============================================ */

/* Small tablet / large mobile landscape */
@media (min-width: 481px) and (max-width: 767px) {
  .main-content-area {
    padding: 20px;
    max-width: none;
    margin: 0;
    width: 100%;
  }
}

/* Medium tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .main-content-area {
    max-width: 750px;
    margin: 0 auto;
    padding: 20px 25px;
  }
}

/* Large tablet / small desktop */
@media (min-width: 1024px) and (max-width: 1199px) {
  .main-content-area {
    max-width: 950px;
    margin: 0 auto;
    padding: 20px 35px;
  }
}

/* Mobile - Keep existing mobile behavior for touch devices */
@media (max-width: 767px) {
  .media-library-sidebar {
    width: 90%;
    max-width: 320px;
    /* Keep transform behavior but trigger with touch/click */
  }
  
  .actions-sidebar {
    width: 90%;
    max-width: 320px;
    /* Keep transform behavior but trigger with touch/click */
  }
  
  .media-library-sidebar.active {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3);
  }
  
  .actions-sidebar.active {
    transform: translateX(0);
    visibility: visible;
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.3);
  }
  
  .main-content-area {
    padding: 15px;
    padding-top: 70px; /* Space for toggle buttons */
    max-width: none; /* Use full width on mobile */
    margin: 0; /* Remove auto margins */
    width: 100%; /* Ensure full width usage */
  }
  
  .sidebar-toggle-left,
  .sidebar-toggle-right {
    display: block;
  }
  
  .sidebar-toggle-right {
    top: 80px; /* Below left toggle */
  }
  
  /* Mobile: Keep fixed buttons inside actions sidebar */
  .actions-sidebar .fixed-buttons {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }
  
  .actions-sidebar .fixed-buttons a,
  .actions-sidebar .fixed-buttons button {
    font-size: 0.85rem;
    padding: 12px 16px;
    width: 100%;
    margin: 0;
    white-space: normal;
  }
}

/* Very Small Mobile - Further optimize */
@media (max-width: 480px) {
  .media-library-sidebar {
    width: 95%;
  }
  
  .actions-sidebar {
    width: 95%;
  }
  
  .main-content-area {
    padding: 10px;
    padding-top: 75px;
    width: 100%;
    margin: 0;
  }
  
  .sidebar-toggle {
    padding: 8px;
    font-size: 16px;
  }
  
  .fixed-buttons {
    bottom: 10px;
    gap: 6px;
    padding: 8px;
    max-width: calc(100% - 20px);
  }
  
  .fixed-buttons a {
    font-size: 0.65rem;
    padding: 0.4rem 0.6rem;
  }
}
.justify-content-center {
  justify-content: center;
}

.sidebar-divider {
  text-align: center;
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
}

/* =========================================
   CHAPTER PREVIEW MODE STYLES
   ========================================= */

/* Preview container styling */
#previewContainer {
  transition: opacity 0.3s ease-in-out;
}

#previewContent {
  /* Reset builder.css interference for preview */
  background: white;
  max-width: 100%;
  font-family: inherit;
}

/* Ensure preview content uses theme styles, not builder styles */
#previewContent * {
  /* Let theme CSS take precedence */
  box-sizing: border-box;
}

/* Preview button active state */
#previewModeBtn.active {
  background-color: #28a745;
  color: white;
}

/* =========================================
   PREVIEW MODAL STYLES
   ========================================= */

.preview-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.preview-modal-backdrop {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.7);
  cursor: pointer;
  z-index: 10000;
}

.preview-modal-content {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 85%;
  max-width: 1000px;
  height: 70vh;
  max-height: 700px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  z-index: 10001;
  overflow: hidden;
}

.preview-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #ddd;
  background: #f8f9fa;
  border-radius: 8px 8px 0 0;
  flex-shrink: 0;
}

.preview-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #333;
}

.preview-modal-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.preview-modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #000;
}

.preview-modal-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .preview-modal-content {
    width: 90%;
    height: 75vh;
    max-height: 600px;
  }
  
  .preview-modal-header {
    padding: 8px 12px;
  }
  
  .preview-modal-header h3 {
    font-size: 1rem;
  }
  
  .preview-modal-close {
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
  }
}

@media (max-height: 700px) {
  .preview-modal-content {
    height: 80vh;
    max-height: 80vh;
  }
  
  .preview-modal-header {
    padding: 6px 12px;
  }
}

@media (max-height: 500px) {
  .preview-modal-content {
    height: 90vh;
    max-height: 90vh;
  }
}

/* =========================================
   QUILL EDITOR Z-INDEX FIXES
   ========================================= */

/* Ensure Quill toolbar and dropdowns appear above all other elements */
/* Using high specificity to override Quill Snow theme defaults */

.ql-toolbar.ql-snow,
.ql-snow.ql-toolbar,
.ql-toolbar {
  position: relative;
  z-index: 100 !important;
}

/* Quill picker buttons need proper z-index */
.ql-toolbar.ql-snow .ql-picker,
.ql-snow.ql-toolbar .ql-picker,
.ql-toolbar .ql-picker {
  position: relative;
  z-index: 100 !important;
}

/* Dropdown menus must appear above everything else - override Quill's z-index: 1 */
.ql-snow .ql-picker.ql-expanded .ql-picker-options,
.ql-snow.ql-toolbar .ql-picker.ql-expanded .ql-picker-options,
.ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-options,
.ql-toolbar .ql-picker.ql-expanded .ql-picker-options,
.ql-snow .ql-picker-options,
.ql-toolbar .ql-picker-options {
  position: absolute !important;
  z-index: 9999 !important;
  background: white !important;
  border: 1px solid #ccc !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

/* Ensure expanded pickers maintain high z-index */
.ql-snow .ql-picker.ql-expanded,
.ql-snow.ql-toolbar .ql-picker.ql-expanded,
.ql-toolbar.ql-snow .ql-picker.ql-expanded,
.ql-toolbar .ql-picker.ql-expanded {
  z-index: 9999 !important;
}

/* Expanded picker labels also need high z-index */
.ql-snow .ql-picker.ql-expanded .ql-picker-label,
.ql-snow.ql-toolbar .ql-picker.ql-expanded .ql-picker-label,
.ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-label {
  z-index: 9999 !important;
}

/* Specific fixes for all dropdown types */
.ql-snow .ql-header .ql-picker-options,
.ql-snow .ql-align .ql-picker-options,
.ql-snow .ql-color .ql-picker-options,
.ql-snow .ql-background .ql-picker-options,
.ql-snow .ql-verticalAlign .ql-picker-options,
.ql-toolbar .ql-header .ql-picker-options,
.ql-toolbar .ql-align .ql-picker-options,
.ql-toolbar .ql-color .ql-picker-options,
.ql-toolbar .ql-background .ql-picker-options,
.ql-toolbar .ql-verticalAlign .ql-picker-options {
  z-index: 9999 !important;
}

/* Ensure the editor info banner stays below dropdowns */
#editorInfo {
  position: relative;
  z-index: 1 !important;
}

/* Quill editor container should not interfere */
#quillEditorContainer,
#quillEditor {
  position: relative;
  z-index: 10 !important;
}

/* Editor area general z-index */
.editor-area {
  position: relative;
  z-index: 10 !important;
}
