/* Removed .spg-container, .spg-controls, .spg-form-group, etc as Bootstrap 5 row/col and form-controls are now used. */

/* Global Font Size Bump */
#spg-main-container,
#spg-main-container .btn,
#spg-main-container .form-control,
#spg-main-container .form-select,
#spg-main-container .form-label,
#spg-main-container .accordion-button,
#spg-folder-manager-modal .modal-content {
  font-size: 14px !important; /* Unified global UI font size */
}

#spg-getting-started-overlay {
  font-size: 1.25rem !important;
}
#spg-getting-started-overlay .btn {
  font-size: 1.25rem !important;
}
#spg-getting-started-overlay .accordion-button {
  font-size: 1.25rem !important;
}
#spg-getting-started-overlay .list-group-item {
  font-size: 1.15rem !important;
}

/* ============================================= */
/* Unified Toolbar - All Screen Sizes            */
/* ============================================= */
.spg-unified-toolbar {
  display: flex !important;
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
  border-bottom: 1px solid rgba(255,255,255,0.1) !important;
  border-top: none !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2) !important;
  z-index: 100002;
  padding: 6px 12px !important;
  gap: 4px !important;
  overflow-x: auto;
  backdrop-filter: none;
}
.spg-unified-toolbar::-webkit-scrollbar {
  display: none;
}

.spg-unified-toolbar .spg-toolbar-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  padding: 8px 14px !important;
  font-size: 13px !important;
  font-weight: 500;
  color: rgba(255,255,255,0.7) !important;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  line-height: 1;
  min-width: auto;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none !important;
}
.spg-unified-toolbar .spg-toolbar-btn:hover {
  background: rgba(255,255,255,0.1) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,0.15) !important;
}
.spg-unified-toolbar .spg-toolbar-btn.active-tab {
  background: rgba(99, 102, 241, 0.3) !important;
  color: #fff !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
}
.spg-unified-toolbar .spg-toolbar-btn .dashicons {
  font-size: 18px;
  height: 18px;
  width: 18px;
  color: inherit;
}
.spg-unified-toolbar .spg-toolbar-btn.spg-primary-btn {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  font-weight: 600;
}
.spg-unified-toolbar .spg-toolbar-btn.spg-primary-btn:hover {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

/* ============================================= */
/* PC Layout: Single Panel + Tabs                */
/* ============================================= */
@media (min-width: 992px) {
  .spg-unified-toolbar {
    padding: 8px 20px !important;
    gap: 6px !important;
  }
  .spg-unified-toolbar .spg-toolbar-btn {
    padding: 10px 18px !important;
    font-size: 13px !important;
    border-radius: 10px !important;
  }
  .spg-unified-toolbar .spg-toolbar-btn .dashicons {
    font-size: 16px;
    height: 16px;
    width: 16px;
  }
  
  /* Controls Panel: Single panel at a time on PC too */
  .spg-controls {
    display: block !important; /* Always visible on PC */
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    padding: 16px !important;
  }
  
  /* Hide all sections, show only active */
  .spg-section {
    display: none !important;
  }
  .spg-section.active-section {
    display: block !important;
  }
  
  /* Style the section cards on PC */
  .spg-section.active-section {
    border: none;
    box-shadow: none !important;
    background: transparent;
    margin-bottom: 0;
  }
  .spg-section.active-section > .card-body {
    padding: 12px 4px !important;
  }
  
  /* Hide mobile close buttons on PC */
  .spg-close-controls-btn {
    display: none !important;
  }
  
  /* Preview area adjustments */
  .spg-preview-area {
    top: 10px !important;
    padding-bottom: 1rem !important;
  }
}

/* Preview Box Updates */
.spg-preview-box {
  /* Base size: 540x960 */
  display: block !important;
  width: 540px;
  height: 960px;
  background-color: #f0f0f1;
  border: 2px dashed #ccc;
  position: relative; /* Relative for children */
  overflow: hidden;

  /* Remove transform to fix jQuery UI Draggable offsets */
  /* transform: scale(0.5);transform-origin: top center; */

  margin: 0 auto;
  margin-bottom: 20px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Result Area (Desktop Default) */
#spg-result-area {
  max-width: 540px; /* Match standard preview box width */
  margin: 0 auto; /* Center like the preview box */
}

/* Draggable Elements in Preview */
.spg-layer-element {
  position: absolute;
  cursor: move;
  border: 1px dashed transparent;
  max-width: 100%;
  width: fit-content; /* Ensure it doesn't take full width */
  display: inline-block; /* Fallback */
  white-space: nowrap;
  float: none !important;
  clear: none !important;
  margin: 0 !important;
  transform-origin: top left !important;
  touch-action: none; /* Prevent rubber-banding or scrolling on mobile touch/drag */
}

/* Inner wrapper for Animation to avoids conflicts with Drag (top/left) vs Animation (transform) */
.spg-layer-inner {
  display: inline-block;
  width: 100%;
  height: 100%;
}

.spg-layer-element:hover {
  border-color: #007cba;
}

.spg-layer-element.is-selected {
  border-color: #007cba;
  z-index: 100;
}

/* Scaling Mode Highlight */
.spg-layer-element.spg-scaling-highlight {
  border: 2px solid #00cba0;
  box-shadow: 0 0 10px rgba(0, 203, 160, 0.5);
  z-index: 105;
}

#spg-preview-box {
  display: block !important;
  background: transparent;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  touch-action: none; /* Prevent browser pinch-to-zoom on the canvas */
}

