/* --- Global Setup --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", sans-serif;
  background-color: #0d1117;
  color: #e6edf3;
  text-align: center;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column; 
  justify-content: flex-start; 
  align-items: center; 
  padding: 2rem;
}

/* --- Back Button Container --- */
.back-link-container {
  width: 100%;
  max-width: 1200px; /* Match generator-container */
  text-align: left;
  margin-bottom: 1rem;
  padding: 0 2rem; /* Match generator-container padding */
}

/* --- Home Page: Header & Footer --- */
header {
  padding: 3rem 1rem;
  background: linear-gradient(135deg, #0077b6, #00b4d8);
  color: white;
}

footer {
  margin-top: 3rem;
  padding: 1rem;
  font-size: 0.9rem;
  color: #aaa;
}

/* --- Home Page: Generator Cards --- */
#generators {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 3rem;
  flex-wrap: wrap;
}

.card {
  background: #161b22;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  width: 300px;
  padding: 1.5rem;
  transition: transform 0.2s;
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 480px;
}

.card img {
  width: 100%;
  border-radius: 8px;
}

.card h2 {
  margin: 1rem 0 0.5rem 0;
}

.card p {
  font-size: 0.95rem;
  color: #ccc;
}

.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.7rem 1.5rem;
  background: #00b4d8;
  color: white;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.3s;
}

.btn:hover {
  background: #0096c7;
}


/* --- Generator Page Layout --- */
.generator-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  padding: 2rem;
  flex-wrap: wrap;
  width: 100%;
  max-width: 1200px;
  margin: 0; 
}

.left-panel {
  flex: 1 1 45%;
  background: #161b22;
  padding: 1.5rem;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  min-width: 350px;
  height: 650px;
  overflow-y: auto;
}

.right-panel {
  flex: 1 1 45%;
  background: #161b22;
  padding: 1.5rem;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  text-align: center;
  min-width: 350px;
  height: 650px;
  overflow-y: hidden; /* Changed from auto */
}

/* --- Generator: Right Panel Grid --- */
.right-grid {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sub-panel {
  text-align: left; 
}
.sub-panel:first-child {
  flex: 1; /* Grow to fill space */
  display: flex; /* Added */
  flex-direction: column; /* Added */
  min-height: 0; /* Prevents overflow */
}

/* --- Generator: Form Elements --- */
#wingForm {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

fieldset {
  border: 1px solid #333;
  margin-bottom: 0; 
  padding: 1rem;
  border-radius: 6px;
  text-align: left;
}

legend {
  font-weight: bold;
  color: #00b4d8;
  padding: 0 0.5rem;
}

label {
  display: block;
  margin-top: 0.7rem;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem;
  border: 1px solid #333;
  border-radius: 5px;
  background-color: #0d1117;
  color: #e6edf3;
}

/* --- Generator: Number Input Spinners (Updated) --- */
/* Hide spinners by default */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield; /* Firefox */
  appearance: textfield;
}

/* Optional .no-spin class */
input[type=number].no-spin {
  appearance: textfield;
  -moz-appearance: textfield; /* per Firefox */
  -webkit-appearance: none;   /* per Safari e Chrome */
}

/* Show spinners ONLY for ribCount */
#ribCount::-webkit-inner-spin-button,
#ribCount::-webkit-outer-spin-button {
  -webkit-appearance: auto;
  margin: 0;
}
#ribCount {
  appearance: auto; 
  -moz-appearance: revert; 
}


/* --- Generator: Preview & Export Sections --- */
#preview-box {
  flex: 1; /* Grow to fill sub-panel */
  height: auto; /* Removed fixed 400px height */
  background: #11161c;
  border-radius: 8px;
  border: 1px dashed #444;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: #777;
  font-style: italic;
}

#export-options {
  margin-top: 20px;
  padding: 15px;
  background-color: #11161c;
  border-radius: 10px;
  border: 1px solid #333;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.export-format {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.export-format span {
  color: #eee;
  font-size: 1rem;
  font-weight: 500;
}

.export-format select {
  background-color: #1e2329;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.95rem;
  width: 40%;
}

.export-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  margin-top: 5px;
}

.export-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ccc;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
}

.export-checkbox input[type="checkbox"] {
  accent-color: #00b4d8;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

#download-btn {
  background: linear-gradient(135deg, #007acc, #00b4d8);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 28px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 180, 216, 0.2);
}

#download-btn:hover {
  background: linear-gradient(135deg, #0094ff, #00d4ff);
  box-shadow: 0 0 12px rgba(0, 180, 216, 0.6);
}

/* --- Responsive (Generator Page) --- */
@media (max-width: 900px) {
  .back-link-container {
    padding: 0; /* Adjust padding */
  }
  
  .generator-container {
    flex-direction: column;
    align-items: center;
    padding: 0; /* Adjust padding */
  }

  .left-panel,
  .right-panel {
    max-width: 90%;
    height: auto; /* Allow height to adjust */
  }

  #wingForm {
    grid-template-columns: 1fr; /* Stack on small screens */
  }
  
  /* Restore preview box height on mobile */
  #preview-box {
      height: 400px; 
  }
}
#preview-box canvas {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: block;
}
