/* CSS Reset and base styles */
html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Allow vertical scrolling on desktop */
@media (min-width: 992px) {
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
    }
}

*, *:before, *:after {
    box-sizing: inherit;
}

/* Theme Classes */
:root {
    /* Use site's color palette from style.css */
    --primary-color: #4a6fa5;
    --secondary-color: #166088;
    --accent-color: #5ea3a3;
    --background-color: #f8f9fa;
    --text-color: #333;
    --light-text: #f8f9fa;
    --border-color: #dee2e6;
    
    /* Default light theme for editor area */
    --editor-bg-primary: #ffffff;
    --editor-bg-secondary: #f9f9f9;
    --editor-bg-tertiary: #f3f3f3;
    --editor-text-primary: #2c2c2c;
    --editor-text-secondary: #555555;
    --editor-border-color: #dee2e6;
    --editor-toolbar-bg: #f3f3f3;
    --panel-bg: #f5f7f9;
    --tab-inactive-bg: #e4e4e4;
    --tab-active-bg: var(--primary-color);
    --tab-active-text: #ffffff;
    --tab-inactive-text: #555555;
    --highlight-color: var(--primary-color);
    --highlight-text: #ffffff;
    --gap-color: #ffffff;
    --border-light: rgba(0, 0, 0, 0.2);
    --border-dark: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

body.dark-editor {
    --editor-bg-primary: #1e1e1e;
    --editor-bg-secondary: #252526;
    --editor-bg-tertiary: #2d2d2d;
    --editor-text-primary: #d4d4d4;
    --editor-text-secondary: #cccccc;
    --editor-border-color: #444444;
    --editor-toolbar-bg: #1e1e1e;
    --panel-bg: #252526;
    --tab-inactive-bg: #3c3c3c;
    --tab-active-bg: var(--primary-color);
    --tab-inactive-text: #cccccc;
}

/* Navbar customization is handled by base.html */

/* Hero section for static analysis */
.hero-section {
    background-color: var(--secondary-color);
    margin-bottom: 1.5rem;
}

/* Main layout container */
.main-content {
    position: relative;
    min-height: 600px; /* Minimum height to prevent collapse */
    height: auto; /* Allow content to determine height */
    overflow: visible; /* Allow content to be visible */
    background-color: #ffffff; /* Always white background for the gap, regardless of theme */
    margin-bottom: 20px;
    padding: 20px 0; /* Add some padding */
}

/* Fullscreen container with proper dimensions */
.fullscreen-container {
    display: flex;
    width: 100%;
    min-height: 600px; /* Minimum height */
    height: calc(100vh - 300px); /* Dynamic height but leave room for navbar/footer */
    overflow: visible;
    /* No background color here to let parent's white background show through */
    transition: all 0.3s ease;
    margin: 0 auto;
}

/* Editor panel styles */
.editor-panel {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    height: 100%;
    min-width: 200px; /* Minimum width to prevent squishing */
    margin-right: 15px; /* Gap between editor and tools panel - will be white */
    background-color: var(--editor-bg-primary);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
}

/* Dark mode border color */
body.dark-editor .editor-panel {
    border-color: var(--border-dark);
}

.editor-toolbar {
    display: flex;
    justify-content: space-between; /* Space items evenly */
    align-items: center;
    padding: 8px 12px; /* Increased padding for more height */
    background-color: var(--editor-toolbar-bg);
    border-bottom: 1px solid var(--border-color);
    height: 42px; /* Increased height */
    min-height: 42px; /* Increased min-height */
    position: relative;
    transition: all 0.3s ease;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.editor-buttons {
    display: flex;
    gap: 8px; /* Consistent gap between buttons */
    flex: 1;
    justify-content: center;
    align-items: center; /* Ensure vertical center alignment */
    margin: 0 16px; /* Add margin around button groups */
}

.editor-buttons:first-child {
    justify-content: flex-start;
    margin-left: 12px; /* Extra margin on the left side */
}

.editor-buttons:last-child {
    justify-content: flex-end;
    margin-right: 12px; /* Extra margin on the right side */
    align-items: center; /* Ensure vertical alignment */
    gap: 8px; /* Consistent spacing between buttons */
}

.editor-buttons .btn-outline-secondary {
    border: none;
    color: #555;
    padding: 6px 12px;
    min-width: 50px;
    font-size: 13px;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    background-color: transparent;
    font-weight: 500;
}

.editor-buttons .btn-outline-secondary:hover {
    background-color: var(--editor-bg-tertiary);
    border-color: var(--highlight-color);
    color: var(--highlight-color);
}

.editor-buttons .btn-outline-secondary:focus {
    box-shadow: 0 0 0 2px rgba(14, 99, 156, 0.5);
    outline: none;
}

.editor-buttons .btn-primary,
#run-analysis {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    padding: 6px 16px;
    font-size: 14px;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    font-weight: 500;
    min-width: 150px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.editor-buttons .btn-primary:hover,
#run-analysis:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.editor-buttons .btn-primary:focus,
#run-analysis:focus {
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.5);
    outline: none;
}

