:root {
    --background-color: #1a1a2e;
    --container-bg: #2a2a4a;
    --text-color: #e0e0e0;
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --border-color: #4a4a6e;
    --error-bg: #4a1c2d;
    --error-text: #ff9999;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --input-bg: #3a3a5e;
    --input-border: #5a5a7e;
    --disabled-bg: #4a4a4a;
    --disabled-text: #999999;
    --notification-bg: #d9534f;
    --notification-text: white;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0; 
    box-sizing: border-box;
    color: var(--text-color);
    line-height: 1.6;
    position: relative;
    overflow-y: auto;
}

.main-content-wrapper {
    display: flex;
    gap: 30px; 
    max-width: 1200px;
    width: 100%;
    justify-content: center;
    align-items: stretch;
    transition: max-width 0.5s ease-out, flex-direction 0.5s ease-out, gap 0.5s ease-out;
    padding: 30px; 
    box-sizing: border-box; 
    flex-shrink: 0;
}

.container {
    background-color: var(--container-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 30px var(--shadow-color);
    text-align: center;
    flex-shrink: 0; 
    width: 480px;
    height: 650px;
    flex: none; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1; 
    width: 100%; 
    justify-content: flex-start; 
    align-items: center; 
}

.image-panel {
    background-color: var(--container-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 30px var(--shadow-color);
    display: flex;
    flex-direction: column;
    justify-content: center; 
    align-items: center; 
    text-align: center;
    width: 480px; 
    height: 650px; 
    flex: none; 
}

.container h1 {
    margin-bottom: 20px; 
}

.container p:first-of-type { 
    margin-bottom: 20px;
}

textarea {
    width: calc(100% - 24px); 
    padding: 12px;
    margin-bottom: 25px; 
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 1.1em;
    resize: vertical;
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    min-height: 100px;
    flex-grow: 0; 
}

textarea::placeholder {
    color: #a0a0c0;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 20px;
    margin-bottom: 30px;
    text-align: left;
    width: 100%; 
}

.option-item {
    display: flex;
    flex-direction: column;
}

.option-item label {
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 1.1em;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 5px;
    justify-content: flex-start; 
}

.radio-group label {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: normal;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    margin-bottom: 0;
    flex-grow: 0; 
    color: var(--text-color);
    background-color: var(--input-bg);
}

.radio-group #aspectRatioSelect label[value="1:1"],
.radio-group #aspectRatioSelect label[value="2:3"],
.radio-group #aspectRatioSelect label[value="3:4"],
.radio-group #aspectRatioSelect label[value="9:16"] {
    width: 65px; 
    height: 45px; 
}

.radio-group #aspectRatioSelect label[value="16:9"],
.model-radio-group label {
    flex-grow: 1; 
    width: auto; 
    height: auto; 
}

.radio-group label:hover {
    background-color: #3a3a6a; 
    border-color: var(--primary-color);
}

.radio-group input[type="radio"] {
    display: none;
}

.radio-group input[type="radio"]:checked + span {
    color: white; 
    font-weight: 600;
}

.radio-group label.selected {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white; 
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5); 
}
.radio-group label.selected span {
    color: white; 
}


button {
    background-color: var(--primary-color);
    color: white;
    padding: 14px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    margin-top: 15px; 
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    width: 100%; 
}

button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

button:disabled {
    background-color: var(--disabled-bg);
    color: var(--disabled-text);
    cursor: not-allowed;
    opacity: 0.8;
    box-shadow: none;
    transform: none;
}

.error-message {
    background-color: var(--error-bg);
    color: var(--error-text);
    border: 1px solid #a00; 
    padding: 15px;
    border-radius: 8px;
    margin-top: 25px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    z-index: 1000;
    position: relative;
    font-size: 1em;
    width: calc(100% - 30px); 
}

.error-message button {
    background: none;
    border: 1px solid var(--error-text); 
    color: var(--error-text);
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    margin-left: 15px;
    pointer-events: auto !important; 
    transition: background-color 0.2s ease, color 0.2s ease;
    box-shadow: none; 
    transform: none; 
}

.error-message button:hover {
    background-color: var(--error-text);
    color: var(--error-bg); 
}

#loading {
    margin-top: 30px;
    font-style: italic;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-size: 1.2em;
    font-weight: 400;
}

.loader {
    border: 4px solid var(--input-bg); 
    border-top: 4px solid var(--primary-color); 
    border-radius: 50%;
    width: 30px; 
    height: 30px;
    animation: spin 1s linear infinite;
}

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

.info-messages {
    margin-top: 20px;
    min-height: 25px; 
    color: var(--text-color);
    font-size: 1em;
    display: flex;
    justify-content: center;
    gap: 20px;
    font-weight: 400;
    margin-top: auto; 
}

.time-info {
    font-weight: 600;
    color: white; 
}


.image-container {
    margin-top: 35px; 
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background-color: var(--input-bg); 
    min-height: 250px; 
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px var(--shadow-color); 
    padding: 5px; 
    width: 100%; 
    height: 100%; 
}

.image-panel > .image-container {
    margin-top: 0;
}

#generatedImage {
    max-width: 100%;
    max-height: 100%; 
    width: auto; 
    height: auto; 
    display: block;
    border-radius: 8px; 
    object-fit: contain; 
}

.hidden {
    display: none !important; 
}

@media (min-width: 1025px) {
    body {
        justify-content: center;
    }

    .main-content-wrapper {
        flex-direction: row; 
        gap: 30px;
        align-items: stretch; 
        margin-top: 0;
        margin-bottom: 0;
    }

    .mobile-only {
        display: none !important; 
    }

    .image-panel {
        justify-content: center;
    }

    .app-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%; 
        padding: 10px 30px;
        box-sizing: border-box;
        margin-top: 0;
        z-index: 10;
    }
}