/* Grid Overlay - SVG Fallback for High DPI Mobile Renderers */
.spg-grid-overlay::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let touches pass through to Draggable elements */
  z-index: 9; /* Keep it below draggable items (which start at 10) but highest otherwise */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><path d='M 20 0 L 0 0 0 20' fill='none' stroke='rgba(0,0,0,0.15)' stroke-width='1'/></svg>") !important;
  background-size: 20px 20px !important;
  background-position: center top !important;
}

/* Grid Center Lines - Vertical and Horizontal Guides */
.spg-grid-overlay::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9; /* Same as grid, sits on top because it's ::after */
  /* Draw a 1px semi-transparent black line exactly in the middle vertically and horizontally */
  /* Draw a 1px semi-transparent black line exactly in the middle vertically and horizontally */
  background-image:
    linear-gradient(
      to right,
      transparent calc(50% - 0.5px),
      rgba(0, 0, 0, 0.3) calc(50% - 0.5px),
      rgba(0, 0, 0, 0.3) calc(50% + 0.5px),
      transparent calc(50% + 0.5px)
    ),
    linear-gradient(
      to bottom,
      transparent calc(50% - 0.5px),
      rgba(0, 0, 0, 0.3) calc(50% - 0.5px),
      rgba(0, 0, 0, 0.3) calc(50% + 0.5px),
      transparent calc(50% + 0.5px)
    );
}

/* Background Layer */
.spg-bg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}

/* Animations (Keyframes only, applied dynamically via JS) */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

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

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes slide-in {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes neon {
  0%,
  100% {
    opacity: 1;
    text-shadow:
      0 0 10px #fff,
      0 0 20px #fff,
      0 0 30px #e60073,
      0 0 40px #e60073;
  }
  50% {
    opacity: 0.5;
    text-shadow: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes zoom-in {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-30px);
  }
  60% {
    transform: translateY(-15px);
  }
}

@keyframes wobble {
  0% {
    transform: translateX(0%);
  }
  15% {
    transform: translateX(-25%) rotate(-5deg);
  }
  30% {
    transform: translateX(20%) rotate(3deg);
  }
  45% {
    transform: translateX(-15%) rotate(-3deg);
  }
  60% {
    transform: translateX(10%) rotate(2deg);
  }
  75% {
    transform: translateX(-5%) rotate(-1deg);
  }
  100% {
    transform: translateX(0%);
  }
}

@keyframes flash {
  0%,
  50%,
  100% {
    opacity: 1;
  }
  25%,
  75% {
    opacity: 0;
  }
}

@keyframes heartbeat {
  0% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.3);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.3);
  }
  70% {
    transform: scale(1);
  }
}

