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

:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #2c2c2c;
    --bg-tertiary: #363636;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-blue: #0D99FF;
    --accent-blue-hover: #0077CC;
    --accent-red: #F24822;
    --accent-red-hover: #D93D1A;
    --success-green: #14AE5C;
    --error-red: #F24822;
    --warning-yellow: #FFA629;
    --border-color: #404040;
    --input-bg: #2c2c2c;
    --hover-bg: #404040;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 20px;
}

section {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.25rem;
    position: relative;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

input[type="text"],
input[type="password"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

select {
    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='white' 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 0.75rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

/* Message styles */
.message {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid transparent;
}

.message.success {
    background: rgba(20, 174, 92, 0.1);
    border-color: var(--success-green);
    color: var(--success-green);
}

.message.error {
    background: rgba(242, 72, 34, 0.1);
    border-color: var(--error-red);
    color: var(--error-red);
}

.message.warning {
    background: rgba(255, 166, 41, 0.1);
    border-color: var(--warning-yellow);
    color: var(--warning-yellow);
}

/* Base button styles */
.btn {
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 36px;
    min-width: 80px;
}

/* Primary Blue Button (Let's Build) */
.btn-primary,
.build-space-btn {
    background: var(--accent-blue);
    color: white;
    border: 1px solid transparent;
    font-weight: 500;
    height: 36px;
    padding: 0 16px;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-primary:hover,
.build-space-btn:hover {
    background: var(--accent-blue-hover);
}

/* Secondary Red Border Button (Edit Settings) */
.btn-secondary,
.edit-settings-btn {
    background: transparent;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    border-radius: 6px;
    font-weight: 500;
    height: 36px;
    padding: 0 16px;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-secondary:hover,
.edit-settings-btn:hover {
    background: rgba(242, 72, 34, 0.1);
}

/* Grey Button (Copy) */
.btn-grey,
.copy-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-weight: 500;
    height: 32px;
    padding: 0 12px;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.btn-grey:hover,
.copy-btn:hover {
    background: var(--hover-bg);
}

/* Remove duplicate button styles */
#buildButton,
.build-space-btn {
    margin-top: 1rem;
}

/* Update copy button positioning */
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    min-width: unset;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Loading states for different button types */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-right-color: transparent;
    animation: spin 0.8s linear infinite;
}

.btn-primary.loading::after,
.build-space-btn.loading::after {
    border-color: white;
    border-right-color: transparent;
}

.btn-secondary.loading::after,
.edit-settings-btn.loading::after {
    border-color: var(--accent-red);
    border-right-color: transparent;
}

.btn-grey.loading::after,
.copy-btn.loading::after {
    border-color: var(--text-primary);
    border-right-color: transparent;
}

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

/* Update form group to show validation messages */
.form-group .validation-message {
    position: absolute;
    bottom: -20px;
    left: 0;
    font-size: 0.75rem;
    color: var(--error-red);
}

#spacesContainer,
#finalSpacesContainer {
    margin-top: 1rem;
}

.space-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
}

.space-card h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.space-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.space-type {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.built-label {
    display: inline-block;
    background: var(--accent-green);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-top: 1rem;
}

.code-container {
    margin-top: 1rem;
    position: relative;
}

.code-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    max-height: 300px;
    overflow-y: auto;
}

/* Settings form styles */
.readonly,
select:disabled {
    background: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
    cursor: not-allowed !important;
    opacity: 1 !important;
}

select.readonly,
select:disabled {
    pointer-events: 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='%23a0a0a0' 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") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 1em !important;
    padding-right: 2.5rem !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Main layout */
.main-content {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

/* Settings box */
.settings-box {
    flex: 0 0 350px;
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Community box */
.community-box {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    position: relative;
    height: auto;
    overflow: hidden;
}

/* Form states */
.form-state {
    display: none;
    position: relative;
    width: 100%;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateX(20px);
}

.form-state.active {
    display: block;
    opacity: 1;
    transform: translateX(0);
}

/* Space containers */
#spacesContainer,
#finalSpacesContainer {
    margin-top: 1rem;
    max-height: none;
    overflow-y: visible;
}

/* Ensure forms take full width */
#communityForm,
#settingsForm {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Adjust button positioning */
#communityForm .btn,
#settingsForm .btn {
    margin-top: 1rem;
    width: 100%;
}

/* Space cards */
.space-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
    width: 100%;
}

/* Message container */
#settingsMessages,
#communityMessages,
#spacesMessages,
#builtSpacesMessages {
    margin-bottom: 1rem;
}

/* Remove duplicate styles */
.form-state {
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.form-state.active {
    transform: translateX(0);
}

/* Ensure proper spacing */
.form-group:last-of-type {
    margin-bottom: 1rem;
}

/* Code container adjustments */
.code-container {
    margin-top: 1rem;
    position: relative;
    width: 100%;
}

.code-box {
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--hover-bg);
}

/* Responsive layout */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .settings-box {
        width: 100%;
        margin-bottom: 1rem;
    }
}

/* Settings form specific styles */
#settingsForm select {
    max-height: 200px;
    overflow-y: auto;
}

/* Adjust section padding since we're handling it in the forms */
section {
    padding: 0;
    background: transparent;
    box-shadow: none;
} 