* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 800px;
    padding: 40px;
    text-align: center;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 2.5rem;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.prompt-container {
    margin-bottom: 30px;
}

#promptInput {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    margin-bottom: 15px;
    transition: border-color 0.3s;
    resize: vertical;
    min-height: 100px;
}

#promptInput:focus {
    outline: none;
    border-color: #667eea;
}

#generateBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 600;
}

#generateBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#generateBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.image-container {
    margin-top: 40px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    overflow: hidden;
    background-color: #f9f9f9;
    position: relative;
}

#resultImage {
    max-width: 100%;
    max-height: 500px;
    display: none;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.placeholder {
    color: #999;
    font-size: 1.2rem;
    padding: 40px;
}

.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    margin-bottom: 10px;
    font-size: 1.1rem;
    color: #555;
}

.loading-time {
    font-size: 0.9rem;
    color: #777;
}

.progress-container {
    width: 100%;
    max-width: 300px;
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    margin-top: 20px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.error-message {
    color: #e74c3c;
    margin-top: 15px;
    padding: 10px;
    background-color: #fdecea;
    border-radius: 5px;
    display: none;
}

.footer {
    margin-top: 30px;
    color: #777;
    font-size: 0.9rem;
}

.image-actions {
    display: none;
    margin-top: 20px;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.regenerate-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.download-btn {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.action-btn:active {
    transform: translateY(0);
}

.history-container {
    margin-top: 30px;
    text-align: left;
    display: none;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.history-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.history-actions {
    display: flex;
    gap: 10px;
}

.toggle-history-btn {
    background: #f0f0f0;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.toggle-history-btn:hover {
    background: #e0e0e0;
}

.delete-selected-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.delete-selected-btn:hover {
    background: #c0392b;
}

.delete-selected-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.clear-history-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.clear-history-btn:hover {
    background: #c0392b;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    display: none;
}

.history-table.active {
    display: table;
}

.history-table th, .history-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.history-table th {
    background-color: #f8f8f8;
    font-weight: 600;
    color: #555;
}

.history-table tr:hover {
    background-color: #f9f9f9;
}

.history-table tr.selected {
    background-color: #e8f4fc;
}

.history-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s;
}

.history-image:hover {
    transform: scale(1.05);
}

.history-prompt {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-date {
    color: #777;
    font-size: 0.9rem;
}

.history-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.empty-history {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

.retry-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 10px;
}

.retry-btn:hover {
    background: #2980b9;
}

.hidden {
    display: none !important;
}

.selection-info {
    font-size: 0.9rem;
    color: #666;
    margin-left: 10px;
}