@keyframes tada {
  0% {
    transform: scale3d(1, 1, 1);
  }
  10%,
  20% {
    transform: scale3d(0.9, 0.9, 0.9) rotate3d(0, 0, 1, -3deg);
  }
  30%,
  50%,
  70%,
  90% {
    transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg);
  }
  40%,
  60%,
  80% {
    transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg);
  }
  100% {
    transform: scale3d(1, 1, 1);
  }
}

/* Button and Form styles replaced by Bootstrap. */

/* Mobile Responsiveness */
@media (max-width: 768px) {
  /* Legacy Bootstrap Overrides if needed */

  .spg-preview-box {
    margin: 0 auto;
    /* Removed transform: none; so JS scaling can work */
    margin-bottom: 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  }

  /* Increase Welcome Screen Typography for Mobile */
  #spg-getting-started-overlay {
    font-size: 1.4rem !important;
  }
  #spg-getting-started-overlay .card-title {
    font-size: 1.7rem !important;
  }
  #spg-getting-started-overlay .card-header {
    font-size: 1.5rem !important;
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }
  #spg-getting-started-overlay .btn {
    font-size: 1.5rem !important;
    padding: 0.75rem 1rem !important;
  }
  #spg-getting-started-overlay .accordion-button {
    font-size: 1.4rem !important;
    padding: 1rem !important;
  }
  #spg-getting-started-overlay .list-group-item {
    font-size: 1.3rem !important;
    padding: 1rem !important;
  }
  #spg-getting-started-overlay .text-muted {
    font-size: 1.1rem !important;
  }
  #spg-getting-started-overlay .card-text {
    font-size: 1.2rem !important;
  }
}

/* Custom Media Modal */
.spg-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spg-modal-content {
  background: #fff;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

/* Auto-Gen Image Preview */
.spg-ag-img-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
  padding: 6px 10px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
}
.spg-ag-img-preview .preview-content {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}
.spg-ag-img-preview img {
  height: 32px;
  width: 32px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid #ddd;
}
.spg-ag-img-preview .preview-url {
  font-size: 0.75rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spg-modal-header {
  padding: 10px 15px;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f9f9f9;
}
.spg-modal-tabs {
  display: flex;
  gap: 10px;
}
.spg-tab-btn {
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: #666;
  padding: 5px 10px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.spg-tab-btn.active {
  color: #007cba;
  border-bottom-color: #007cba;
}
.spg-tab-btn:hover {
  color: #007cba;
}
#spg-close-media-modal {
  background: #f1f1f1 !important;
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
  font-size: 18px !important;
  cursor: pointer;
  color: #555 !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  line-height: 1 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}
#spg-close-media-modal:hover {
  color: #d63638;
}

.spg-modal-body {
  padding: 15px;
  overflow-y: auto;
  flex: 1;
}
.spg-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 15px;
}
.spg-media-item {
  position: relative;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: #eee;
}
.spg-preview-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #999;
  text-align: center;
  font-size: 14px;
  pointer-events: none;
  width: 80%;
  line-height: 1.5;
}
.spg-media-item:hover {
  border-color: #2271b1;
}
.spg-media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.spg-media-delete-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #d63638;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 10;
}
.spg-media-delete-btn:hover {
  background: #b32d2e;
}

/* Mobile Toolbar - now using .spg-unified-toolbar for all screen sizes */

/* Base styles for new components (Desktop mostly hidden) */
.spg-bottom-sheet-drag-handle {
  display: none;
}
.spg-close-panel-btn {
  display: none;
}