@media (max-width: 1024px) {
    body {
        justify-content: flex-start; 
        align-items: flex-start; 
    }
    .main-content-wrapper { 
        flex-direction: column; 
        gap: 20px;
        align-items: center;
        max-width: 600px;
        margin-top: 0; 
        margin-bottom: 0;
    }

    .container, .image-panel {
        width: 100%; 
        height: auto; 
        padding: 30px;
        flex: unset; 
        min-height: auto; 
    }

    .container h1 {
        padding-bottom: 40px;
        margin-bottom: 0;
    }

    .container p:first-of-type {
        padding-top: 0px;
        margin-top: 0px;
        margin-bottom: 10px;
    }

    textarea { 
        width: calc(100% - 24px);
        padding: 12px;
        margin-bottom: 25px;
        border: 1px solid var(--input-border);
        border-radius: 8px;
        font-size: 1.1em;
        resize: vertical;
        background-color: var(--input-bg);
        color: var(--text-color);
        transition: border-color 0.3s ease, box-shadow 0.3s ease;
        min-height: 100px;
        flex-grow: 0; 
    }

    .controls-wrapper {
        flex-grow: unset;
        width: 100%;
        justify-content: flex-start; 
        align-items: flex-start; 
    }
    
    .container > h1,
    .container > p,
    .container .options-grid, 
    .container button, 
    .container .error-message, 
    .container .info-messages { 
        margin-bottom: initial; 
        margin-top: initial; 
        width: 100%;
    }
    .container button {
        margin-top: 25px; 
    }
    .container .info-messages {
        margin-top: 15px; 
    }

    .radio-group label {
        flex-grow: 1; 
        width: auto; 
        height: auto; 
    }

    .desktop-only {
        display: none !important; 
    }
    .mobile-only {
        order: -1; 
        margin-bottom: 20px; 
        font-size: 1.1em;
    }

    .image-panel #loading {
        order: -1;
        margin-top: 0; 
        margin-bottom: 20px;
    }

    .image-panel > .image-container {
        margin-top: 0; 
        flex-grow: 1; 
    }

    .image-panel {
        justify-content: flex-start;
    }

    .app-footer {
        position: relative; 
        margin-top: 20px; 
        padding: 8px 30px; 
        max-width: 100%; 
    }
}

@media (max-width: 768px) { 
    .container, .image-panel {
        padding: 25px;
    }

    h1 {
        font-size: 2em;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .radio-group {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container, .image-panel {
        padding: 20px;
    }

    h1 {
        font-size: 1.8em;
    }

    button {
        font-size: 1.1em;
        padding: 12px 25px;
    }

    .radio-group label {
        padding: 8px 10px;
        font-size: 0.9em;
    }
}

.app-footer {
    width: 100%;
    text-align: center;
    color: var(--text-color);
    font-size: 0.8em; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box; 
}

.app-footer p {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.app-footer p a {
    color: var(--text-color); 
    font-size: 1.2em;
    transition: color 0.3s ease;
    text-decoration: none;
}

.app-footer p a:hover {
    color: var(--primary-color); 
}

@media (max-width: 1024px) {
    .app-footer {
        margin-top: 20px; 
        padding: 8px 30px; 
        max-width: 100%; 
    }
    .app-footer p {
        gap: 8px;
    }
    .app-footer p a {
        font-size: 1.1em;
    }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--container-bg);
    color: var(--text-color);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    max-width: 600px;
    width: 90%;
    text-align: center;
    position: relative;
    animation: fadeInScale 0.3s ease-out forwards;
    border: 1px solid var(--primary-color);
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 2em;
}

.modal-content p {
    margin-bottom: 15px;
    font-size: 1.1em;
    line-height: 1.8;
}

.modal-content button {
    margin-top: 30px;
    padding: 12px 25px;
    font-size: 1em;
    width: auto;
}

.app-footer .separator {
    color: var(--text-color);
    margin: 0 5px;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.language-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.1em;
    font-weight: bold;
    color: var(--text-color);
}

.language-switcher .lang-option {
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 5px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.language-switcher .lang-option:hover {
    background-color: rgba(0, 123, 255, 0.2);
}

.language-switcher .lang-option.active {
    background-color: var(--primary-color);
    color: white;
}

.floating-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--notification-bg);
    color: var(--notification-text);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out, transform 0.5s ease-out;
    text-align: center;
    font-weight: 600;
    max-width: 90%;
    min-width: 280px;
}

.floating-notification.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

@keyframes slideDownFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.floating-notification.show {
    animation: slideDownFadeIn 0.5s forwards;
}

@keyframes slideUpFadeOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

.floating-notification.hide-animation {
    animation: slideUpFadeOut 0.5s forwards;
}

.app-version {
    font-size: 0.6em;
    opacity: 0.7;
    margin-left: 5px;
}

.log-content {
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 15px;
    margin-bottom: 20px;
}

.log-content::-webkit-scrollbar {
    width: 8px;
}

.log-content::-webkit-scrollbar-track {
    background-color: var(--input-bg);
    border-radius: 4px;
}

.log-content::-webkit-scrollbar-thumb {
    background-color: var(--text-color);
    border-radius: 4px;
}

.log-content::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-hover);
}

.log-content h3 {
    color: var(--text-color);
    margin-top: 25px;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.log-content ul {
    list-style-type: disc;
    margin-left: 20px;
    padding-left: 0;
}

.log-content li {
    margin-bottom: 8px;
    font-size: 0.95em;
    line-height: 1.5;
}