/* Custom styles for DevSystem */

/* Editor container */
.editor-container {
    height: calc(100vh - 56px - 50px); /* Account for navbar and status bar */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Status bar */
.status-bar {
    z-index: 1050;
    font-size: 0.875rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    flex-shrink: 0;
    height: 50px;
}

/* Editor content area */
.editor-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Code editor styling */
.code-editor {
    width: 100%;
    height: 100%;
    border: none;
    font-family: 'Courier New', monospace;
}

.CodeMirror {
    height: 100%;
    font-size: 14px;
}

.CodeMirror-scroll {
    overflow: auto !important;
}

/* Editor tabs */
.editor-tabs-container {
    overflow: hidden;
    flex-shrink: 0;
}

#editorTabs {
    border-bottom: 2px solid #dee2e6;
    flex-wrap: wrap;
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

#editorTabs .nav-item {
    flex-shrink: 0;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    color: #6c757d;
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
}

.nav-tabs .nav-item.ms-auto {
    margin-left: auto;
    flex-shrink: 0;
}

.nav-tabs .nav-item.ms-auto .btn {
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .editor-container {
        height: calc(100vh - 56px - 50px); /* Account for navbar and status bar */
        max-height: calc(100vh - 56px - 50px);
        overflow: hidden;
    }
    
    .tab-content {
        max-height: 100%;
        overflow: hidden;
    }
    
    .tab-pane {
        max-height: 100%;
    }
    
    .nav-tabs .nav-link {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    .nav-tabs .nav-link i {
        font-size: 1.1rem;
    }
    
    .nav-tabs .nav-item.ms-auto .btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.875rem;
    }
    
    .status-bar {
        padding: 0.5rem;
        font-size: 0.75rem;
        height: auto;
        min-height: 50px;
    }
    
    /* Agent pane mobile adjustments */
    #agent-pane .row {
        flex-direction: column;
    }
    
    #agent-pane .col-md-6 {
        flex: 1;
        min-height: 0;
        max-height: 50%;
    }
    
    #agent-pane .border-top {
        flex-shrink: 0;
        background: #fff;
    }
}

.nav-tabs .nav-link:hover {
    border-color: #dee2e6;
    color: #495057;
}

.nav-tabs .nav-link.active {
    border-bottom-color: #0d6efd;
    color: #0d6efd;
    font-weight: 500;
}

/* Tab content */
.tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.tab-pane {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    height: 100%;
}

.tab-pane.active,
.tab-pane.show {
    display: flex;
}

/* Code editor tab panes */
#html-pane,
#script-pane,
#styles-pane {
    position: relative;
    height: 100%;
    z-index: 1;
}

#html-pane .code-editor,
#script-pane .code-editor,
#styles-pane .code-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .nav-tabs {
        flex-wrap: wrap;
    }
    
    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Stack agent tabs on mobile */
    #agent-pane .row {
        flex-direction: column;
    }
    
    #agent-pane .col-md-6 {
        max-width: 100%;
        border-right: none !important;
        border-bottom: 1px solid #dee2e6;
    }
    
    /* Status bar adjustments */
    .status-bar {
        font-size: 0.75rem;
        padding: 0.5rem !important;
        height: auto;
        min-height: 50px;
    }
}

/* Asset grid */
#assetsList .card {
    transition: transform 0.2s;
}

#assetsList .card:hover {
    transform: translateY(-2px);
}

/* Asset preview images */
.asset-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    max-height: 400px;
    overflow: hidden;
    background: #f8f9fa;
    padding: 10px;
}

.asset-preview {
    max-width: 100%;
    max-height: 380px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.asset-preview.img-thumbnail {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0;
}

/* Project cards */
.card {
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Agent pane styling */
#agent-pane {
    background: #fff;
    color: #212529;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 1;
}

#agent-pane .row {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin: 0;
}

#agent-pane .col-md-6 {
    background: #fff;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#agent-pane .border-top {
    flex-shrink: 0;
}

#agent-pane h5 {
    color: #212529;
    font-weight: 600;
}

#agent-pane .p-3 {
    background: #fff;
    color: #212529;
}

/* Agent response area */
#agentResponse {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff !important;
    color: #212529 !important;
    border: 1px solid #dee2e6;
    border-radius: 0;
    line-height: 1.6;
    padding: 1rem !important;
    margin: 0;
    -webkit-overflow-scrolling: touch;
}

#agentResponse.bg-success {
    background: #198754 !important;
    color: #fff !important;
    border-color: #198754;
}

#agentResponse.bg-danger {
    background: #dc3545 !important;
    color: #fff !important;
    border-color: #dc3545;
}

#agentResponse.bg-light {
    background: #fff !important;
    color: #212529 !important;
    border-color: #dee2e6;
}

#agentResponse.bg-success .agent-actions,
#agentResponse.bg-danger .agent-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

#agentResponse.bg-light .agent-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.agent-actions .btn {
    min-width: 150px;
}

/* Prompts list */
#promptsList {
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

#promptsList .card {
    background: #fff;
    border: 1px solid #dee2e6;
    margin-bottom: 0.75rem;
}

#promptsList .card-body {
    padding: 0.75rem;
}

#promptsList .text-muted {
    color: #6c757d !important;
}

#promptsList p {
    color: #212529;
    margin-bottom: 0;
    line-height: 1.5;
}

/* Agent input area */
#agent-pane .border-top {
    background: #fff;
    border-top: 1px solid #dee2e6 !important;
}

#agent-pane .bg-light {
    background: #f8f9fa !important;
}

/* Settings form */
#settings-pane {
    background: #fff;
    color: #212529;
}

#settings-pane .form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #212529;
}

#settings-pane .text-muted {
    color: #6c757d !important;
}

#settings-pane .card {
    background: #fff;
    color: #212529;
}

/* Loading states */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Dark mode scrollbar (for CodeMirror) */
.CodeMirror-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.CodeMirror-scrollbar::-webkit-scrollbar-thumb {
    background: #555;
}

/* Focus states */
.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Badge adjustments */
.badge {
    font-size: 0.7rem;
    padding: 0.25em 0.5em;
}

/* Button groups on mobile */
@media (max-width: 576px) {
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: 0.375rem !important;
        margin-bottom: 0.25rem;
    }
}

/* Editor container */
#editorTabContent {
    background: #272822; /* Match CodeMirror monokai background */
}

/* Ensure full height for editor */
html, body {
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

main.container-fluid {
    padding-left: 0;
    padding-right: 0;
}

/* Remove margin-top for editor page */
main.container-fluid:has(.editor-container) {
    margin-top: 0 !important;
    padding-top: 0;
}

/* Fallback for browsers that don't support :has() */
.editor-container {
    margin-top: -1rem;
}

/* Alert dismissible */
.alert-dismissible .btn-close {
    padding: 0.5rem 0.75rem;
}

/* Modal adjustments for mobile */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
    }
}