/* Mobile Integrated UI */
@media screen and (max-width: 768px) {
  /* Hide WP Admin bar and menus to maximize screen */
  html {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  body {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  html.wp-toolbar {
    padding-top: 0 !important;
  }
  #wpadminbar,
  #adminmenumain,
  #wpfooter {
    display: none !important;
  }
  #wpcontent,
  #wpbody-content,
  .wrap {
    padding: 0 !important;
    margin: 0 !important;
  }

  #spg-main-container {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    /* Using 100% instead of 100vh can sometimes fix Safari bottom bar jumping, but 100% needs body 100% */
    /* dvh is dynamic viewport height, fixes mobile address bar issues */
    height: 100vh; /* Fallback for older browsers */
    height: 100dvh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    background: #e0e0e0;
    z-index: 99999;
    overflow-y: auto;
    overflow-x: hidden;
    /* overscroll-behavior: none; Prevent rubber-banding on iOS Safari (Disabled to allow pull-to-refresh) */
  }

  /* Optional toggle class via JS for locking scroll again */
  #spg-main-container.spg-locked {
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }

  /* Target the wrapper around display.php to remove margins */
  .spg-frontend-wrapper {
    margin: 0;
    padding: 0;
  }

  /* Top Toolbar - inherits .spg-unified-toolbar dark theme */

  /* Preview Box takes remaining height */
  .spg-preview-area {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    top: 0;
    left: 0;
    justify-content: center;
    overflow: hidden;
    z-index: 100000; /* Ensure it stays above base backgrounds */
  }

  .spg-preview-area h3 {
    display: none; /* Hide preview text on mobile */
  }

  .spg-preview-box {
    margin: 0;
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%); /* Base centering, JS adjusts scale */
    transform-origin: top center;
    z-index: 100000;
  }
  /* Mobile Toolbar Overrides for unified toolbar */
  .spg-unified-toolbar {
    padding: 4px 6px !important;
    padding-top: max(4px, env(safe-area-inset-top, 4px)) !important;
    gap: 2px !important;
  }
  .spg-unified-toolbar .spg-toolbar-btn {
    flex: 1 1 0;
    flex-direction: column;
    padding: 6px 4px !important;
    font-size: 10px !important;
    gap: 2px;
    min-width: 44px;
    border-radius: 6px !important;
  }
  .spg-unified-toolbar .spg-toolbar-btn .dashicons {
    font-size: 20px;
    height: 20px;
    width: 20px;
  }

  /* Controls Panel (Top Sheet) */
  .spg-controls {
    display: none; /* JS slideDown handles visibility */
    position: relative;
    flex: 0 0 auto;
    top: 0;
    left: 0;
    width: 100%;
    max-height: 50vh;
    background: #fff;
    border-radius: 0; /* User request: remove radius */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); /* Slight top shadow */
    z-index: 100001;
    padding: 12px 15px; /* Compact padding */
    box-sizing: border-box;
    overflow-y: auto;
  }
  /* Hide headers internally to make the panels more compact */
  .spg-section h3 {
    display: none;
  }

  /* Drag Handle UI (Hidden since not at bottom anymore) */
  .spg-bottom-sheet-drag-handle {
    z-index: 10;
    cursor: grab;
  }
  .spg-handle-bar {
    width: 40px;
    height: 5px;
    background: #ccc;
    border-radius: 3px;
  }

  /* Drag Handle UI (Hidden since not at bottom anymore) */

  /* Hide sections by default inside panel */
  .spg-section {
    display: none;
    border: none;
    margin-top: 5px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .spg-section.active-section {
    display: block;
  }

  #spg-result-area {
    position: fixed;
    top: 50%;
    left: 0;
    right: 0;
    margin: auto !important; /* Mathematically center between left 0 and right 0 */
    transform: translateY(-50%); /* Only translate Y to center vertically */
    width: 85vw; /* Slightly smaller than full width */
    max-width: 400px;
    max-height: 80vh; /* Prevent overflowing screen height */
    background: #fff;
    z-index: 200000;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    overflow-y: auto; /* Allow scroll if image is too tall */
  }
  #spg-result-gif {
    display: block;
    max-width: 100%;
    max-height: 50vh;
    object-fit: contain;
    margin: 10px auto; /* Center the image horizontally within the modal */
  }

  /* Mobile Overlays: Keep them inside the flex flow, below the toolbar */
  #spg-getting-started-overlay,
  #spg-autogen-input-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 100003 !important; /* Above toolbar (100002) but we position inside preview-wrapper so no overlap */
  }
}

