body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 20px 0;
    direction: rtl; /* RTL support */
    text-align: right;
}

.container {
    max-width: 900px;
    margin: 20px auto;
    padding: 30px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

h1, h2, h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: 700;
}

h1 {
    text-align: center;
    font-size: 2.5em;
    color: #007bff; /* Primary color */
}

.description {
    text-align: center;
    color: #555;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.card {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}

.prompt-section textarea {
    width: calc(100% - 20px);
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    resize: vertical;
    min-height: 80px;
    box-sizing: border-box;
    font-family: 'Vazirmatn', sans-serif;
    color: #444;
}

.prompt-tips {
    margin-top: 10px;
    color: #777;
    font-size: 0.9em;
}

.parameters-section {
    margin-top: 30px;
}

.param-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px; /* Space between items */
    align-items: flex-start; /* Align items to the start for better vertical alignment */
}

.param-group h3 {
    width: 100%;
    margin-bottom: 15px;
    color: #34495e;
    font-size: 1.3em;
    display: flex;
    align-items: center;
}

.param-group h3 i {
    margin-left: 10px; /* Adjust for RTL */
    color: #007bff;
}

.param-item {
    flex: 1 1 calc(33% - 20px); /* 3 items per row with gap, adjust for smaller screens */
    min-width: 250px; /* Minimum width for each item */
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.param-item label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
    font-size: 0.95em;
}

.param-item input[type="text"],
.param-item input[type="number"],
.param-item select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.95em;
    background-color: #fff;
    box-sizing: border-box;
}

.param-item input[type="range"] {
    width: calc(100% - 50px); /* Adjust for value display */
    -webkit-appearance: none; /* Remove default styling for Chrome/Safari */
    appearance: none;
    height: 8px;
    background: #d3d3d3;
    outline: none;
    opacity: 0.7;
    -webkit-transition: .2s;
    transition: opacity .2s;
    border-radius: 5px;
    margin-top: 5px;
    margin-left: 10px; /* Adjust for RTL */
}

.param-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.param-item input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.param-item span[id$="Value"] {
    display: inline-block;
    width: 40px;
    text-align: center;
    margin-top: 5px;
    font-weight: 600;
    color: #007bff;
}

.switch-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 45px;
    height: 25px;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 25px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 17px;
    width: 17px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #007bff;
}

input:focus + .slider {
    box-shadow: 0 0 1px #007bff;
}

input:checked + .slider:before {
    -webkit-transform: translateX(-20px); /* Adjust for RTL */
    -ms-transform: translateX(-20px);
    transform: translateX(-20px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 25px;
}

.slider.round:before {
    border-radius: 50%;
}

.generate-button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 15px 25px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-top: 30px;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
}

.generate-button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.generate-button:active {
    transform: translateY(0);
}

.generate-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid white;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin-right: 10px; /* Adjust for RTL */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-message, .error-message {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
}

.loading-message {
    background-color: #e7f3ff;
    color: #007bff;
    border: 1px solid #b3d9ff;
}

.error-message {
    background-color: #ffe7e7;
    color: #dc3545;
    border: 1px solid #ffb3b3;
}

.image-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 40px;
}

.image-results img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.image-results img:hover {
    transform: scale(1.03);
}

footer {
    text-align: center;
    margin-top: 50px;
    color: #777;
    font-size: 0.9em;
    padding-bottom: 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 20px;
    }
    h1 {
        font-size: 2em;
    }
    .param-item {
        flex: 1 1 100%; /* Stack items on small screens */
        min-width: unset;
    }
    .param-item input[type="range"] {
        width: calc(100% - 60px); /* Adjust for smaller screens */
    }
    input:checked + .slider:before {
        -webkit-transform: translateX(-18px); /* Adjust for RTL on small screens */
        -ms-transform: translateX(-18px);
        transform: translateX(-18px);
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }
    .description {
        font-size: 1em;
    }
    .generate-button {
        font-size: 1.1em;
        padding: 12px 20px;
    }
}