/* Aileo Hatmaster Custom Styles */

/* Reset body styles for different page types */
body {
    margin: 0;
    padding: 0;
}

.landing-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Override flexbox styles when not on landing page */
body:not(.landing-container) {
    display: block !important;
    align-items: initial !important;
    justify-content: initial !important;
}

/* Specific override for when landing classes might persist */
body.d-flex:not(.landing-container) {
    display: block !important;
}

body.align-items-center:not(.landing-container) {
    align-items: initial !important;
}

/* App layout specific styles */
body.app-layout {
    display: block !important;
    align-items: initial !important;
    justify-content: initial !important;
    min-height: 100vh;
    background-color: #f8f9fa !important;
    background-image: none !important;
}

.login-card {
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
}

.app-header {
    background-color: #1a1a2e;
    border-bottom: 2px solid #16213e;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    height: 56px;
}

.sidebar {
    background-color: #16213e;
    min-height: calc(100vh - 56px);
    width: 250px;
    position: fixed;
    left: 0;
    top: 56px;
    overflow-y: auto;
}

.sidebar .nav-link {
    color: #8a92b2;
    padding: 12px 20px;
    border-radius: 8px;
    margin: 4px 8px;
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: #0f1419;
    color: #ffffff;
}

.main-content {
    margin-left: 250px;
    margin-top: 56px;
    padding: 20px;
    background-color: #f8f9fa;
    min-height: calc(100vh - 56px);
    width: calc(100% - 250px);
}

.content-wrapper {
    position: relative;
    width: 100%;
}

.btn-google {
    background-color: #db4437;
    border-color: #db4437;
}

.btn-google:hover {
    background-color: #c23321;
    border-color: #c23321;
}


/* Form Styling Improvements */
.form-row {
    margin-bottom: 1.5rem;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.form-text {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #dc3545;
}

/* Button Group Styling */
.btn-group-crud {
    gap: 0.5rem;
}

/* API Key Field with Toggle */
.api-key-container {
    position: relative;
}

.api-key-field {
    padding-right: 3rem !important;
}

.api-key-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 10;
}

.api-key-toggle:hover {
    color: #495057;
}

.api-key-toggle:focus {
    outline: none;
    color: #495057;
}

/* API Key Field States */
.api-key-field[type="password"] {
    font-family: text-security-disc, monospace;
    letter-spacing: 0.125em;
}

.api-key-field[data-masked="true"] {
    -webkit-text-security: disc;
    text-security: disc;
}

/* Clickable Table Rows */
.languagemodel-row,
.agent-row {
    transition: background-color 0.2s ease;
}

.languagemodel-row:hover,
.agent-row:hover {
    background-color: rgba(0, 123, 255, 0.1) !important;
}

.languagemodel-row:hover td,
.agent-row:hover td {
    background-color: transparent !important;
}