/* Removed toolbar-email */

.editor-content {
    flex: 1;
    position: relative;
    display: flex;
    overflow: hidden; /* Prevent scrollbars on the container */
    min-height: 0; /* Critical for Firefox flex child */
    height: calc(100% - 42px); /* Updated for taller toolbar height */
}

#monaco-editor-container {
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 300px); /* Prevent infinite expansion */
    border: none;
    flex: 1; /* Take all available space */
    margin: 0;
    padding: 0; /* Remove padding to match mockup */
    box-sizing: border-box;
    overflow: hidden; /* Prevent scrollbar issues */
}

.editor-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.empty-state-message {
    display: none;
    text-align: center;
    width: 100%;
    padding: 20px;
}

.empty-state-message p {
    font-size: 16px;
    color: var(--editor-text-secondary);
    opacity: 0.7;
    font-style: italic;
    margin: 0;
}

/* Tools panel styles */
.tools-panel {
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    width: 200px; /* Default width - about 2x the RUN ANALYSIS button */
    flex: 0 0 200px; /* Fixed width, don't grow or shrink */
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    height: 100%;
    max-height: calc(100vh - 300px); /* Limit height to viewport minus navbar/footer */
    overflow: hidden;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
}

/* Dark mode border color */
body.dark-editor .tools-panel {
    border-color: var(--border-dark);
}

.tools-panel.expanded {
    flex: 0 0 33.333%; /* Fixed width at 1/3 of total page width when expanded */
    width: 33.333%;
}

/* Header removed as requested */

.tool-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 6px;
    background-color: #f5f7f9;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    justify-content: center;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

.tool-tab {
    padding: 6px 12px;
    background-color: var(--tab-inactive-bg);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--tab-inactive-text);
    transition: all 0.2s ease;
    margin: 2px;
    text-align: center;
    min-width: 70px;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-tab:hover {
    background-color: rgba(74, 111, 165, 0.1);
    color: var(--primary-color);
}

.tool-tab:focus {
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.5);
    outline: none;
}

.tool-tab.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tools-content {
    flex: 1;
    overflow: auto;
    background-color: var(--panel-bg);
    min-height: 0; /* Critical for Firefox flex container */
    height: calc(100% - 38px); /* Subtract navigation and footer heights */
    transition: all 0.3s ease;
}

.tools-footer {
    height: 50px;
    padding: 4px;
    border-top: 1px solid var(--border-color);
    background-color: var(--panel-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.analysis-results {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    background-color: var(--panel-bg);
    color: var(--text-color);
    padding: 16px;
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.tab-pane.active .analysis-results {
    border-left-color: var(--primary-color);
}

.tool-item {
    padding: 10px;
    border-bottom: 1px solid var(--editor-border-color);
    cursor: pointer;
    color: var(--editor-text-primary);
    transition: all 0.3s ease;
}

.tool-item:hover {
    background-color: var(--editor-bg-tertiary);
}

/* Loading indicator */
.loading-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(30, 30, 30, 0.9);
    color: #d4d4d4;
    padding: 25px 30px;
    border-radius: 8px;
    text-align: center;
    z-index: 100;
    border: 1px solid #333;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    min-width: 200px;
}

.loading-spinner .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 0.25em;
}

.loading-spinner p {
    margin-top: 15px !important;
    font-size: 14px;
    font-weight: 500;
}

/* Flow arrow indicator */
.flow-arrow {
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    font-size: 24px;
    color: #0e639c;
    display: block; /* Always visible */
    text-shadow: 0 0 6px rgba(14, 99, 156, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.7;
        transform: translateY(-50%) scale(0.95);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.05);
    }
    100% {
        opacity: 0.7;
        transform: translateY(-50%) scale(0.95);
    }
}

