/* --- General Body & Font Styling --- */
body {
    font-family: 'Roboto', sans-serif;
    background-color: #121212;;
    color: #e0e0e0;
    margin: 0;
    padding: 0rem 0rem;
    line-height: 1.4;
}

/* --- Main Layout Container --- */
.container {
    max-width: 800px;
    margin: 1rem auto;
    background-color: #1e1e1e;
    padding: 0.75rem;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

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

h1 {
    margin: 1rem auto;
    width: 70%;
    color: #f5f5f5;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #c7c7c7;
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* --- New Top Controls for API Key and Style --- */
.top-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.model-selector-block {
    background-color: #242424;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.block-label {
    font-weight: bold;
    color: #c0c0c0;
}

.selector-row {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.provider-select,
.model-select {
    flex: 1;
    padding: 7px;
    font-family: inherit;
    font-size: 0.9rem;
    background-color: #343434;
    border: 1px solid #555;
    color: #e0e0e0;
    border-radius: 0 0 6px 6px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Style the top select dropdown */
.provider-select {
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

.api-key-input,
#image-style-prompt {
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: #242424;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 10px; /* I've removed the redundant padding property */
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    color: #e0e0e0;
    box-sizing: border-box; /* This is the fix */
}

.api-key-input:disabled {
    background-color: #383838;
    color: #888;
}

/* --- Main Bottom Input Controls --- */
.controls {
    display: flex;
    flex-direction: column;
    padding-top: 0.75rem;
}

#prompt-input {
    width: 100%;
    height: 80px;
    padding: 5px;
    font-family: inherit;
    font-size: 1rem;
    background-color: #2c2c2c;
    border: 1px solid #444;
    color: #e0e0e0;
    border-radius: 8px;
    resize: vertical;
    box-sizing: border-box;
    margin-bottom: 2rem;
}

#generate-btn {
    background-color: #0068d7;
    color: #e0e0e0;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

#generate-btn:hover {
    background-color: #004289;
}

#generate-btn:disabled {
    background-color: #0a0035;
    cursor: not-allowed;
}

/* --- Comic Display Area --- */
.comic-container {
    display: grid;
    gap: 0.75rem;
}

.comic-panel {
    background-color: #2c2c2c;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 0.2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.comic-panel img {
    width: 100%;
    height: auto;
    max-height: 80vh;
    min-height: 1px;
    object-fit: contain;
    display: block;
    border-radius: 6px;
    background-color: #232323;
}

/* Style for the editable caption input */
.caption-input {
    width: 100%;
    min-height: 20px;
    padding: 5px;
    font-family: inherit;
    font-size: 1rem;
    color: #e0e0e0;
    background-color: #1e1e1e;
    border: 1px #0068d7;
    border-radius: 6px;
    box-sizing: border-box;
    resize: vertical;
    overflow-y: hidden;
}

/* Style for the final, locked-in caption text */
.caption-text {
    font-size: 1rem;
    color: #e0e0e0;
    margin: 0;
    padding: 5px;
    background-color: #2c2c2c;
    border-radius: 6px;
    border: 1px solid transparent;
}

.top-controls details {
    background-color: #2c2c2c;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 10px;
    transition: all 0.3s ease-in-out;
}

.top-controls details[open] {
    background-color: #2c2c2c;
}

.top-controls summary {
    font-size: 1.1em;
    font-weight: bold;
    color: #e3e3e3;
    cursor: pointer;
    outline: none;
    list-style: none; /* Remove default marker */
}

/* Add custom marker */
.top-controls summary::before {
    content: '▶'; /* Right-pointing triangle */
    margin-right: 10px;
    font-size: 0.9em;
    transition: transform 0.2s ease-in-out;
}

.top-controls details[open] summary::before {
    transform: rotate(90deg); /* Rotate triangle when open */
}
