/**
 * FusedFormations IDE Styles
 * Clean, minimal design with custom syntax highlighting
 */

/* IDE Page Layout */
.ide-page-wrapper {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    overflow: hidden;
}

/* Hide default theme header/footer on IDE page */
body.page-template-page-ide .site-header,
body.page-template-page-ide .site-footer {
    display: none;
}

.usage-indicator {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    color: #666;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

#assist-count {
    font-weight: bold;
    color: #007bff;
}

/* Disabled state for chat when limit reached */
.chat-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}







/* IDE Navigation */
.ide-nav {
    background: #ffffff;
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ide-nav-container {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ide-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #000000;
    text-decoration: none;
    transition: opacity 0.2s;
}

.ide-logo:hover {
    opacity: 0.8;
}

.logo-icon {
    font-size: 1.5rem;
}

.ide-nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-greeting {
    color: #6c757d;
    font-size: 0.875rem;
}

/* IDE Container */
.ide-container {
    flex: 1;
    display: grid;
    grid-template-columns: 400px 4px 1fr;
    overflow: hidden;
    height: calc(100vh - 60px);
}

/* Panels */
.ide-panel {
    background: #ffffff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    background: #f8f9fa;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    border-bottom: 1px solid #e9ecef;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Assistant Panel */
.device-status {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.status-indicator.connected {
    color: #28a745;
}

.status-indicator.disconnected {
    color: #ced4da;
}

.board-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #ffffff;
    font-size: 0.875rem;
}

/* Chat */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.message {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.5;
}

.ai-message {
    background: #ffffff;
    border: 1px solid #e9ecef;
}

.user-message {
    background: #007bff;
    color: white;
    margin-left: 2rem;
}

.chat-input-container {
    display: flex;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.875rem;
}

.chat-input:focus {
    outline: none;
    border-color: #007bff;
}

.btn-send {
    padding: 0.75rem;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-send:hover:not(:disabled) {
    background: #0056b3;
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Quick Examples */
.quick-examples {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.quick-examples h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: #6c757d;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.example-chip {
    padding: 0.375rem 0.75rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.example-chip:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Resize Handle */
.resize-handle {
    width: 4px;
    background: #e9ecef;
    cursor: col-resize;
    position: relative;
}

.resize-handle:hover {
    background: #007bff;
}

/* Editor Panel */
.ide-editor-panel {
    display: flex;
    flex-direction: column;
}

/* Editor Toolbar */
.editor-toolbar {
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0056b3;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: #6c757d;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #f8f9fa;
    color: #000000;
}

.btn-primary-small {
    padding: 0.375rem 0.75rem;
    background: #007bff;
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

/* File Tabs */
.file-tabs {
    display: flex;
    background: #f8f9fa;
    padding: 0.5rem 0.5rem 0;
    gap: 0.25rem;
    overflow-x: auto;
    border-bottom: 1px solid #e9ecef;
}

.file-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 0.875rem;
}

.file-tab.active {
    background: #ffffff;
    border-color: #007bff;
    color: #007bff;
}

.file-tab .material-icons {
    font-size: 16px;
}

.tab-close {
    margin-left: 0.5rem;
    opacity: 0.5;
    cursor: pointer;
}

.tab-close:hover {
    opacity: 1;
}

/* Code Editor Container */
.editor-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.CodeMirror {
    height: 100%;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 14px;
}

/* Console */
.console-container {
    height: 200px;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #e9ecef;
}

.console-header {
    background: #f8f9fa;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.console {
    flex: 1;
    padding: 1rem;
    background: #f8f9fa;
    color: #333333;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid #e9ecef;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #ffffff;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #ced4da;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-body kbd {
    background: #f8f9fa;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.875rem;
}

/* Code Help Styles */
.code-help-container {
    padding: 1rem;
}

.help-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.help-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
}

.help-header p {
    margin: 0;
    color: #6c757d;
    font-size: 0.875rem;
}

.help-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.help-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.help-btn:hover {
    background: #ffffff;
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.help-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.help-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.help-response {
    margin-top: 1rem;
}

.help-loading {
    text-align: center;
    padding: 2rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top-color: #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.help-result {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.help-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.help-type-badge {
    font-size: 0.875rem;
    font-weight: 600;
}

.cached-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: #28a745;
    color: white;
    border-radius: 4px;
}

.help-content {
    font-size: 0.875rem;
    line-height: 1.6;
}

.help-content code {
    background: #e9ecef;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: monospace;
}

.code-block {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1rem 0;
}

.btn-apply {
    margin-top: 1rem;
    background: #28a745;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.btn-apply:hover {
    background: #218838;
}

.help-message {
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
}

.help-message.help-warning {
    background: #fff3cd;
    color: #856404;
}

.help-message.help-error {
    background: #f8d7da;
    color: #721c24;
}

.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: #000000;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* AI Action Buttons */
.ai-action-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 16px;
    font-size: 0.875rem;
    cursor: pointer;
    margin: 0.25rem;
    transition: all 0.2s;
    display: inline-block;
}

.ai-action-btn:hover {
    background: #0056b3;
    transform: scale(1.05);
}

/* Copy Example Button */
.btn-copy-example {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: all 0.2s;
    display: inline-block;
}

.btn-copy-example:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Message improvements for code blocks */
.ai-message pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5rem 0;
    border: 1px solid #dee2e6;
    position: relative;
    white-space: pre;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
}

.ai-message code {
    background: #e9ecef;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.875rem;
}

.ai-message pre code {
    background: none;
    padding: 0;
    color: #d4d4d4;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre;
    display: block;
}

/* Improve AI message styling */
.ai-message {
    line-height: 1.6;
}

.ai-message ul, .ai-message ol {
    margin: 0.5rem 0 0.5rem 1.5rem;
}

.ai-message li {
    margin: 0.25rem 0;
}

/* Flash effect for editor update */
.CodeMirror.flash-update {
    animation: flashGreen 0.5s ease;
}

@keyframes flashGreen {
    0% { background-color: transparent; }
    50% { background-color: rgba(76, 175, 80, 0.1); }
    100% { background-color: transparent; }
}

/* ====================================
   FusedFormations Custom CodeMirror Theme
   Clean, minimal syntax highlighting
   ==================================== */

/* Base editor styling */
.cm-s-fusedformations {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #1d1d1f;
    background-color: #ffffff;
}

.cm-s-fusedformations .CodeMirror-gutters {
    background-color: #fafafa;
    border-right: 1px solid #e5e5e7;
    padding-right: 8px;
}

.cm-s-fusedformations .CodeMirror-linenumber {
    color: #86868b;
    font-size: 12px;
}

.cm-s-fusedformations .CodeMirror-cursor {
    border-left: 2px solid #007AFF;
}

.cm-s-fusedformations .CodeMirror-selected {
    background-color: rgba(0, 122, 255, 0.15);
}

.cm-s-fusedformations .CodeMirror-activeline-background {
    background-color: rgba(0, 122, 255, 0.05);
}

/* Python Syntax Highlighting */

/* Keywords (def, class, if, while, for, import, etc.) */
.cm-s-fusedformations .cm-keyword {
    color: #9B2393;
    font-weight: 600;
}

/* Built-in functions and constants (print, len, True, False, None) */
.cm-s-fusedformations .cm-builtin {
    color: #0066CC;
}

/* Function and class definitions */
.cm-s-fusedformations .cm-def {
    color: #0066CC;
    font-weight: 600;
}

/* Variables and identifiers */
.cm-s-fusedformations .cm-variable {
    color: #1d1d1f;
}

.cm-s-fusedformations .cm-variable-2 {
    color: #5856D6;
}

/* Properties and attributes */
.cm-s-fusedformations .cm-property {
    color: #007AFF;
}

/* Operators (+, -, *, /, =, etc.) */
.cm-s-fusedformations .cm-operator {
    color: #1d1d1f;
}

/* Comments */
.cm-s-fusedformations .cm-comment {
    color: #6C7680;
    font-style: italic;
}

/* Strings */
.cm-s-fusedformations .cm-string {
    color: #D73502;
}

.cm-s-fusedformations .cm-string-2 {
    color: #D73502;
}

/* Numbers */
.cm-s-fusedformations .cm-number {
    color: #1C8C00;
}

/* Atoms (True, False, None) */
.cm-s-fusedformations .cm-atom {
    color: #9B2393;
    font-weight: 600;
}

/* Brackets and punctuation */
.cm-s-fusedformations .cm-bracket {
    color: #1d1d1f;
}

/* Function calls */
.cm-s-fusedformations .cm-variable-3 {
    color: #007AFF;
}

/* Type annotations */
.cm-s-fusedformations .cm-type {
    color: #5856D6;
}

/* Decorators */
.cm-s-fusedformations .cm-meta {
    color: #FF3B30;
}

/* Errors */
.cm-s-fusedformations .cm-error {
    color: #FFFFFF;
    background-color: #FF3B30;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Matching brackets */
.cm-s-fusedformations .CodeMirror-matchingbracket {
    color: #1d1d1f;
    background-color: rgba(0, 122, 255, 0.2);
    font-weight: bold;
}

.cm-s-fusedformations .CodeMirror-nonmatchingbracket {
    color: #FF3B30;
    font-weight: bold;
}

/* Search and replace */
.cm-s-fusedformations .CodeMirror-searching {
    background-color: rgba(255, 204, 0, 0.3);
    outline: 1px solid #FFCC00;
}

/* Special educational features */
.cm-s-fusedformations .cm-tab {
    background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QUXCToH00Y1UgAAAAZiS0dEAP8A/wD/oL2nkwAAABtJREFUCNdjPMnQ/J+BgYGBgYmRgQEIMxAQAABpHgPf8qGFrgAAAABJRU5ErkJggg==) right no-repeat;
}

/* Line wrap indicator */
.cm-s-fusedformations .CodeMirror-wrap pre.CodeMirror-line,
.cm-s-fusedformations .CodeMirror-wrap pre.CodeMirror-line-like {
    word-break: break-word;
}

/* Focus styles for accessibility */
.cm-s-fusedformations.CodeMirror-focused .CodeMirror-selected {
    background-color: rgba(0, 122, 255, 0.2);
}

/* Subtle animation for cursor */
@keyframes cm-blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

.cm-s-fusedformations .CodeMirror-cursor {
    animation: cm-blink 1.2s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .ide-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }
    
    .ide-assistant-panel {
        display: none;
    }
    
    .resize-handle {
        display: none;
    }
    
    .editor-toolbar {
        padding: 0.5rem;
    }
    
    .toolbar-group {
        flex-wrap: wrap;
    }
    
    .help-actions {
        grid-template-columns: 1fr;
    }
}

/* IDE-specific overrides */
body.page-template-page-ide {
    overflow: hidden;
}

body.page-template-page-ide .site-footer {
    display: none;
}