body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  box-sizing: border-box;
}

body,
html,
button,
select,
input {
  font-family: "Playpen Sans", cursive;
}

/* Header section */
header {
  height: 10dvh; /* Header takes up 10% of the viewport height */
  background-color: #6ec8d0; /* #4caf50;*/
  color: white;
  display: flex;
  justify-content: space-between; /* Text on the left, buttons on the right */
  padding: 0 20px; /* Add padding to give some space */
  align-items: center;
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
}

/* Right-aligned header buttons */
.header-buttons {
  display: flex;
  gap: 15px; /* Space between buttons */
}

/* Styling for header buttons */
.header-button {
  background-color: #fff;
  color: #6ec8d0; /* #4caf50;*/
  border: none;
  padding: 10px;
  border-radius: 5px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.header-buttons img {
  width: 44px;
  height: 46px;
  border-radius: 10px;
  cursor: pointer;
}

.header-button:hover {
  background-color: #e0e0e0;
}

.header-button i {
  font-size: 1.5rem; /* Icon size */
}

.header-button:disabled {
  /*background-color: #a5d6a7; /* Faded green when disabled */
  opacity: 0.6; /* Lower opacity to give a less vibrant look */
  cursor: not-allowed; /* Change cursor to indicate it is disabled */
}

#generateThemeButton:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 70px;
  right: 15px;
  background-color: #419744;
  padding: 10px;
  border-radius: 5px;
  border: 2px solid white; /* Adding a yellow border */
  z-index: 1000; /* Add high z-index to bring it on top of other elements */
}
.dropdown-menu button {
  display: block;

  text-decoration: none;
  margin: 5px 0;
}

/* Main container for the layout */
.main-container {
  display: flex;
  height: max(90vh, 90dvh); /* Take up full viewport height */
}

/* Left section: Color palette */
.palette-section {
  width: 20%; /* Take up 20% of the window width */
  padding: 10px;
  box-sizing: border-box;
  border-right: 1px solid #ccc;
  overflow-y: auto; /* Scroll if palette section exceeds the window height */
}

.palette-section h3 {
  text-align: center;
}

.palette-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  /*width: 350px;  /* Adjust width to fit 5 color pickers in one row */
  /*margin-bottom: 20px;*/
}

#generatePatternButton {
  background-color: mediumpurple;
  color: white;
}

.fill-modal-button {
  background-color: #f0f0f0;
  border: none;
  border-radius: 5px;
  padding: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.fill-modal-button:hover {
  background-color: #e0e0e0;
}

.fill-modal-button:active {
  background-color: #ccc;
}

/*.palette-container input[type="color"],*/
.palette-container div.swatch {
  width: 60px;
  height: 60px;
  margin: 5px;
  cursor: pointer;
  border: 2px solid transparent; /* No border unless active */
  flex-shrink: 0; /* Prevent shrinking */
}

.palette-container div.swatch {
  padding: 4px;
  box-sizing: border-box; /* Ensures that padding and borders are included in the width/height */
  background-color: #f0f0f0; /* To give a similar background look */

  /* Disable text selection */
  user-select: none;
}

#addSwatchButton {
  width: 60px;
  height: 60px;
  margin: 5px;
  cursor: pointer;
  padding: 4px;
  box-sizing: border-box; /* Ensures that padding and borders are included in the width/height */
  flex-shrink: 0; /* Prevent shrinking */
}

#addSwatchButton button {
  width: 100%;
  height: 100%;
  font-size: 1.5rem;
}

div.swatch svg {
  border: 1px solid #777777;
  box-sizing: border-box;
  cursor: pointer;
}

.palette-container input[type="color"].active,
.palette-container div.swatch.active {
  border: 2px solid #000; /* Highlight the active palette */
}

#bgColorPicker {
  border: 1px solid #777777;
  cursor: pointer;
  padding: 2px;
  background-color: #ffffff;
}

#bgColorPicker svg {
  cursor: pointer;
}

/* Right section: SVG canvas */
.canvas-section {
  width: 80%; /* Take up 80% of the window width */
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f5f5f5;
  position: relative;
}

#paintCanvas {
  /*width: 100%; /* Ensure the canvas fills its container * /
            max-width: 500px; /* Limit the maximum size * /
            margin: 0 auto;*/
  width: 100%;
  height: 100%;
  max-height: 90%; /* Limit the height so there's some padding */
  max-width: 90%; /* Limit the width so there's some padding */
  overflow: hidden;
  border: 1px solid black;
  position: relative;
}

.spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute; /* Position spinner over the content */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.7); /* Overlay background */
  z-index: 10; /* Ensure spinner is on top */
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #ccc;
  border-top-color: #337ab7; /* Spinner color */
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

svg {
  /*width: 1500px;
            height: 4200px;*/
  width: 100%; /* Scale SVG to fill the canvas */
  height: 100%; /*auto; /* Maintain aspect ratio */
  display: block; /* Remove inline block gaps */
  /*border: 1px solid #000;*/
  cursor: default;
}

svg.grab {
  cursor: grab; /* Grab cursor when Ctrl is held down */
}

svg.grabbing {
  cursor: grabbing; /* Grabbing cursor when dragging */
}

.help-button {
  background-color: #d3d3d3;
  border: none;
  border-radius: 5px;
  padding: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.help-button:hover {
  background-color: #e0e0e0;
}

.help-button-mobile {
  display: none;
}

/* Cozy Corner Controls */

#uploadButton {
  border: 2px dotted grey;
  border-radius: 10px;
  padding-bottom: 5px;
}

#cozyCornerControls {
  display: flex;
  justify-content: center;
}

#cozyCornerControls button i {
  font-size: 1.15rem;
}

#backgroundControls {
  display: none; /* Hidden by default */
  flex-direction: column;
  position: absolute;
  bottom: 0px;
  right: 0px;
  background-color: #fff;
  padding-top: 10px;
  padding-bottom: 10px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  width: 100%;
}

#backgroundControlsInstructions {
  text-align: center;
  margin-bottom: 10px;
  font-size: 1.25rem;
}

#backgroundControlsButtons {
  display: flex;
}

#backgroundControls button {
  background-color: #4caf50;
  color: white;
  border: none;
  width: 50%;
  padding: 10px;
  border-radius: 5px;
  cursor: pointer;
  margin-left: 5px;
  margin-right: 5px;
  font-size: 1rem;
}

/* Zoom and Pan button styles */
.controls {
  position: absolute;
  bottom: 10px;
  left: 10px;
  /*display: flex;
            flex-direction: column;*/
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 3px;
}

.control-button {
  background-color: #6ec8d0; /* #4caf50;*/
  color: white;
  border: 1px solid white;
  /*margin: 3px;*/
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.control-button:hover {
  background-color: #377d84; /* #45a049;*/
}

/* Zoom buttons styles */
#zoomIn,
#zoomOut {
  grid-column: span 3;
}

.undo-button {
  display: block;
  position: absolute;
  bottom: 10px;
  left: 140px;
}

.undo-button:disabled {
  background-color: #9ee7ed; /* #a5d6a7;*/
}

#printFooter {
  display: none;
}

/* Modal overlay (dark background) */
.modal-overlay {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7); /* Dark semi-transparent background */
  z-index: 1000;
}

/* Modal container */
.modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  width: 80%;
  max-width: 600px;
  height: 60%;
  border-radius: 10px;
  padding: 40px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  z-index: 1001;
}

/* Close button for the modal */
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: #333;
  font-size: 1.5rem;
  cursor: pointer;
}

