/* CFP - Online Designer Tool CSS */

/* Reset-ish */
* { box-sizing: border-box; }
html, body { height: 100%; }
img { max-width: 100%; display: block; }

/* Shell */
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: #0f172a;
  background: #f8fafc;
}
.odt-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* Topbar */
.odt-topbar {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: .75rem 1rem;
  color: #e2e8f0;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(90deg, lightblue, deepskyblue, lightblue) !important; /* More vibrant light blue gradient */
  background-size: 200% 100%;
  animation: gradient-animation 2s ease infinite; /* Faster animation */
}
.odt-title { font-weight: 600; margin-right: auto; display: flex; align-items: center; gap: .5rem; }
.odt-title-badge {
  font-size: .7rem;
  color: #e2e8f0; /* Adjusted for contrast against blue gradient */
  background: rgba(163, 230, 53, .12);
  border: 1px solid rgba(163, 230, 53, .25);
  padding: .15rem .35rem;
  border-radius: .35rem;
}

@keyframes gradient-animation {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Help Button */
.help-btn {
  background: rgba(255, 255, 255, 0.2) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  padding: 0.5rem 0.75rem !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  font-weight: 500 !important;
  transition: all 0.3s ease !important;
  margin-left: auto !important;
}

.help-btn:hover {
  background: rgba(255, 255, 255, 0.3) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.help-btn svg {
  width: 18px;
  height: 18px;
}

/* Inline Help Content Styles */
.help-content-inline {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #334155;
  max-height: 600px;
  overflow-y: auto;
  padding: 0.5rem;
}

.help-content-inline h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0f172a;
  margin: 1.5rem 0 0.75rem 0;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

.help-content-inline h4:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.help-content-inline p {
  margin-bottom: 0.75rem;
  color: #475569;
}

.help-content-inline ul, .help-content-inline ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.help-content-inline li {
  margin-bottom: 0.5rem;
  color: #475569;
}

.help-content-inline strong {
  color: #0f172a;
  font-weight: 600;
}

.help-section-inline {
  margin-bottom: 1.5rem;
}

.help-welcome-inline {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  padding: 1rem;
  border-radius: 0.5rem;
  border-left: 4px solid #3b82f6;
  margin-bottom: 1.5rem;
}

.help-welcome-inline h4 {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

.help-content-inline .help-tip {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border-left: 4px solid #3b82f6;
  border-radius: 0.5rem;
  margin: 1rem 0;
}

.help-content-inline .help-tip strong {
  display: block;
  margin-bottom: 0.25rem;
}

/* Scrollbar for help content */
.help-content-inline::-webkit-scrollbar {
  width: 6px;
}

.help-content-inline::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.help-content-inline::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.help-content-inline::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
.odt-btn {
  appearance: none;
  border: none;
  background: linear-gradient(180deg, #e8f8ff, #cfeeff); /* Subtle modern gradient */
  color: #0f172a;
  padding: .3rem .6rem; /* Smaller padding for more compact buttons */
  border-radius: .4rem; /* Slightly smaller border-radius */
  font-size: .85rem; /* Smaller font size */
  cursor: pointer;
  line-height: 1;
  transition: background .18s ease, transform .08s ease, box-shadow .18s ease;
  box-shadow: 0 8px 20px rgba(2,6,23,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
  border: 1px solid rgba(2,6,23,0.04);
}
.odt-btn:hover {
  background: linear-gradient(180deg, #cfeeff, #9ddfff); /* Slightly darker on hover */
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(2,6,23,0.09), inset 0 1px 0 rgba(255,255,255,0.4);
}
.odt-btn:active { transform: translateY(1px); }
.odt-btn.primary {
  background: linear-gradient(180deg, #f0f0f0, #e0e0e0); /* Light gray gradient */
  color: #333333; /* Darker text for contrast */
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.1); /* Subtle inner shadow */
}
.odt-btn.primary:hover {
  background: linear-gradient(180deg, #e0e0e0, #d0d0d0); /* Slightly darker gray on hover */
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.15); /* Slightly more pronounced inner shadow on hover */
}

/* Disabled state for buttons */
.odt-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

/* Icon buttons for alignment */
.odt-btn.icon-btn {
  padding: .4rem .6rem; /* Smaller padding for icon buttons */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; /* Fixed width for square buttons */
  height: 40px; /* Fixed height for square buttons */
  flex-shrink: 0; /* Prevent shrinking */
}
.odt-btn.icon-btn svg {
  width: 20px; /* Icon size */
  height: 20px; /* Icon size */
}

/* Active state for icon buttons (e.g., bold/italic toggled on) */
.odt-btn.icon-btn.active {
  background: linear-gradient(180deg, #1d4ed8, #2563eb); /* Darker blue gradient for active state */
  color: #e5e7eb; /* White text/icon for active state */
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4); /* Inner shadow for active state */
}
.odt-btn.icon-btn.active:hover {
  background: linear-gradient(180deg, #103a8a, #1d4ed8); /* Even darker on hover when active */
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

/* Layout */
.odt-layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 0;
  min-height: 0;
  align-items: start;
  border-radius: .75rem; /* Apply rounded corners */
  box-shadow: 0 30px 60px rgba(2,6,23,.15); /* Apply shadow */
  /* overflow: hidden; Removed to allow sticky positioning */
  background: #fff; /* Add a background to make rounded corners visible */
}
.odt-pane {
  padding: .75rem;
  border-right: 1px solid #e5e7eb;
  background: #fff;
  overflow: auto;
  /* Extra bottom padding so last controls (like Import) don't get clipped by the rounded layout container */
  padding-bottom: 3.25rem;
  /* Elevate sidebars above layer-drag placeholder to prevent click blocking */
  z-index: 100;
}
.odt-layout > .odt-pane:not(.right) {
  position: sticky;
  top: 110px;
  align-self: start;
  max-height: calc(100vh - 220px);
}
.odt-pane.right {
  border-right: none;
  border-left: 1px solid #e5e7eb;
  position: sticky;
  top: 10px;
  align-self: start;
  max-height: calc(100vh - 120px);
}
.odt-pane h3 {
  margin: .5rem 0 1rem; /* Increased bottom margin for more separation */
  font-size: 1.1rem; /* Slightly larger font size */
  font-weight: 600; /* Bolder font weight */
  color: #0f172a;
  padding-bottom: .5rem; /* Add padding below text */
  border-bottom: 1px solid #e5e7eb; /* Subtle bottom border */
}
.odt-toolbar { display: grid; gap: .5rem; }
.odt-group {
  background: #f9fafb;
  padding: .5rem;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
}
.odt-group label { display: block; font-size: .8rem; color: #334155; margin-bottom: .15rem; }
.odt-group .row { display: flex; gap: .5rem; align-items: center; }

.odt-input, select.odt-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  border-radius: .45rem;
  padding: .45rem .55rem;
  font-size: .9rem;
}
input[type="file"].odt-input {
  padding: .3rem;
}
/* Color input: compact rounded swatch (smaller / forced) */
input[type="color"].odt-input {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid #cbd5e1;
  padding: 0;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  max-width: 20px !important;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  vertical-align: middle;
  box-sizing: border-box;
  display: inline-block;
  overflow: hidden;
}

/* Chrome / Safari: remove extra wrapper padding and make swatch truly fit */
input[type="color"].odt-input::-webkit-color-swatch-wrapper {
  padding: 0 !important;
  border-radius: 6px;
}
input[type="color"].odt-input::-webkit-color-swatch {
  border: none !important;
  border-radius: 6px;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Firefox: make swatch fit and rounded */
input[type="color"].odt-input::-moz-color-swatch {
  border: none !important;
  border-radius: 6px;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Fallback: any color inputs inside the toolbar group (covers cases without the odt-input class) */
.odt-group input[type="color"] {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  max-width: 20px !important;
  padding: 0 !important;
  border-radius: 6px !important;
  box-sizing: border-box !important;
}

/* Accessibility / disabled state */
input[type="color"].odt-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Tidy layout for the Font controls */
.odt-font-group .row {
  align-items: center;
  gap: .4rem; /* Reduced gap for compactness */
  margin-top: .4rem; /* Reduced top margin for rows */
}

/* Make the small labels in the font group more compact */
.odt-font-group .row .odt-small,
.odt-font-group .row > label {
  flex: 0 0 48px; /* Slightly smaller flex basis for labels */
  min-width: 48px;
  font-size: .75rem; /* Slightly smaller font size for labels */
  color: #475569; /* Softer color for labels */
}

/* Size input in font group: compact numeric field */
.odt-font-group .row input[type="number"].odt-input#inp-font-size {
  flex: 0 0 56px; /* More compact width */
  width: 56px;
  padding: .3rem .4rem; /* Reduced padding */
  text-align: center;
  font-size: .85rem; /* Slightly smaller font size */
  border-radius: .35rem; /* Softer border radius */
}

/* Stroke size input: small fixed width */
.odt-font-group .row input[type="number"].odt-input#inp-stroke-width {
  flex: 0 0 56px; /* More compact width */
  width: 56px;
  padding: .3rem .4rem; /* Reduced padding */
  text-align: center;
  font-size: .85rem; /* Slightly smaller font size */
  border-radius: .35rem; /* Softer border radius */
}

/* Ensure color swatches in font group sit neatly with a little spacing */
.odt-font-group .row input[type="color"] {
  margin-left: .2rem; /* Adjusted margin */
  margin-right: .2rem; /* Adjusted margin */
  vertical-align: middle;
  width: 24px !important; /* Slightly larger color swatch */
  height: 24px !important; /* Slightly larger color swatch */
  min-width: 24px !important;
  max-width: 24px !important;
  border-radius: .35rem; /* Softer border radius */
  border: 1px solid #e2e8f0; /* Softer border */
  box-shadow: 0 1px 2px rgba(0,0,0,0.05); /* Subtle shadow */
}

/* Make the font select sit full width and slightly tighter */
.odt-font-group select.odt-input {
  margin-bottom: .3rem; /* Reduced bottom margin */
  padding: .35rem .55rem; /* Adjusted padding for consistency */
  font-size: .85rem; /* Slightly smaller font size */
  border-radius: .35rem; /* Softer border radius */
  max-width: 100%; /* Ensure it doesn't exceed its container */
  width: 100%; /* Make it take full width of its container */
}

/* Style for range inputs */
.odt-input[type="range"] {
  -webkit-appearance: none; /* Remove default webkit styles */
  appearance: none;
  background: transparent; /* Hide default track */
  cursor: pointer;
  height: 1.2rem; /* Adjust height for better usability */
  padding: 0; /* Remove padding */
}

/* Track styles for range input */
.odt-input[type="range"]::-webkit-slider-runnable-track {
  background: #e2e8f0; /* Softer track color */
  border-radius: 0.25rem;
  height: 0.4rem; /* Thinner track */
}
.odt-input[type="range"]::-moz-range-track {
  background: #e2e8f0;
  border-radius: 0.25rem;
  height: 0.4rem;
}

/* Thumb styles for range input */
.odt-input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; /* Remove default webkit styles */
  appearance: none;
  background-color: #2563eb; /* Primary color for thumb */
  border: 1px solid #1d4ed8;
  border-radius: 50%;
  height: 1rem;
  width: 1rem;
  margin-top: -0.3rem; /* Center thumb vertically on track */
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: background-color .15s ease, box-shadow .15s ease;
}
.odt-input[type="range"]::-moz-range-thumb {
  background-color: #2563eb;
  border: 1px solid #1d4ed8;
  border-radius: 50%;
  height: 1rem;
  width: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: background-color .15s ease, box-shadow .15s ease;
}

/* Focus styles for range input */
.odt-input[type="range"]:focus {
  outline: none;
}
.odt-input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(37,99,235,0.3);
}
.odt-input[type="range"]:focus::-moz-range-thumb {
  box-shadow: 0 0 0 3px rgba(37,99,235,0.3);
}

/* General input styling for a softer look */
.odt-input, select.odt-input {
  border-color: #e2e8f0; /* Softer border color */
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03); /* Subtle inner shadow */
  transition: border-color .15s ease, box-shadow .15s ease;
}
.odt-input:focus, select.odt-input:focus {
  border-color: #93c5fd; /* Light blue focus border */
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05), 0 0 0 3px rgba(147,197,253,0.3); /* Focus ring */
  outline: none;
}

/* Reduce visual weight of swatches (no heavy border) to look slimmer */
input[type="color"].odt-input,
.odt-group input[type="color"] {
  border-width: 1px;
  border-color: #e2e8f0; /* Softer border color */
  box-shadow: 0 1px 2px rgba(0,0,0,0.05); /* Subtle shadow */
}

/* Canvas area */
.odt-canvas-wrap {
  display: flex;
  /* center the design area container horizontally and vertically in the available canvas space */
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  min-height: calc(100vh - 78px);
  padding: 20px;
  position: sticky;
  top: 10px;
  align-self: start;
  overflow: visible;
}
.odt-canvas-inner {
  /* make the inner panel a centered column so the canvas and helper text are aligned in the middle */
  display: flex;
  flex-direction: column;
  align-items: center;
  background: repeating-conic-gradient(#f8fafc 0% 25%, #f1f5f9 0% 50%) 50%/2rem 2rem;
  padding: 0.5rem; /* reduce padding so canvas stays closer to controls */
  border: 1px dashed #cbd5e1;
  border-radius: .75rem;
  box-shadow: 0 20px 40px rgba(2,6,23,.08);
  max-width: none;
  width: 90%;
  position: relative;
  overflow: visible;
  max-height: none;
}
.odt-viewport {
  width: 100%;
  max-width: 100%;
  max-height: 70vh;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.odt-viewport.is-scrollable {
  overflow: auto;
  justify-content: flex-start;
}

.odt-canvas-sizer {
  display: inline-block;
  vertical-align: top;
  max-width: none;
  max-height: none;
}

/* Tighter spacing rules to remove vertical gap between the top controls and the canvas */
.odt-canvas-topbar {
  margin-bottom: 0.25rem; /* reduce gap below the topbar controls */
}
.odt-canvas-meta {
  margin-bottom: 0; /* remove extra bottom margin */
}
.odt-canvas-scaler {
  margin-top: 0; /* ensure scaler sits immediately after meta row */
}
/* ensure the small meta row still spans the width of the inner panel but content is centered */
.odt-canvas-meta {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-size: .8rem;
  color: #475569;
  margin-bottom: 0; /* tightened to remove gap above the canvas */
}

/* Make the canvas itself centered and prevent inline spacing issues */
#designer-canvas {
  display: block;
  margin: 0 auto;
}

.odt-canvas-scaler {
  transition: transform 0.3s ease-in-out;
  transform-origin: top left;
  /* Ensure the scaler participates in layout as an inline-block and
     aligns to the top of the surrounding content so no baseline gap
     appears above/below the canvas when we set its width/height via JS. */
  display: inline-block;
  vertical-align: top;
  max-width: none;
  max-height: none;
}

/* Prevent page scroll/pan gestures from hijacking object dragging on the canvas */
.canvas-container,
.canvas-container canvas {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Center the lower helper text inside the design area */
.odt-canvas-inner .odt-small.odt-muted,
.odt-canvas-inner .odt-small {
  text-align: center;
}

/* Layers and properties */
.odt-layers { font-size: .9rem; }
.odt-layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem .5rem;
  border: 1px solid #e5e7eb;
  border-radius: .35rem;
  margin-bottom: .35rem;
  background: #fff;
  cursor: pointer;
  transition: background .12s ease, transform .08s ease, opacity .08s ease, top 0.3s ease-out; /* Added top for animation */
  position: relative; /* Needed for top property to work */
}

/* Drag affordances (visible when items are draggable) */
.odt-layer-item[draggable="true"] {
  cursor: grab;
}
.odt-layer-item:active {
  cursor: grabbing;
}
.odt-layer-item:hover { background: #f8fafc; }

/* Visual state when dragging */
.odt-layer-item.dragging {
  opacity: 0.7;
  transform: scale(.99);
  box-shadow: 0 6px 18px rgba(2,6,23,.06);
  z-index: 10; /* Ensure dragging item is above others */
}

/* Blink effect for selected layer item */
@keyframes layer-blink {
  0% { background-color: #eef2ff; } /* Light blue */
  50% { background-color: #dbeafe; } /* Slightly darker blue */
  100% { background-color: #eef2ff; }
}

.odt-layer-item.selected-blink {
  animation: layer-blink 0.8s ease-in-out 2; /* Blink twice */
  background-color: #eef2ff; /* Default selected background */
}

/* Class to temporarily disable transitions during DOM manipulation */
.odt-layers.no-transition .odt-layer-item {
  transition: none !important;
}

/* Visual drop target indicator */
.odt-layer-item.drag-over {
  outline: 2px dashed rgba(37,99,235,.9);
  background: #eef2ff;
}

.odt-badge {
  font-size: .72rem;
  padding: .1rem .35rem;
  border: 1px solid #cbd5e1;
  border-radius: .35rem;
  color: #334155;
  background: #f8fafc;
}
.odt-muted { color: #64748b; }
.odt-divider { height: 1px; background: #e5e7eb; margin: .5rem 0; }
.odt-small { font-size: .8rem; color: #64748b; }

/* Modals */
.odt-modal {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

#templates-modal,
#my-designs-modal,
#save-design-modal,
#save-template-modal,
#custom-alert-modal,
#customer-designs-modal {
  z-index: 2147483647 !important;
}
.odt-modal.open { display: flex; }
.odt-modal-card {
  width: min(1100px, 92vw);
  max-height: 84vh;
  overflow: hidden;
  background: #fff;
  border-radius: .75rem;
  box-shadow: 0 30px 60px rgba(2,6,23,.35);
  display: flex;
  flex-direction: column;
}
.odt-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}
.odt-modal-body { padding: 1rem; overflow: auto; }

/* Templates grid */
.odt-templates-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.odt-template-card {
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.odt-template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(2,6,23,.08);
}
.odt-template-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3.5 / 2;
  object-fit: cover;
  background: #f1f5f9;
}
.odt-template-card .meta {
  padding: .5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Custom Alert/Confirmation Modal Styles */
#custom-alert-modal .odt-modal-card {
  width: min(400px, 90vw); /* Smaller width for alerts */
  max-height: unset; /* Allow height to adjust to content */
  animation: fadeInScaleUp 0.3s ease-out forwards;
}

#custom-alert-modal .odt-modal-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f1f5f9; /* Lighter header background */
}

#custom-alert-modal .odt-modal-header strong {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0f172a;
}

#custom-alert-modal .odt-modal-body {
  padding: 1rem;
  text-align: center;
  font-size: 0.95rem;
  color: #334155;
}

#custom-alert-modal .odt-modal-actions {
  display: flex;
  justify-content: center; /* Center buttons */
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Animation for modal entry */
@keyframes fadeInScaleUp {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Animation for modal exit */
@keyframes fadeOutScaleDown {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.9);
  }
}

.odt-modal.closing .odt-modal-card {
  animation: fadeOutScaleDown 0.5s ease-out forwards;
}

/* Responsive */
@media (max-width: 1100px) {
  .odt-layout { grid-template-columns: 240px 1fr 240px; }
}
@media (max-width: 900px) {
  .odt-layout { grid-template-columns: 1fr; }
  .odt-pane { border-right: none; border-bottom: 1px solid #e5e7eb; }
  .odt-pane.right { border-left: none; border-top: 1px solid #e5e7eb; }
  .odt-pane,
  .odt-canvas-wrap {
    position: static;
    top: auto;
    max-height: none;
  }
}

/* Loading Overlay Styles */
@keyframes jump {
  0% { transform: translateY(0); }
  25% { transform: translateY(-15px); }
  50% { transform: translateY(0); }
  75% { transform: translateY(-7px); }
  100% { transform: translateY(0); }
}

.pain-icon img {
  animation: jump 1s ease-in-out infinite;
}

.loading-bar {
  transition: width 0.3s ease-out; /* Smooth transition for width change */
}

/* Animations for design system sections */
@keyframes fadeInSlideUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.odt-layout-animated .odt-pane,
.odt-layout-animated .odt-canvas-wrap {
  animation: fadeInSlideUp 0.6s ease-out forwards;
  opacity: 0; /* Start hidden for animation */
}

.odt-layout-animated .odt-pane:nth-child(1) {
  animation-delay: 0.1s; /* Delay for left pane */
}

.odt-layout-animated .odt-canvas-wrap {
  animation-delay: 0.2s; /* Delay for center canvas */
}

.odt-layout-animated .odt-pane:nth-child(2) {
  animation-delay: 0.3s; /* Delay for right pane */
}

/* Temporarily hide the "Save PNG to Server" button(s) */
#btn-export-server {
  display: none !important;
  visibility: hidden !important;
}

/* Upload button styling (label acting as upload control) */
.upload-btn {
  background: linear-gradient(180deg, #ffffff, #f0fbff);
  color: #063f2d;
  padding: .45rem .85rem;
  border-radius: .6rem;
  border: 1px solid rgba(2,6,23,0.06);
  box-shadow: 0 8px 18px rgba(2,6,23,0.06);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.upload-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(2,6,23,0.08);
}

/* Filename hint next to upload button */
#upload-filename {
  font-size: .85rem;
  color: #475569;
  display: inline-block;
  vertical-align: middle;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Uploaded images gallery: enforce a robust fixed scroll area and prevent clipping.
   Use !important to override inline styles and ensure the gallery itself scrolls
   while remaining fully visible inside the left pane. */
#uploaded-images-gallery {
  /* Reduce vertical size so the gallery fits within the visible ADD Stuff container.
     Use a responsive cap so it remains usable on smaller viewports. */
  max-height: min(260px, 38vh) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  box-sizing: border-box;
  padding-right: 8px !important;
  padding-left: .5rem !important;
}

/* Ensure each uploaded item is measured correctly and fully visible inside the scroller */
#uploaded-images-gallery .uploaded-image-item {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
  padding-bottom: 0;
}

/* Make the small add/remove buttons a bit more compact so they don't push content out */
#uploaded-images-gallery .odt-btn.odt-btn-sm {
  padding: .25rem .35rem;
  min-width: 34px;
  height: 28px;
  box-sizing: border-box;
}

/* Animated show/hide for toolbar groups */
.odt-group {
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out, margin-bottom 0.3s ease-out;
  /* IMPORTANT: don't clip content (e.g. Images + Import) in the visible state */
  overflow: visible;
  max-height: 5000px; /* large enough to avoid clipping; left pane handles scrolling */
  opacity: 1;
  margin-bottom: .5rem; /* Default margin */
}

.odt-group.odt-group-hidden {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
}

/* Hide accordion sections entirely when toggled off by JS (keeps DOM headers clean).
   Use a smooth fade+slide animation when showing. */
.odt-accordion-hidden {
  display: none !important;
}

/* Show animation for accordion sections when they are opened by JS.
   We animate the inner content so showing feels soft and modern. */
.odt-accordion-section {
  --accordion-duration: 600ms; /* Slowed down for smoother feel */
}

.odt-accordion-section .odt-accordion-content {
  transition: max-height var(--accordion-duration) cubic-bezier(0.4, 0, 0.2, 1), opacity var(--accordion-duration) ease, padding var(--accordion-duration) ease;
  will-change: max-height, opacity, padding;
}

/* When the section has the 'open' class the content will expand (this already exists),
   we add a slight upward origin and fade so it feels modern. */
.odt-accordion-section.open .odt-accordion-content {
  animation: fadeInSlideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Provide a subtle focus/outline when sections become visible for accessibility */
.odt-accordion-section.open {
  box-shadow: 0 6px 18px rgba(2,6,23,0.04);
  border-color: #dbeafe;
}

/* Accordion styles */
.odt-accordion-section {
  margin-bottom: .5rem;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  background: #f9fafb;
  overflow: hidden; /* Ensures content is clipped when collapsed */
}

.odt-accordion-section.open {
  border-color: #cbd5e1; /* Slightly darker border when open */
  overflow-x: hidden; /* Prevent horizontal overflow while allowing vertical growth */
  overflow-y: visible; /* Allow vertical content to show, parent .odt-pane handles scrolling */
}

.odt-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: .5rem .75rem;
  background: #f1f5f9; /* Lighter background for header */
  border: none;
}

/* Breadcrumb */
.odt-modern-breadcrumb {
  background: rgba(255, 255, 255, 0.8);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  font-size: 0.85rem;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
}
.odt-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
}
.odt-bc-sep {
  color: #cbd5e1;
  font-size: 0.75rem;
}
.odt-bc-current {
  color: #0f172a;
  font-weight: 600;
}
