:root {
    --primary-color: #00aaff;
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --text-color: #e0e0e0;
    --subtle-text-color: #888;
    --border-color: #333;
    --green-color: #28a745;
    --red-color: #ff6b6b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto Mono', monospace;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

#info-icon {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 1001; /* Above other content, but below modals */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s, transform 0.2s;
}

#info-icon:hover {
    background-color: #0088cc;
    transform: scale(1.05);
}

.container {
    width: 100%;
    max-width: 800px;
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

header {
    text-align: center;
    padding: 30px 40px;
    background-color: rgba(0,0,0,0.1);
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 10px;
}

main {
    padding: 30px 40px;
}

.input-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.input-area > * {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.input-area.loading > *:not(#generate-btn) {
    opacity: 0.5;
    transform: translateY(-5px);
    pointer-events: none;
}

.model-selection {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-selection label {
    font-size: 0.9rem;
    color: var(--subtle-text-color);
    padding-left: 2px;
}

#model-select {
    width: 100%;
    padding: 12px 15px;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-family: 'Roboto Mono', monospace;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 1em;
}

#model-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.2);
}

#prompt-input {
    width: 100%;
    min-height: 100px;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    color: var(--text-color);
    font-family: 'Roboto Mono', monospace;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#prompt-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.2);
}

#generate-btn {
    align-self: flex-end;
    padding: 12px 25px;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Roboto Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

#generate-btn:hover {
    background-color: #0088cc;
}

#generate-btn:active {
    transform: scale(0.98);
}

#generate-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.7;
}

#loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 40px 0;
    text-align: center;
}

#loading-indicator.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#result-container {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

#result-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.extension-card {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
}

.extension-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.extension-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 5px;
    flex-shrink: 0;
}

.extension-title h2 {
    color: var(--primary-color);
    font-size: 1.75rem;
}

.extension-title p {
    font-style: italic;
    color: var(--subtle-text-color);
}

.extension-body h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.extension-body ul {
    list-style: none;
    padding-left: 0;
}

.extension-body ul li {
    background-color: var(--surface-color);
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 8px;
    border-left: 3px solid var(--primary-color);
}

.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.file-item {
    background-color: var(--background-color) !important;
    border: 1px solid var(--primary-color) !important;
    color: var(--primary-color);
    padding: 5px 12px !important;
    border-radius: 20px !important;
    font-size: 0.85rem;
}

.extension-actions {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: right;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

#live-preview-btn {
    padding: 12px 25px;
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    font-family: 'Roboto Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

#live-preview-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

#view-code-btn {
    padding: 12px 25px;
    background-color: var(--subtle-text-color);
    color: var(--background-color);
    border: none;
    border-radius: 8px;
    font-family: 'Roboto Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

#view-code-btn:hover {
    background-color: var(--text-color);
}

#download-btn {
    padding: 12px 25px;
    background-color: var(--green-color); /* A green color for download */
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Roboto Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

#download-btn:hover {
    background-color: #218838;
}

#download-btn:active {
    transform: scale(0.98);
}

#download-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

.extension-review {
    margin-top: 25px;
    padding: 20px;
    background-color: var(--surface-color);
    border-radius: 8px;
    border-left: 4px solid var(--subtle-text-color);
}

.extension-review blockquote {
    font-style: italic;
    color: var(--subtle-text-color);
    position: relative;
    padding-left: 25px;
}

.extension-review blockquote::before {
    content: '“';
    font-size: 3rem;
    color: var(--primary-color);
    position: absolute;
    left: -15px;
    top: -15px;
    opacity: 0.5;
}

/* Modal Styles */
#code-preview-modal, #live-preview-modal, #instructions-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

#code-preview-modal.hidden, #live-preview-modal.hidden, #instructions-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-container {
    position: relative;
    width: 90%;
    max-width: 1000px;
    height: 80vh;
    background-color: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(1);
    transition: transform 0.3s ease;
}

#code-preview-modal.hidden .modal-container, #live-preview-modal.hidden .modal-container, #instructions-modal.hidden .modal-container {
    transform: scale(0.95);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-header h3 {
    color: var(--primary-color);
    font-size: 1.2rem;
}

#modal-close-btn, #live-preview-close-btn, #instructions-close-btn {
    background: none;
    border: none;
    color: var(--subtle-text-color);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.3s;
    order: 3; /* Ensure it's on the right */
}

#modal-close-btn:hover, #live-preview-close-btn:hover, #instructions-close-btn:hover {
    color: var(--text-color);
}

.modal-content {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

.text-content {
    padding: 20px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
}

.text-content p {
    margin-bottom: 1em;
}

.text-content ol {
    list-style: decimal;
    padding-left: 25px;
}

.text-content ol li {
    margin-bottom: 10px;
}

.text-content strong {
    color: var(--primary-color);
}

.text-content code {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.file-tabs-container {
    flex-basis: 200px;
    flex-shrink: 0;
    background-color: rgba(0,0,0,0.2);
    padding: 10px;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.file-tab {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: var(--subtle-text-color);
    padding: 12px 15px;
    text-align: left;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    margin-bottom: 5px;
}

.file-tab:hover {
    background-color: rgba(255,255,255,0.05);
}

.file-tab.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
}

.code-display-container {
    flex-grow: 1;
    overflow: auto;
    background-color: var(--background-color);
}

#code-content {
    display: block;
    padding: 20px;
    color: var(--text-color);
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    min-height: 100%;
}

/* Live Preview Specific Styles */
.modal-container.browser-sim {
    padding: 0;
}

.browser-header {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #2a2a2a;
    padding: 10px;
}

.browser-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.browser-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.address-bar-container {
    flex-grow: 1;
    display: flex;
    background-color: var(--background-color);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#sim-address-bar {
    flex-grow: 1;
    background: none;
    border: none;
    padding: 8px 12px;
    color: var(--text-color);
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
}

#sim-address-bar:focus {
    outline: none;
}

#sim-go-btn {
    background-color: var(--primary-color);
    border: none;
    color: white;
    padding: 0 15px;
    cursor: pointer;
    font-size: 0.9rem;
}

.extension-icon-container {
    flex-shrink: 0;
    margin: 0 10px;
}

#sim-extension-icon {
    width: 28px;
    height: 28px;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px;
    background: rgba(255,255,255,0.1);
}

.browser-body {
    flex-grow: 1;
    position: relative;
    background-color: var(--background-color);
}

#browser-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: white;
}

#sim-popup-container {
    position: absolute;
    top: 5px;
    right: 50px;
    width: 300px;
    max-height: 400px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    z-index: 10;
    overflow-y: auto;
    padding: 10px;
}

#sim-popup-container.hidden {
    display: none;
}

.proxy-note {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 170, 255, 0.1);
    color: var(--primary-color);
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
    z-index: 5;
    width: 90%;
    max-width: 600px;
    border: 1px solid rgba(0, 170, 255, 0.2);
}

.proxy-note b {
    font-weight: 700;
    color: #e0e0e0;
}

footer {
    text-align: center;
    padding: 20px 40px;
    font-size: 0.8rem;
    color: var(--subtle-text-color);
}

.credits {
    margin-top: 10px;
    font-size: 0.75rem;
    line-height: 1.5;
}

.credits a {
    color: var(--subtle-text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.credits a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}