/* Reset some defaults */
body,
h1,
h2,
ul,
li,
button,
p {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

body {
  font-family: sans-serif;
  display: flex;
  flex-direction: column;
  /* Ensure body takes full height */
  min-height: 100vh;
  /* Ensure footer (if any) stays down */
}

.app-header {
  background-color: #f8f9fa;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #dee2e6;
  position: relative;
  /* Needed for absolute positioning of mobile menu */
}

.app-header h1 {
  font-size: 1.5rem;
}

.menu-toggle {
  display: none;
  /* Hidden by default on larger screens */
  font-size: 1.8rem;
  background: none;
  border: none;
  cursor: pointer;
}

.main-nav ul {
  list-style: none;
  display: flex;
  gap: 15px;
}

.main-nav .nav-button {
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.main-nav .nav-button:hover {
  background-color: #e9ecef;
}

.main-nav .nav-button.active {
  background-color: #007bff;
  color: white;
  font-weight: bold;
}

main {
  flex-grow: 1;
  /* Allow main content to fill available space */
  padding: 20px;
  display: flex;
  /* Use flex for content alignment */
  flex-direction: column;
  align-items: center;
  /* Center tool content */
}

.tool-content {
  display: none;
  /* Hide tools by default */
  width: 100%;
  /* Take full width of main */
  max-width: 800px;
  /* Optional: constrain max width */
  flex-direction: column;
  align-items: center;
}

.tool-content.active {
  display: flex;
  /* Show active tool using flex */
}

.tool-content h2 {
  margin-bottom: 20px;
  text-align: center;
}

/* --- Existing Framer Styles --- */

.settings-container {
  flex-direction: column;
  align-items: center;
  padding: 20px;
  /* padding: 20px; Duplicated line removed */
}

.settings-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
  width: 80%;
  max-width: 500px;
}

.setting {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}

.setting label {
  margin-right: 10px;
  min-width: 100px;
  /* Align selects/inputs */
  text-align: right;
}

.setting select,
.setting input[type="file"] {
  padding: 5px;
}

#imageCanvas {
  margin-top: 10px;
  /* Reduced margin */
  /* border: 10px solid white; /* Frame is now drawn on canvas */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  /* Optional: add a subtle shadow */
  max-width: 90%;
  height: auto;
  /* Maintain aspect ratio */
  display: none;
  /* Hide initially */
  cursor: grab;
  /* Indicate draggable */
}

#imageCanvas.dragging {
  cursor: grabbing;
  /* Indicate dragging */
}

.controls {
  margin-top: 20px;
  display: none;
  /* Hidden until image is processed */
  width: 80%;
  max-width: 500px;
  /* Limit width of controls */
  text-align: center;
}

.slider-container {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slider-container label {
  margin-right: 10px;
}

.slider-container input[type="range"] {
  flex-grow: 1;
  margin: 0 10px;
}

#downloadLink {
  /* display: none; /* Now controlled by parent .controls */
  margin-top: 20px;
  padding: 10px 20px;
  background-color: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  cursor: pointer;
}

#downloadLink:hover {
  background-color: #0056b3;
}

/* --- Grid Tool Styles --- */

.grid-settings-container {
  display: flex;
  flex-wrap: wrap;
  /* Allow wrapping on smaller screens */
  justify-content: center;
  gap: 15px;
  /* Spacing between settings */
  margin-bottom: 20px;
  width: 100%;
  max-width: 600px;
  /* Adjust as needed */
}

/* Inherit .setting styles */
.grid-settings-container .setting {
  margin-bottom: 0;
  /* Remove bottom margin as gap is used */
}

.grid-inputs-container {
  display: flex;
  flex-direction: column;
  /* Default layout for inputs */
  gap: 15px;
  margin-bottom: 20px;
  width: 100%;
  max-width: 500px;
  /* Adjust as needed */
  align-items: center;
  /* Center input slots */
}

.grid-input-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 100%;
  /* Take full width of container */
}

.grid-input-slot label {
  min-width: 60px;
  /* Adjust label width */
  text-align: right;
}

.grid-input-slot input[type="file"] {
  flex-grow: 1;
  /* Allow input to take remaining space */
}

#gridPreviewCanvas {
  margin-top: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  height: auto;
  display: none;
  /* Hide initially until settings are chosen/images loaded */
  background-color: #eee;
  /* Placeholder background */
  border: 1px solid #ccc;
  cursor: default;
  /* Default cursor */
}

#gridPreviewCanvas.draggable {
  cursor: grab;
  /* Indicate draggable possible */
}

#gridPreviewCanvas.dragging {
  cursor: grabbing;
  /* Indicate dragging active */
}


.grid-controls {
  margin-top: 20px;
  text-align: center;
}

/* Use a common class for download buttons if desired */
.download-button {
  padding: 10px 20px;
  background-color: #28a745;
  /* Green color for download */
  color: white;
  text-decoration: none;
  border-radius: 5px;
  cursor: pointer;
  border: none;
  /* Reset button border */
  font-size: inherit;
  /* Inherit font size */
}

.download-button:hover {
  background-color: #218838;
}


/* --- Responsive Menu --- */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
    /* Show hamburger */
  }

  .main-nav {
    display: none;
    /* Hide nav by default */
    position: absolute;
    top: 100%;
    /* Position below header */
    left: 0;
    right: 0;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    z-index: 1000;
  }

  .main-nav.open {
    display: block;
    /* Show nav when open */
  }

  .main-nav ul {
    flex-direction: column;
    padding: 10px 0;
    gap: 0;
  }

  .main-nav li {
    width: 100%;
  }

  .main-nav .nav-button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 20px;
    border-radius: 0;
  }

  .main-nav .nav-button.active {
    background-color: #007bff;
    color: white;
  }

  .main-nav .nav-button:hover:not(.active) {
    background-color: #e9ecef;
  }
}