* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --background-color: #f5f8f3;
    --text-color: #2c3e50;
    --primary-color: #2e7d32;
    --primary-hover-color: #1b5e20;
    --input-border-color: #a5d6a7;
    --panel-background: #e8f5e9;
    --container-shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --background-color: #1a2027;
    --text-color: #e0e0e0;
    --primary-color: #4caf50;
    --primary-hover-color: #388e3c;
    --input-border-color: #4caf50; 
    --panel-background: #263238;
    --container-shadow: rgba(0, 0, 0, 0.3);

    --choices-background: #263238; 
    --choices-text-color: #e0e0e0;
    --choices-border-color: #4caf50; 
    --choices-item-bg: #37474f; 
    --choices-item-border: #546e7a; 
    --choices-item-text: #e0e0e0;
    --choices-highlight-bg: var(--primary-color); 
    --choices-highlight-text: #ffffff;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.prompt-section {
    display: flex;
    flex-direction: column;
    margin-bottom: 2rem;
    gap: 1rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
}

#prompt-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--input-border-color);
    border-radius: 4px;
    font-size: 1rem;
    background-color: var(--background-color);
    color: var(--text-color);
}

#generate-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

#generate-btn:hover {
    background-color: var(--primary-hover-color);
}

.output-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#result-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#image-container {
    width: 100%;
    max-width: 500px;
    box-shadow: 0 4px 12px var(--container-shadow);
    border-radius: 8px;
    overflow: hidden;
}

#image-container img {
    width: 100%;
    height: auto;
    display: block;
}

#plant-name {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
}

#plant-description {
    font-size: 1.1rem;
    line-height: 1.6;
    text-align: center;
    max-width: 600px;
}

.hidden {
    display: none !important;
}

/* Customization panel styles */
#customization-panel {
    background-color: var(--panel-background);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.customization-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-group label {
    font-weight: bold;
    color: var(--primary-color);
}

.option-group select, 
.option-group input[type="number"] {
    padding: 0.5rem;
    border: 1px solid var(--input-border-color);
    border-radius: 4px;
    background-color: var(--background-color);
    color: var(--text-color);
}

/* Loading animation */
.spinner {
    width: 50px;
    height: 50px;
    animation: rotate 2s linear infinite;
}

.path {
    stroke: var(--primary-color);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* Word count slider styles */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.slider-container label {
    font-weight: bold;
    color: var(--primary-color);
    display: flex;
    justify-content: space-between;
}

.slider-container span {
    font-weight: normal;
    color: #555;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

/* Advanced options toggle */
.advanced-toggle {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: bold;
    cursor: pointer;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.advanced-toggle svg {
    margin-left: 5px;
    transition: transform 0.3s ease;
}

.advanced-toggle.open svg {
    transform: rotate(180deg);
}

.advanced-options {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.advanced-options.open {
    max-height: 1000px;
}

/* Theme toggle switch */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    position: absolute;
    top: 20px;
    right: 20px;
}

.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 50px;
}

.theme-switch input {
    display: none;
}

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

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

input:checked + .slider {
    background-color: var(--primary-color);
}

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

.theme-switch-wrapper .icon {
    margin: 0 5px;
}

.moon-icon, .sun-icon {
    width: 16px;
    height: 16px;
}

@media (max-width: 768px) {
    .theme-switch-wrapper {
        position: relative;
        top: 0;
        right: 0;
        justify-content: flex-end;
        margin-bottom: 10px;
    }
}

/* Multi-select styling for Choices.js */
.choices__inner {
    border: 1px solid var(--input-border-color);
    background-color: var(--background-color);
    color: var(--text-color);
    border-radius: 4px;
    padding: 0.5rem;
    min-height: auto; 
}

.choices__list--dropdown,
.choices__list[aria-expanded] {
    background-color: var(--panel-background);
    border: 1px solid var(--input-border-color);
    box-shadow: 0 2px 8px var(--container-shadow);
    color: var(--text-color); 
}

.choices__list--dropdown .choices__item--selectable.is-highlighted,
.choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
     background-color: var(--primary-hover-color); 
     color: #ffffff; 
}

.choices__list--multiple .choices__item {
    background-color: var(--panel-background);
    color: var(--text-color);
    border: 1px solid var(--input-border-color);
    margin: 2px 2px 0 0; 
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.choices__list--multiple .choices__item .choices__button {
    filter: invert(80%); 
    border-left: 1px solid var(--input-border-color); 
    margin-left: 5px;
    padding-left: 5px;
}

.choices__input {
    background-color: var(--background-color); 
    color: var(--text-color);
}

/* Dark Mode Specific Styles for Choices.js */
[data-theme="dark"] .choices__inner {
    background-color: var(--choices-background);
    border-color: var(--choices-border-color);
    color: var(--choices-text-color);
}

[data-theme="dark"] .choices__list--dropdown,
[data-theme="dark"] .choices__list[aria-expanded] {
    background-color: var(--choices-background);
    border-color: var(--choices-border-color);
    color: var(--choices-text-color);
}

[data-theme="dark"] .choices__list--dropdown .choices__item--selectable,
[data-theme="dark"] .choices__list[aria-expanded] .choices__item--selectable {
    color: var(--choices-text-color); 
}

[data-theme="dark"] .choices__list--dropdown .choices__item--selectable.is-highlighted,
[data-theme="dark"] .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
     background-color: var(--choices-highlight-bg);
     color: var(--choices-highlight-text);
}

[data-theme="dark"] .choices__list--multiple .choices__item {
    background-color: var(--choices-item-bg);
    border: 1px solid var(--choices-item-border);
    color: var(--choices-item-text);
}

[data-theme="dark"] .choices__list--multiple .choices__item .choices__button {
    filter: none; 
    border-left: 1px solid var(--choices-item-border);
    background-image: url('data:image/svg+xml;utf8,<svg width="10" height="10" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><path stroke="%23e0e0e0" stroke-width="1.5" d="M1 1l8 8m0-8L1 9"/></svg>'); 
}

[data-theme="dark"] .choices__list--multiple .choices__item .choices__button:hover,
[data-theme="dark"] .choices__list--multiple .choices__item .choices__button:focus {
    background-color: #c0392b; 
}

[data-theme="dark"] .choices__input {
    background-color: var(--choices-background); 
    color: var(--choices-text-color);
}

[data-theme="dark"] .choices__input::placeholder {
  color: #a0a0a0; 
}