/* --- Frontend Shortcode UI Refinement --- */
/* Use absolute PX to avoid theme-specific root font size (rem) interference */
.spg-frontend-wrapper #spg-main-container,
.spg-frontend-wrapper #spg-main-container .btn,
.spg-frontend-wrapper #spg-main-container .form-control,
.spg-frontend-wrapper #spg-main-container .form-select,
.spg-frontend-wrapper #spg-main-container .form-label,
.spg-frontend-wrapper #spg-main-container .accordion-button {
    font-size: 14px !important; /* Strictly reduced from 18px for general UI */
}

/* KEEP Wizard Font Sizes Large - These need higher specificity to override general reduction */
/* Target h3/h4 specifically to restore hierarchy */
.spg-frontend-wrapper .spg-ag-step h3,
.spg-frontend-wrapper .spg-ag-step h4,
.spg-frontend-wrapper h3.fw-bold,
.spg-frontend-wrapper h4.fw-bold,
.spg-frontend-wrapper #spg-ag-wizard-container h3,
.spg-frontend-wrapper #spg-ag-wizard-container h4,
.spg-frontend-wrapper .spg-ag-wizard-header h3,
.spg-frontend-wrapper .spg-ag-wizard-header h4 {
    font-size: 26px !important; /* Premium Large Title for PC */
    margin-bottom: 20px !important;
}

.spg-frontend-wrapper .spg-ag-step,
.spg-frontend-wrapper .spg-ag-step .form-control,
.spg-frontend-wrapper .spg-ag-step .form-label,
.spg-frontend-wrapper .spg-ag-step .btn,
.spg-frontend-wrapper .spg-ag-step-indicator,
.spg-frontend-wrapper .spg-ag-next-step-btn,
.spg-frontend-wrapper .spg-ag-prev-step-btn {
    font-size: 19px !important; /* Premium Large content for PC */
}

.spg-frontend-wrapper .spg-ag-wizard-header {
  padding: 12px !important;
}

.spg-frontend-wrapper .spg-ag-step-indicator {
  font-size: 20px !important;
  font-weight: bold !important;
}

/* Redundant PC step title rule removed */

.spg-frontend-wrapper .spg-ag-step .small,
.spg-frontend-wrapper .spg-ag-step .text-muted {
  font-size: 16px !important;
  display: block !important;
  margin-bottom: 10px !important;
}

/* Force border-radius consistency for frontend theme compatibility */
.spg-frontend-wrapper .form-control,
.spg-frontend-wrapper .form-select,
.spg-frontend-wrapper #spg-main-container .form-control,
.spg-frontend-wrapper #spg-main-container .form-select,
.spg-frontend-wrapper #spg-ag-shopname,
.spg-frontend-wrapper #spg-ag-phone,
.spg-frontend-wrapper #spg-ag-kakao,
.spg-frontend-wrapper #spg-ag-location,
.spg-frontend-wrapper #spg-ag-hours {
  border-radius: 8px !important;
  padding: 12px 15px !important;
  min-height: 48px !important;
}

/* Frontend toolbar inherits unified styles - minimal overrides needed */

