/* Color Palette */
:root {
    --color-terracotta: #E07A5F;
    --color-sage: #81B29A;
    --color-sand: #F2CC8F;
    --color-navy: #3D405B;
    --color-cream: #F4F1DE;
    --color-error: #E07A5F;
    --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Base Styles */
body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--color-cream);
  color: var(--color-navy);
  line-height: 1.6;
}

/* Header */
header {
    background: url('assets/background-875120.jpg') no-repeat center center;
    background-size: cover;
    color: var(--color-cream);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-soft);
    position: relative;
    font-family: 'Pacifico', cursive;
}

header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5); /* Dark overlay for better text visibility */
    z-index: 1;
}

header h1 {
    position: relative;
    z-index: 2;
    margin: 0;
    font-family: 'Dancing Script', cursive;
    font-size: 4rem;
    font-weight: 700;
    
    background: linear-gradient(45deg, #ff9a9e, #fad0c4);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    border: 2px solid var(--color-cream);
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

/* Instructions */
#instructions {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 2rem;
  background-color: white;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

/* Layout */
#container {
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 2rem;
  background: url('assets/neule-888375_1920.png') no-repeat center center;
  background-size: cover;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

/* Ensure content within the container is readable */
#container > * {
  background: rgba(255, 255, 255, 0.8); /* Semi-transparent white background */
  padding: 2rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  margin-top: 2rem;
}

#main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
}

/* Controls Section */
#controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 2rem;
}

/* Controls */
#controls {
  display: flex;
  justify-content: space-between; /* Adds space between the two sections */
  align-items: flex-start; /* Aligns items at the top */
  gap: 20px; /* Adds space between sections */
}

#swatch-calculator, #color-inputs-section {
  flex: 1; /* Ensures both sections take equal width */
  padding: 20px;
  border: 1px solid #ccc; /* Optional: Adds a border for clarity */
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1); /* Optional: Adds a subtle shadow */
  background-color: #f9f9f9; /* Optional: Background color for distinction */
}

@media (max-width: 768px) {
  #controls {
      flex-direction: column; /* Stacks sections on smaller screens */
  }

  #swatch-calculator, #color-inputs-section {
      flex: unset; /* Resets flex property */
      width: 100%; /* Makes each section full width */
  }
}

#add-color-btn {
    cursor: pointer;
    background: linear-gradient(45deg, var(--color-navy), var(--color-sage));
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    width: 100%;
    font-size: 1rem;
    transition: background-color 0.3s ease;
    margin-bottom: 1rem;
}

#add-color-btn:hover {
    background-color: #729e87;
}

.color-input-group {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: var(--color-cream);
    border-radius: 8px;
}

.color-picker {
    cursor: pointer;
    width: 50px;
    height: 50px;
    padding: 0;
    border: none;
    border-radius: 8px;
}

.stitches-input {
    flex: 1;
    width: 100%;
    padding: 0.8rem;
    margin: 0.5rem 0;
    border: none;
    border-bottom: 2px solid var(--color-sage);
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px 8px 0 0;
    font-size: 1rem;
    color: var(--color-navy);
    outline: none;
    transition: all 0.3s ease;
}

.stitches-input:focus {
    border-bottom-color: var(--color-terracotta);
    background-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stitches-input::placeholder {
    color: var(--color-navy);
    opacity: 0.5;
}

#stitches-across-input {
    flex: 1;
    width: 100%;
    padding: 0.8rem;
    margin: 0.5rem 0;
    border: none;
    border-bottom: 2px solid var(--color-sage);
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px 8px 0 0;
    font-size: 1rem;
    color: var(--color-navy);
    outline: none;
    transition: all 0.3s ease;
}

#stitches-across-input:focus {
    border-bottom-color: var(--color-terracotta);
    background-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#stitches-across-input::placeholder {
    color: var(--color-navy);
    opacity: 0.5;
}

.remove-color-btn {
    cursor: pointer;
    background: linear-gradient(45deg, var(--color-error), #ff6b6b);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    font-size: 0.9rem;
}

.remove-color-btn:hover {
    background-color: #c86a51;
}

/* Grid */
#live-grid {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    margin-top: 2rem;
}

#grid {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    display: grid;
    gap: 1px;
    margin-top: 20px;
    width: 100%; /* Ensure it spans the full width */
    height: auto;
    box-sizing: border-box;
}

.grid-square {
    border: 1px solid rgba(0, 0, 0, 0.1);
    width: 100%;
    height: 100%; /* Ensure height matches width for a perfect square */
    padding-bottom: 100%; /* Maintain aspect ratio */
    box-sizing: border-box;
    overflow: hidden;
    max-width: 20px; /* Limit the maximum size of each square */
    max-height: 20px; /* Limit the maximum size of each square */
}

/* Handle responsiveness by adjusting max-width and max-height for smaller screens */
@media (max-width: 600px) {
  .grid-square {
      max-width: 10px; /* Smaller square size for smaller screens */
      max-height: 10px;
  }
}

#save-grid-btn {
    cursor: pointer;
    background: linear-gradient(45deg, var(--color-sage), var(--color-terracotta));
    color: white;
    border: none;
    border-radius: 25px;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 1rem;
}

#save-grid-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background: linear-gradient(45deg, var(--color-terracotta), var(--color-sage));
}

/* Swatch Calculator */
#swatch-calculator {
    background-color: var(--color-cream);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    height: 100%;
}

#swatch-calculator h3 {
    margin-top: 0;
    color: var(--color-navy);
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-navy);
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#calculation-results {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
}

#calculation-results p {
    margin: 0.5rem 0;
}

/* Color Picker Section */
#color-picker-section {
    background-color: var(--color-cream);
    padding: 1.5rem;
    border-radius: 8px;
}

/* Color Picker Container */
#color-inputs-section {
    background-color: var(--color-cream);
    padding: 1.5rem;
    border-radius: 8px;
    height: 100%;
}

/* Info Sections */
#info-sections {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 2rem auto;
    align-items: stretch; /* Ensure equal height */
}

#instructions, #how-to-use {
    flex: 1;
    padding: 2rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    height: 200px; /* Reduced height */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#instructions h2, #how-to-use h2 {
    color: var(--color-navy);
    margin-top: 0;
    position: sticky;
    top: 0;
    background: white;
    padding: 1rem 0;
    z-index: 1;
}

#toggle-info-btn, #toggle-instructions-btn {
    background: linear-gradient(45deg, var(--color-sage), var(--color-terracotta));
    color: white;
    border: none;
    border-radius: 25px;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

#toggle-info-btn:hover, #toggle-instructions-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background: linear-gradient(45deg, var(--color-terracotta), var(--color-sage));
}

@media (max-width: 768px) {
    #info-sections {
        flex-direction: column;
    }

    #instructions, #how-to-use {
        height: auto;
        max-height: 200px;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    #main-content {
        grid-template-columns: 1fr;
    }

    #instructions, #controls, #live-grid {
        margin: 1rem;
    }

    #controls {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    #container {
        padding: 1rem;
    }
}

/* Button Styles */
button {
    background: linear-gradient(45deg, var(--color-sage), var(--color-terracotta));
    color: white;
    border: none;
    border-radius: 25px;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background: linear-gradient(45deg, var(--color-terracotta), var(--color-sage));
}

#stitches-across {
    display: grid;
    grid-template-columns: 200px 200px;
}