/* CodeMirror Editor Specific Styles */
.codemirror-editor-container {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

/* Force CodeMirror wrapper to proper height */
.CodeMirror {
    height: 500px !important;
    min-height: 400px !important;
    font-family: 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

/* Theme-specific CodeMirror adjustments */
[data-theme="refined-dark"] .codemirror-editor-container,
[data-theme="minimal-dark"] .codemirror-editor-container,
[data-theme="dracula"] .codemirror-editor-container,
[data-theme="nord"] .codemirror-editor-container,
[data-theme="solarized-dark"] .codemirror-editor-container,
[data-theme="github-dark"] .codemirror-editor-container,
[data-theme="atom-one-dark"] .codemirror-editor-container,
[data-theme="monokai"] .codemirror-editor-container {
    background-color: var(--card-background);
}

/* Responsive CodeMirror editor */
@media (max-width: 768px) {
    .codemirror-editor-container {
        height: 400px;
    }
    
    .CodeMirror {
        height: 400px !important;
        min-height: 300px !important;
    }
}

@media (max-width: 480px) {
    .codemirror-editor-container {
        height: 300px;
    }
    
    .CodeMirror {
        height: 300px !important;
        min-height: 250px !important;
    }
}

/* Loading state for editors */
.codemirror-editor-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.codemirror-editor-loading::after {
    content: "Loading editor...";
}

/* Error state for editors */
.codemirror-editor-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--accent-error);
    font-size: 1.2rem;
}

/* Editor action buttons styling */
.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--card-header-bg);
    border-radius: 0.5rem 0.5rem 0 0;
    border-bottom: 1px solid var(--border-color);
}

/* Project Creation Form - Compact Version */
.project-creation-form {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.form-title {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.15rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input, 
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

/* Make the compose textarea much bigger */
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: monospace;
    min-height: 400px;
    resize: vertical;
}

/* CodeMirror in create form should also be bigger */
.form-group .CodeMirror {
    height: 400px !important;
    min-height: 300px !important;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.form-step {
    display: none;
}

.form-step.active {
    display: block;
}

.step-title {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
    margin-right: 0.5rem;
}

.step-title h4 {
    margin: 0;
    font-size: 1rem;
}

.project-preview {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.preview-file {
    margin-bottom: 1rem;
}

.preview-file h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
}

.preview-file-icon {
    margin-right: 0.5rem;
}

.preview-content {
    font-family: monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    background: var(--bg-primary);
    padding: 0.75rem;
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
}

/* Compact template info */
.template-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Make help text smaller */
.help-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    line-height: 1.3;
}

/* Checkbox styling */
input[type="checkbox"] {
    margin-right: 8px;
    vertical-align: middle;
}

label[for="env-content"] {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

/* Two-column layout for smaller fields */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Editor Actions - Keep on one line */
.editor-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap !important;
    margin-top: 1rem;
}

.editor-actions .form-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
    white-space: nowrap;
    flex-shrink: 0;
    height: 40px;
}

.editor-actions .form-group label {
    margin-bottom: 0 !important;
    height: auto;
    display: flex;
    align-items: center;
}

.editor-actions .filter-select {
    height: 40px !important;
    padding: 0.5rem;
    box-sizing: border-box;
}

.editor-actions .btn {
    height: 40px !important;
    padding: 0.5rem 1rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Fix that specific refresh button alignment */
#compose-subtab > div:nth-child(4) > div:nth-child(1) > button:nth-child(3) {
    margin-top: 3px;
}

/* Regular textarea editors (fallback) */
#compose-editor, 
#env-editor, 
#caddy-editor {
    width: 100%;
    height: 500px !important;
    min-height: 400px !important;
    font-family: monospace;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    resize: vertical;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .form-group textarea,
    .form-group .CodeMirror {
        min-height: 300px !important;
        height: 300px !important;
    }
    
    .project-creation-form {
        padding: 0.75rem;
    }
    
    /* Regular editors on mobile */
    #compose-editor, 
    #env-editor, 
    #caddy-editor {
        height: 400px !important;
        min-height: 300px !important;
    }
    
    /* Editor actions responsive */
    .editor-actions {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    
    .editor-actions .form-group {
        flex-direction: row !important;
        align-items: center !important;
    }
    
    .editor-actions .btn {
        width: auto !important;
        flex-shrink: 0;
    }
}

/* Mobile header and navigation fixes */
@media (max-width: 768px) {
    header {
        padding: 0.5rem;
        gap: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .system-stats {
        padding: 8px;
    }
    
    .stats-compact {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        font-size: 0.75rem;
        gap: 2px;
    }
    
    .stats-compact span {
        white-space: nowrap;
    }
    
    .stats-grid {
        display: none;
    }
    
    .tabs {
        display: flex;
        background-color: var(--background-secondary);
        border-radius: 8px 8px 0 0;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 0;
        width: 100%;
    }
    
    .tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
        min-width: auto;
    }
    
    .tab-icon {
        font-size: 1rem;
        margin-right: 0.5rem;
    }
    
    .tab-text {
        font-size: 0.8rem;
    }
    
    .config-subtabs {
        max-width: none;
        width: 100%;
        flex-wrap: wrap;
        gap: 0.25rem;
        padding: 0.5rem;
    }
    
    .subtab {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
        flex: 1;
        min-width: auto;
        text-align: center;
    }
    
    .compose-file-selector {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .compose-file-selector select {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .scan-btn {
        width: 100%;
        padding: 0.75rem;
    }
    
    .tab-content {
        padding: 0.75rem 0.5rem;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .tab {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .tab-icon {
        font-size: 0.9rem;
        margin-right: 0.25rem;
    }
    
    .tab-text {
        font-size: 0.75rem;
    }
}