/* Mobile Extreme Scaling for Frontend Shortcode */
@media screen and (max-width: 768px) {
    .spg-frontend-wrapper #spg-main-container,
    .spg-frontend-wrapper #spg-main-container .form-label,
    .spg-frontend-wrapper #spg-main-container .btn,
    .spg-frontend-wrapper #spg-main-container .form-control,
    .spg-frontend-wrapper #spg-main-container .form-select,
    .spg-frontend-wrapper #spg-main-container .accordion-button {
        font-size: 16px !important; /* Reduced for general UI */
    }

    /* Primary Wizard scaling remains extreme */
    .spg-frontend-wrapper .spg-ag-step .form-label,
    .spg-frontend-wrapper .spg-ag-step .form-control,
    .spg-frontend-wrapper .spg-ag-step .btn,
    .spg-frontend-wrapper .spg-ag-next-step-btn,
    .spg-frontend-wrapper .spg-ag-prev-step-btn,
    .spg-frontend-wrapper .spg-ag-step-indicator,
    .spg-frontend-wrapper .spg-ag-wizard-header .spg-ag-step-indicator {
        font-size: 18px !important; /* Reduced for mobile fitting */
    }
    
    .spg-frontend-wrapper .spg-ag-step h3,
    .spg-frontend-wrapper .spg-ag-step h4,
    .spg-frontend-wrapper h3.fw-bold,
    .spg-frontend-wrapper h4.fw-bold,
    .spg-frontend-wrapper #spg-ag-wizard-container h3,
    .spg-frontend-wrapper #spg-ag-wizard-container h4,
    .spg-frontend-wrapper .spg-ag-wizard-header h3,
    .spg-frontend-wrapper .spg-ag-wizard-header h4 {
        font-size: 32px !important; /* Premium Large Title for Mobile */
    }

    .spg-frontend-wrapper .spg-ag-step .small,
    .spg-frontend-wrapper .spg-ag-step .text-muted {
        font-size: 18px !important;
    }

    .spg-frontend-wrapper .spg-ag-wizard-header .btn {
        font-size: 18px !important; /* Reduced for mobile */
        padding: 6px 12px !important;
    }

    /* Target the sticky header specifically - Reset top to 0 as it's now full screen */
    .spg-ag-wizard-header {
        z-index: 1000001 !important; 
        padding: 8px !important;
        top: 0 !important; 
        background: #fff !important;
        border-bottom: 1px solid #eee !important;
    }
    
    .spg-frontend-wrapper .spg-ag-step .form-control {
        min-height: 56px !important;
    }

    .spg-frontend-wrapper #spg-autogen-input-overlay,
    .spg-frontend-wrapper #spg-getting-started-overlay,
    .spg-frontend-wrapper #spg-autogen-preview-overlay,
    .spg-frontend-wrapper #spg-autogen-result-overlay {
        position: fixed !important;
        left: 0 !important;
        width: 100% !important; 
        z-index: 1000000 !important;
        background: #fff !important;
    }

    /* Getting-started and autogen-input overlays: leave space for toolbar at top */
    .spg-frontend-wrapper #spg-getting-started-overlay,
    .spg-frontend-wrapper #spg-autogen-input-overlay {
        top: 0 !important;
        height: 100% !important;
        /* These are inside .spg-preview-area which is below toolbar in flex flow, */
        /* so they naturally sit below toolbar. Use position:absolute to stay inside parent. */
        position: absolute !important;
    }

    /* Result/preview overlays can still be fixed full-screen */
    .spg-frontend-wrapper #spg-autogen-preview-overlay,
    .spg-frontend-wrapper #spg-autogen-result-overlay {
        top: 0 !important;
        height: 100% !important;
    }

    /* Keep toolbar always visible - do NOT hide it when overlay is active */
    .spg-frontend-wrapper .spg-mobile-toolbar {
        z-index: 1000001 !important; /* Always above overlays */
        position: sticky !important;
        top: 0 !important;
    }

    .spg-frontend-wrapper .spg-ag-step {
        padding-bottom: 150px !important; /* Massive padding to ensure scroll reach */
    }
}

/* Template Grid for Welcome Screen */
.spg-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 6px;
    padding: 8px;
}
#spg-welcome-samples-accordion .accordion-button {
    font-size: 13px !important;
    padding: 0.75rem 1rem !important;
    box-shadow: none !important;
}
#spg-welcome-samples-accordion .accordion-button:not(.collapsed) {
    background-color: #f8f9fa !important;
    color: #007cba !important;
}
.spg-welcome-folder-title {
    display: none; /* Replaced by accordion headers */
}
.spg-template-card {
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.spg-template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #007cba;
}
.spg-template-thumb-wrapper {
    width: 100%;
    aspect-ratio: 9 / 16;
    background: #f0f0f1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.spg-template-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.spg-template-no-thumb {
    font-size: 1.25rem;
    color: #ccc;
}
.spg-template-info {
    padding: 4px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}
.spg-template-title {
    margin: 0;
    font-size: 10px;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