/* Iframe in the modal - support */
.modal iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Toggle switch container */
.toggle-container {
  margin-top: 10px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-container label {
  font-size: 0.9em;
  color: #333;
  margin-right: 10px; /* Space between label and switch */
  font-weight: 500; /* Slightly bolder text */
  display: block;
}

/* Toggle switch CSS */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.toggle-switch input {
  /*opacity: 0;
        width: 0;
        height: 0;*/
  display: none; /* Hide the checkbox */
}

.slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #4caf50;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

/* Toggle items here are used for the template selector */
.toggle-buttons {
  /* display: flex; */
  border: 2px solid #ccc;
  border-radius: 30px;
  overflow: hidden;
  width: max-content;
}

.toggle-buttons input[type="radio"] {
  display: none; /* Hide the radio buttons */
}

.toggle-button {
  padding: 10px 0px;
  cursor: pointer;
  background-color: #ccc;
  color: #fff;
  border: none;
  transition: background-color 0.3s ease, color 0.3s ease;
  width: 100%;
  /*flex: 1; /* Make the buttons equal in width */
  text-align: center;
}

/* Style for the active button */
input[type="radio"]:checked + .toggle-button {
  background-color: #2196f3; /* Active button color */
  color: white;
}

/* Optional hover effect */
.toggle-button:hover {
  background-color: #bbb;
}

/* Hide the print button on mobile devices */
@media (max-width: 768px) {
  .print-button,
  .controls,
  #eyedropper-button {
    display: none;
  }

  header {
    font-size: 1.3rem;
  }
  .header-buttons {
    gap: 10px;
  }
  .header-button {
    font-size: 1.2rem;
    padding: 7px;
  }

  .header-buttons img {
    width: 40px;
    height: 40px;
  }

  .undo-button {
    bottom: 10px;
    left: 10px;
    font-size: 1.25rem;
  }

  .help-button {
    display: none;
  }

  .help-button-mobile {
    display: block;
    bottom: 10px;
    right: 10px;
    font-size: 1.25rem;
    position: absolute;
    background-color: #6ec8d0; /*#4caf50;*/
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 5px;
    cursor: pointer;
  }

  #backgroundControlsInstructions {
    font-size: 1rem;
  }

  #backgroundControls button {
    font-size: 0.85rem;
  }

  .canvas-section {
    flex-grow: 1;
    height: calc(90dvh - 10dvh); /* Adjust the canvas height */
  }

  .palette-section {
    width: 100%;
    height: 10dvh; /* Take up the bottom 20% of the screen */
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between; /*center;*/
    background-color: #ddd;
    border-top: 1px solid #ccc;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }

  .palette-container {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto; /* Allow scrolling horizontally if there are too many colors */
    -webkit-overflow-scrolling: touch; /* Enable smooth scrolling on iOS */
    width: 80%; /*100%;*/
    justify-content: flex-start;
  }

  .palette-section h3 {
    margin: 0px;
  }

  .palette-container div.swatch,
  #addSwatchButton {
    width: 35px;
    height: 35px;
    margin: 0 5px;
    padding: 2px;
  }

  /* Settings Button */
  .settings-button {
    background-color: #6ec8d0; /* #4caf50;*/
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 5px;
    cursor: pointer;
    margin: 0px 10px;
  }

  .settings-button:hover {
    background-color: #377d84; /* #45a049;*/
  }

  /* Modal overlay */
  .modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
  }

  /* Modal content */
  .modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 400px;
    z-index: 1001;
  }

  .close-button {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 5px 10px;
    font-size: 1.2rem;
    cursor: pointer;
    float: right;
  }

  .close-button:hover {
    background-color: #e53935;
  }

  .modal-content h2 {
    margin-top: 0;
  }

  /* Center the items in the settings modal */
  .toggle-container {
    justify-content: center;
  }
}

/* Print media styles */
@media print {
  /* Hide everything except the svg and extra text */
  body * {
    visibility: hidden;
  }

  /* Ensure only the SVG and extra text is visible */
  #paintCanvas,
  #paintCanvas * {
    visibility: visible;
  }

  /* Hide the control buttons */
  .controls,
  .print-button,
  #undoButton,
  .help-button-mobile {
    display: none;
  }

  /* Center the SVG in the print output */
  #paintCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 100%;
    padding-bottom: 60px; /* Add padding to ensure no overlap with footer */
    border: none;
  }

  svg {
    width: 100%;
    height: auto;
    max-height: 85vh; /* Ensure it fits within the vertical space */
    max-width: 90vw; /* Ensure it fits within the width of the page */
  }

  /* Extra text for print */
  #printFooter {
    display: block;
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 12px;
    color: #555;
    visibility: visible;
  }
}

/* Modal styling */
.color-modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  overflow-y: scroll;
}

.modal-content {
  background-color: white;
  /*margin: 15% auto;*/
  padding: 20px;
  border: 1px solid #888;
  width: 300px;
  position: absolute;
  top: 50%;
  left: 50%;
  height: 60%;
  overflow-y: auto;
  transform: translate(-50%, -50%);
  text-align: center;
}
/* Modal title */
.modal-title {
  font-size: 1.5em;
  font-weight: bold;
  text-align: center;
  margin-bottom: 20px;
  color: #4caf50;
  letter-spacing: 0.05em; /* Slight letter spacing for a polished look */
  margin-top: 0px;
}

/* Optional: Add a subtle underline or border below the title */
.modal-title::after {
  content: "";
  display: block;
  /*width: 50px;*/
  height: 2px;
  background-color: #4caf50; /* Light gray underline */
  margin: 10px auto 0; /* Centered and spaced below the title */
}