/* Code Editor Styling */
.code-editor {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
    font-size: 0.875rem;
    line-height: 1.4;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

.code-editor {
    border-radius: 0.375rem;
    min-height: 200px;
}

.code-editor:focus {
    background-color: #ffffff;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* CodeMirror 6 Container Styling */
.code-editor-container {
    position: relative;
    margin-bottom: 0.75rem;
}

/* CodeMirror 6 Enhanced Styling */
.code-editor-container .cm-editor {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #ffffff;
    font-size: 0.875rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.code-editor-container .cm-editor.cm-focused {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    outline: none;
}

.code-editor-container .cm-content {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    padding: 12px;
    min-height: 200px;
    line-height: 1.4;
}

.code-editor-container .cm-gutters {
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.code-editor-container .cm-lineNumbers .cm-gutterElement {
    color: #6c757d;
    font-size: 0.8rem;
    min-width: 2.5rem;
    text-align: right;
    padding-right: 0.5rem;
}

.code-editor-container .cm-activeLine {
    background-color: rgba(0, 123, 255, 0.05);
}

.code-editor-container .cm-selectionBackground {
    background-color: rgba(0, 123, 255, 0.3);
}

.code-editor-container .cm-scroller {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* YAML Syntax Highlighting */
.code-editor-container .tok-meta {
    color: #d63384; /* Bootstrap pink for YAML keys */
}

.code-editor-container .tok-string {
    color: #198754; /* Bootstrap green for strings */
}

.code-editor-container .tok-number {
    color: #0d6efd; /* Bootstrap blue for numbers */
}

.code-editor-container .tok-comment {
    color: #6c757d; /* Bootstrap gray for comments */
    font-style: italic;
}

.code-editor-container .tok-keyword {
    color: #6f42c1; /* Bootstrap purple for keywords */
    font-weight: 600;
}

/* Error state styling */
.code-editor-container.has-error .cm-editor {
    border-color: #dc3545;
}

.code-editor-container.has-error .cm-editor.cm-focused {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* Monaco Editor Container Styling */
.monaco-editor-container {
    /* Default height for Monaco containers when not in specific contexts */
    height: 400px;
    min-height: 400px;
    /* Improve rendering performance and prevent collapse issues */
    will-change: transform;
    contain: layout;
    /* Ensure container is visible during initialization */
    position: relative;
}

/* Monaco Editor Wrapper (contains toolbar + editor) */
.monaco-editor-wrapper {
    position: relative;
}

/* Monaco Editor Toolbar */
.monaco-editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.monaco-toolbar-left,
.monaco-toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.monaco-toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #6c757d;
    background: transparent;
    color: #6c757d;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.monaco-toolbar-btn-text {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid #6c757d;
    background: transparent;
    color: #6c757d;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
    text-decoration: none;
}

.monaco-toolbar-btn:hover,
.monaco-toolbar-btn-text:hover {
    background-color: #e9ecef;
    border-color: #495057;
    color: #495057;
    text-decoration: none;
}

.monaco-toolbar-btn:focus,
.monaco-toolbar-btn-text:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Monaco Editor Fullscreen Mode */
.monaco-editor-wrapper.monaco-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: #ffffff !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
}

.monaco-editor-wrapper.monaco-fullscreen .monaco-editor-toolbar {
    padding: 8px 16px;
    background-color: #1e1e1e;
    border-bottom: 1px solid #333;
}

.monaco-editor-wrapper.monaco-fullscreen .monaco-toolbar-btn,
.monaco-editor-wrapper.monaco-fullscreen .monaco-toolbar-btn-text {
    border-color: #6c757d;
    color: #adb5bd;
}

.monaco-editor-wrapper.monaco-fullscreen .monaco-toolbar-btn:hover,
.monaco-editor-wrapper.monaco-fullscreen .monaco-toolbar-btn-text:hover {
    background-color: #333;
    border-color: #adb5bd;
    color: #ffffff;
}

.monaco-editor-wrapper.monaco-fullscreen .monaco-editor-container {
    height: calc(100vh - 45px) !important;
    max-height: calc(100vh - 45px) !important;
    min-height: calc(100vh - 45px) !important;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

/* Card Styling for Forms */
.form-card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid rgba(0, 0, 0, 0.125);
}

.form-card-header {
    padding: 1.25rem 1.25rem 0;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.form-card-body {
    padding: 0 1.25rem 1.25rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        margin-top: 56px;
        width: 100%;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        position: relative;
        top: 0;
    }


    .btn-sm {
        padding: 0.125rem 0.5rem;
        font-size: 0.8125rem;
    }

    .form-row {
        margin-bottom: 1rem;
    }
}


/* =============================================================================
   UNIFIED MODEL TABLE STYLES
   All model tables (LanguageModel, Agent, Process, FileSystem) use these styles
   ============================================================================= */

.unified-model-table {
    table-layout: auto !important;
    width: 100% !important;
}

.unified-model-table th:nth-child(1),
.unified-model-table td:nth-child(1) {
    width: 5% !important; /* ID column */
    text-align: center !important;
}

.unified-model-table th:nth-child(2),
.unified-model-table td:nth-child(2) {
    width: 25% !important; /* Name column */
}

.unified-model-table th:nth-child(3),
.unified-model-table td:nth-child(3) {
    width: 15% !important; /* Provider column */
}

.unified-model-table th:nth-child(4),
.unified-model-table td:nth-child(4) {
    width: 10% !important; /* Version column */
}

.unified-model-table th:nth-child(5),
.unified-model-table td:nth-child(5) {
    width: 25% !important; /* Modified column */
}

.unified-model-table th:nth-child(6),
.unified-model-table td:nth-child(6) {
    width: 20% !important; /* Actions column */
}

/* Responsive behavior for unified tables */
@media (max-width: 768px) {
    .unified-model-table {
        font-size: 0.875rem;
    }

    .unified-model-table th,
    .unified-model-table td {
        padding: 0.5rem 0.25rem;
    }

    .btn-sm {
        padding: 0.125rem 0.5rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 576px) {
    .unified-model-table th:nth-child(1),
    .unified-model-table td:nth-child(1) {
        display: none; /* Hide ID column on mobile */
    }

    .unified-model-table th:nth-child(2),
    .unified-model-table td:nth-child(2) {
        width: 55% !important; /* Name column */
    }

    .unified-model-table th:nth-child(3),
    .unified-model-table td:nth-child(3) {
        width: 25% !important; /* Provider column */
    }

    .unified-model-table th:nth-child(4),
    .unified-model-table td:nth-child(4) {
        display: none; /* Hide Version column on mobile */
    }

    .unified-model-table th:nth-child(5),
    .unified-model-table td:nth-child(5) {
        display: none; /* Hide Modified column on mobile */
    }

    .unified-model-table th:nth-child(6),
    .unified-model-table td:nth-child(6) {
        width: 20% !important; /* Actions column */
    }

    .btn-group-crud {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* Sidebar Tools Section Styling */
.sidebar-divider {
    border-color: #2a3142;
    margin: 1rem 0.5rem;
}

.sidebar-heading {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    padding: 0.5rem 1.25rem;
    margin-bottom: 0.5rem;
}

/* Tools Modal Styling */
.modal-xl .modal-dialog {
    max-width: 1200px;
    width: 1000px; /* Better initial width */
}

/* Prevent flash of incorrect size by setting initial positioning */
#toolsModal .modal-dialog {
    position: absolute;
    margin: 0;
    transform: none !important; /* Override Bootstrap's centering transform */
    top: 50px; /* Initial top position */
    left: 50%; /* Initial left position */
    margin-left: -500px; /* Half of initial width to center */
}

#toolsModal .modal-body {
    padding: 0;
    min-height: 500px;
}

#tools-nav {
    padding: 1rem;
    background-color: #f8f9fa;
    height: 500px;
    overflow-y: auto;
}

#tools-nav .nav-link {
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
}

#tools-nav .nav-link.active {
    background-color: #0d6efd;
    color: white;
}

#tool-content-area {
    height: 500px;
    overflow-y: auto;
}

/* Tool-specific styling */
.tools-modal .form-control {
    border-radius: 0.375rem;
}

.tools-modal .btn {
    border-radius: 0.375rem;
}

/* Resizable Modal Styling */
.resizable-modal {
    position: relative;
    min-width: 400px;
    min-height: 300px;
    max-width: 95vw;
    max-height: 95vh;
    resize: none; /* Disable browser default resize */
}

.resizable-modal .modal-content {
    position: relative;
    height: 100%;
    width: 100%;
}

/* Drag handle for moving the modal */
.drag-handle {
    cursor: move;
    user-select: none;
}

.drag-handle:hover {
    background-color: #f8f9fa;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    background-color: transparent;
    z-index: 1050;
}

.resize-handle:hover {
    background-color: rgba(0, 123, 255, 0.2);
}

/* Edge handles */
.resize-handle-n {
    top: -3px;
    left: 10px;
    right: 10px;
    height: 6px;
    cursor: n-resize;
}

.resize-handle-s {
    bottom: -3px;
    left: 10px;
    right: 10px;
    height: 6px;
    cursor: s-resize;
}

.resize-handle-w {
    left: -3px;
    top: 10px;
    bottom: 10px;
    width: 6px;
    cursor: w-resize;
}

.resize-handle-e {
    right: -3px;
    top: 10px;
    bottom: 10px;
    width: 6px;
    cursor: e-resize;
}

/* Corner handles */
.resize-handle-nw {
    top: -3px;
    left: -3px;
    width: 10px;
    height: 10px;
    cursor: nw-resize;
}

.resize-handle-ne {
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    cursor: ne-resize;
}

.resize-handle-sw {
    bottom: -3px;
    left: -3px;
    width: 10px;
    height: 10px;
    cursor: sw-resize;
}

.resize-handle-se {
    bottom: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    cursor: se-resize;
}

/* Make modal backdrop non-dismissible when dragging/resizing */
.modal-dragging .modal-backdrop,
.modal-resizing .modal-backdrop {
    pointer-events: none;
}

/* Adjust content areas for dynamic sizing */
.resizable-modal #tools-nav,
.resizable-modal #tool-content-area {
    height: calc(100vh - 200px);
    min-height: 300px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .resizable-modal {
        min-width: 320px;
    }
    
    .resize-handle {
        display: none; /* Hide resize handles on mobile */
    }
}
