/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

:root {
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
  --transition-speed: 0.3s;
  --transition-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body,
input,
select,
textarea,
button {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

h1, h2, h3, h4, h5, h6, .brand-font {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  color: var(--text-color, #1a1a2e);
  background: var(--bg-color, #f4f6f9);
}

/* Dynamic Animated Background */
.animated-bg {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  z-index: -1;
  background: linear-gradient(
    120deg,
    var(--bg-color, #f4f6f9) 0%,
    var(--bg-muted, #e9ecef) 45%,
    var(--panel-bg-color, #ffffff) 100%
  );
  animation: bgOrbit 30s linear infinite;
  opacity: 0.8;
}

@keyframes bgOrbit {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

.wrapper {
  max-width: 900px;
  margin: 3rem auto;
  padding: 0 2rem;
  position: relative;
  z-index: 1;
}

.section {
  padding: 2.5rem;
  border-radius: 20px;
  margin-bottom: 2.5rem;
  background: var(--panel-bg-color, rgba(255, 255, 255, 0.85));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.4));
  box-shadow: var(--glass-shadow);
  opacity: 0;
  animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.section:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.1);
}

.section header h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  position: relative;
}

.section header h2::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--header-color, #4a90e2);
  border-radius: 2px;
}

label {
  display: flex !important;
  flex-direction: column;
  margin-bottom: 1.25rem !important;
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.6;
}

label.inline {
  display: inline-flex !important;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0 !important;
}

label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.75rem;
  margin-bottom: 1rem !important;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background var(--transition-speed);
}

label:has(input[type="checkbox"]):hover,
label:has(input[type="radio"]):hover {
  background: rgba(0, 0, 0, 0.03);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  padding: 0.85rem 1.25rem !important;
  border-radius: 10px !important;
  border: 1px solid var(--input-border-color, rgba(0,0,0,0.15)) !important;
  background-color: var(--input-bg-color, rgba(255,255,255,0.9)) !important;
  color: var(--input-text-color, #333) !important;
  margin-top: 0.5rem;
  transition: all var(--transition-speed) ease;
  box-sizing: border-box;
  font-size: 0.95rem;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--header-color, #4a90e2) !important;
  box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.15) !important;
  transform: translateY(-1px);
}

/* Custom Checkboxes and Radios */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--header-color, #4a90e2);
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
  transition: transform 0.2s;
}

input[type="checkbox"]:active,
input[type="radio"]:active {
  transform: scale(0.9);
}

input.inline,
textarea.inline,
select.inline {
  width: auto;
  margin-top: 0;
}

input.inline[type='number'] {
  width: 6em;
}

.layout_margin_user_input label {
  text-align: right;
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.input-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: rgba(0,0,0,0.02);
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.05);
}

.input-group>label {
  margin-bottom: 0 !important;
}

button {
  padding: 0.85rem 1.75rem !important;
  border-radius: 10px !important;
  font-weight: 600 !important;
  font-family: 'Outfit', sans-serif !important;
  letter-spacing: 0.02em;
  transition: all var(--transition-speed) var(--transition-bounce);
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.1) !important;
  background-color: var(--button-bg-color, #ffffff) !important;
  color: var(--text-color, #333) !important;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
  background-color: var(--button-hover-bg-color, #f8f9fa) !important;
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

/* Primary Button Styling overrides for important actions */
#generate {
  background: linear-gradient(135deg, var(--header-color, #4a90e2), #357abd) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 8px 16px rgba(74, 144, 226, 0.25) !important;
}

#generate:hover:not([disabled]) {
  box-shadow: 0 12px 24px rgba(74, 144, 226, 0.35) !important;
  transform: translateY(-3px);
}

#generate:disabled {
  opacity: 0.6;
  filter: grayscale(100%);
  cursor: not-allowed;
  transform: none;
  box-shadow: none !important;
}

button.small {
  padding: 0.6rem 1.25rem !important;
  font-size: 0.85rem !important;
}

button.larger {
  padding: 1.25rem 2.5rem !important;
  font-size: 1.15rem !important;
}

.row {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

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

.space-evenly {
  display: flex;
  justify-content: space-evenly;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.flex.align-center {
  display: flex;
  align-items: center;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.ml-2 { margin-left: 1rem; }
.ml-4 { margin-left: 2rem; }
.p-1 { padding: 0.5rem; }
.pb-2 { padding-bottom: 1rem; }

#sig_format img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  margin-top: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: transform var(--transition-speed);
}

#sig_format img:hover {
  transform: scale(1.02);
}

#show_layout_info {
  display: none;
}

.layout_spine_label {
  transform: rotate(-90deg);
  position: absolute;
  text-align: center;
  padding: 0px;
  height: 40px;
  margin: 105px -123px;
  width: 250px;
  font-family: 'Inter', monospace;
  letter-spacing: 14px;
  font-weight: 600;
  color: var(--header-color);
  opacity: 0.7;
}

#grid_layout_preview {
  border: 2px dashed var(--header-color, purple);
  width: 250px;
  height: 250px;
  margin-left: 0px;
  pointer-events: none;
  border-radius: 8px;
  background-color: var(--panel-bg-color);
  box-shadow: 0 8px 24px rgba(0,0,0,0.05);
}

#pdf_on_page_layout_preview {
  border: 2px solid var(--header-color, orange);
  width: 150px;
  height: 24px;
  position: absolute;
  margin: 0px;
  padding: 0px;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(4px);
}

.stripes_paper {
  background: repeating-linear-gradient(45deg, rgba(96, 109, 188, 0.1), rgba(96, 109, 188, 0.1) 10px, rgba(70, 82, 152, 0.1) 10px, rgba(70, 82, 152, 0.1) 20px);
}

.stripes_pdf {
  background: repeating-linear-gradient(133deg,
      rgba(255, 235, 59, 0.4),
      rgba(255, 193, 7, 0.4) 10px,
      rgba(255, 152, 0, 0.4) 10px,
      rgba(255, 152, 0, 0.4) 15px);
}

.stripes_sample_box {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-block;
  border-radius: 4px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#pdf_offset_dimensions {
  padding-left: 0.5rem;
  display: inline-block;
  vertical-align: top;
}

.flash {
  padding: 1rem 1.5rem;
  border-radius: 12px;
  margin: 1rem 0;
  border-left: 4px solid transparent;
  animation: slideUpFade 0.4s ease forwards;
}

.flash.variant {
  background-color: var(--bg-muted, #f1f3f5);
  border-left-color: var(--header-color, #adb5bd);
  color: var(--text-color);
}

.flash.attention {
  background-color: rgba(255, 193, 7, 0.1);
  border-left-color: #ffc107;
  color: #856404;
}

details {
  background: rgba(0,0,0,0.02);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.05);
  margin-bottom: 1rem;
}

summary {
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background 0.2s;
  outline: none;
}

summary:hover {
  background: rgba(0,0,0,0.03);
}

/* Dialog Backdrop */
dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease forwards;
}

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

/* Theme Switcher Buttons */
.theme-btn {
  flex: 1;
  margin: 0 0.25rem;
  padding: 0.75rem 0.5rem !important;
  text-align: center;
}