/* Tab styles for the tool output */
.tab-content {
    height: 100%;
}

.tab-pane {
    height: 100%;
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Alert container for messages */
.alert-container {
    max-width: 800px;
    margin: 0 auto;
    z-index: 1000;
}

.alert {
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    border-left: 4px solid;
}

.alert-danger {
    border-left-color: #dc3545;
}

.alert-info {
    border-left-color: #0dcaf0;
}

/* Upload button style */
#upload-file, #fetch-url {
    color: #555;
    border: none;
    background-color: transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    min-width: 120px;
    font-size: 13px;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

#upload-file:hover, #fetch-url:hover {
    background-color: var(--editor-bg-tertiary);
    border-color: var(--highlight-color);
    color: var(--highlight-color);
}

#upload-file .bi, #fetch-url .bi {
    font-size: 14px;
}

/* Footer is handled by base.html */

/* Theme Toggle Button */
#theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    background-color: white;
    padding: 6px 10px;
    border-radius: 4px;
}

#theme-toggle:hover {
    background-color: var(--background-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

body.dark-editor #theme-toggle .bi-moon-fill {
    display: none;
}

body.dark-editor #theme-toggle::before {
    content: "☀️";
    font-size: 14px;
}

body:not(.dark-editor) #theme-toggle::before {
    content: "";
}

/* Styles moved from inline HTML */
.tools-footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 10px;
}

.pip-requirements-dropdown textarea {
    width: 100%;
    height: 100px;
    font-family: monospace;
    resize: vertical;
}

.pip-requirements-dropdown .dropdown-menu {
    background-color: #f5f7f9;
    border: 1px solid rgba(0,0,0,0.2);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 350px;
    right: 0;
    left: auto;
}

.pip-requirements-dropdown .btn {
    color: #555;
    border: none;
    background-color: transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    min-width: 120px;
    font-size: 13px;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.pip-requirements-dropdown .btn:hover {
    background-color: var(--editor-bg-tertiary);
    border-color: var(--highlight-color);
    color: var(--highlight-color);
}

body.dark-editor .pip-requirements-dropdown .dropdown-menu {
    background-color: #252526;
    border-color: #444444;
    color: #d4d4d4;
}

body.dark-editor .pip-requirements-dropdown textarea {
    background-color: #1e1e1e;
    color: #d4d4d4;
    border-color: #444444;
}

body.dark-editor .pip-requirements-dropdown .btn-secondary,
body.dark-editor .pip-requirements-dropdown .btn {
    border-color: #444444;
    color: #d4d4d4;
}

/* Strictness toggle styles */
.strictness-dropdown {
    display: inline-block;
    vertical-align: middle;
}

#strictness-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    vertical-align: middle;
    border: none;
    background-color: transparent;
    color: #555;
    transition: all 0.3s ease;
}

#strictness-toggle:hover {
    background-color: var(--editor-bg-tertiary);
    border-color: var(--highlight-color);
    color: var(--highlight-color);
}

#strictness-toggle:focus {
    box-shadow: 0 0 0 2px rgba(14, 99, 156, 0.5);
    outline: none;
}

#strictness-toggle .bi {
    font-size: 14px;
}

.strictness-dropdown .dropdown-menu {
    min-width: 120px;
    font-size: 13px;
}

.strictness-dropdown .dropdown-item {
    padding: 6px 16px;
    transition: all 0.2s ease;
}

.strictness-dropdown .dropdown-item:hover {
    background-color: var(--primary-color);
    color: white;
}

.strictness-dropdown .dropdown-item.active {
    background-color: var(--primary-color);
    color: white;
}

body.dark-editor .strictness-dropdown .dropdown-menu {
    background-color: #252526;
    border-color: #444444;
    color: #d4d4d4;
}

body.dark-editor .strictness-dropdown .dropdown-item {
    color: #d4d4d4;
}

body.dark-editor .strictness-dropdown .dropdown-item:hover {
    background-color: var(--primary-color);
    color: white;
}