/* Section Headers */
.modal-section-header {
  font-size: 1.2em;
  font-weight: bold;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-section-header i {
  margin-right: 10px;
}

/* Section background to lightly differentiate each */
.modal-section {
  border: 2px solid #f9f9f9;
  padding: 15px;
  margin-bottom: 20px;
  border-radius: 8px;
}

.modal-premium-section {
  border: 3px solid #9370db; /* Strong mediumpurple border */
  /*background: linear-gradient(135deg, #ede7f6 60%, #d1c4e9 100%);*/
  background: #d1c4e93b 60%;
  box-shadow: 0 4px 16px rgba(147, 112, 216, 0.25);
  padding: 18px;
  border-radius: 12px;
  position: relative;
  /*animation: premiumPulse 2s 3; /*infinite*/
}

@keyframes premiumPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(147, 112, 216, 0.4);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(30, 27, 36, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(147, 112, 216, 0);
  }
}

/* Subtle dividers between sections */
.modal-divider {
  border: none;
  border-top: 1px solid #ddd; /* Light gray divider */
  margin: 20px 0;
}

.brand-filter {
  display: block;
}

.close {
  color: #aaa;
  float: right;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
}

.color-box {
  display: inline-block;
  width: 30px;
  height: 30px;
  margin: 5px;
  cursor: pointer;
  border: 2px solid #fff;
}

.color-box:hover {
  border-color: #000;
}

.hidden {
  display: none;
}

/* Search input */
#colorSearch {
  width: 80%;
  padding: 5px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Reusable modal, TODO convert everything else to use this eventually */
.reusable-modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}
/* Modal content */
.reusable-modal-content {
  background-color: white;
  margin: 15% auto;
  padding: 20px;
  border: 1px solid #888;
  border-radius: 10px;
  width: 325px;
  text-align: center;
  max-height: 60dvh;
  overflow-y: auto;
}
.reusable-modal-content ul {
  text-align: left;
}
/* Styles for the modal buttons */
.reusable-modal-button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  font-size: 15px;
  cursor: pointer;
  margin: 10px;
  transition: background-color 0.3s ease;
}

/* Affirmative button (e.g., "Yes", "Confirm") */
.reusable-modal-button-affirmative {
  background-color: #4caf50; /* Green */
  color: white;
}

.reusable-modal-button-affirmative:hover {
  background-color: #45a049;
}

/* Negative button (e.g., "No", "Cancel") */
.reusable-modal-button-negative {
  background-color: #e57373; /* Red */
  color: white;
}

.reusable-modal-button-negative:hover {
  background-color: #d32f2f;
}

/* Close button */
.reusable-close-btn {
  color: red;
  float: right;
  font-size: 28px;
  font-weight: bold;
}
.reusable-close-btn:hover,
.reusable-close-btn:focus {
  color: darkred;
  text-decoration: none;
  cursor: pointer;
}

#themePromptInput {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 16px;
}

.color-swatch {
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-right: 8px;
  border: 1px solid #000;
  vertical-align: middle;
}

/* Pattern modal specific styles */
.pattern-modal {
  display: none; /* Modal is hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Dimmed background */
}

.pattern-modal-content {
  background-color: #fff;
  margin: 15% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 600px;
  max-height: 70%;
  overflow-y: auto;

  border-radius: 20px;
}

.pattern-modal-content h2 {
  margin-top: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

div#materialSelection {
  display: flex;
  flex-direction: column;
  align-items: center;
}

div#patternForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-svg {
  width: 100%;
  margin: 16px 0;
  border: 3px solid black;
  border-radius: 5px;
}

/* Close button style */
.pattern-modal-close {
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.pattern-modal-close:hover,
.pattern-modal-close:focus {
  color: red;
  text-decoration: none;
}

.premium-cta {
  background: linear-gradient(135deg, #4caf50, #43a047);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, background 0.3s;
}

.premium-cta:hover {
  transform: scale(1.05);
  background: linear-gradient(135deg, #43a047, #388e3c);
}

.premium-cta:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.cta-subtext {
  display: block;
  font-size: 0.75em;
  margin-top: 4px;
  color: #e8f5e9; /* Light green to blend with theme */
  opacity: 0.9;
}

.premium-cta .icon {
  font-size: 1.2em;
}

.premium-cta .pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
  }
  70% {
    box-shadow: 0 0 0 20px rgba(76, 175, 80, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
  }
}
