/**
 * Styles for CodeMirror Python Editor
 */

/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --header-height: 80px;
    --footer-height: 40px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Dark theme (default) */
body.dark-theme {
    background-color: #1e1e1e;
    color: #d4d4d4;
}

body.dark-theme header {
    background-color: #2d2d30;
    border-bottom: 1px solid #3e3e42;
}

body.dark-theme footer {
    background-color: #2d2d30;
    border-top: 1px solid #3e3e42;
    color: #858585;
}

body.dark-theme button {
    background-color: #0e639c;
    color: #ffffff;
    border: 1px solid #0e639c;
}

body.dark-theme button:hover {
    background-color: #1177bb;
}

body.dark-theme a {
    color: #4daafc;
}

/* Light theme */
body.light-theme {
    background-color: #ffffff;
    color: #000000;
}

body.light-theme header {
    background-color: #f3f3f3;
    border-bottom: 1px solid #d4d4d4;
}

body.light-theme footer {
    background-color: #f3f3f3;
    border-top: 1px solid #d4d4d4;
    color: #616161;
}

body.light-theme button {
    background-color: #007acc;
    color: #ffffff;
    border: 1px solid #007acc;
}

body.light-theme button:hover {
    background-color: #005a9e;
}

body.light-theme a {
    color: #0066cc;
}

/* Header */
header {
    min-height: var(--header-height);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.sample-selector {
    display: flex;
    gap: 4px;
    align-items: center;
    min-width: 0;
}

.sample-selector select {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.board-selector {
    display: flex;
    gap: 4px;
    align-items: center;
}

.board-selector label,
.typecheck-selector label {
    font-size: 13px;
    font-weight: 500;
}

.typecheck-selector {
    display: flex;
    gap: 4px;
    align-items: center;
}

.loading-indicator {
    font-size: 14px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

select {
    padding: 4px 8px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    min-width: auto;
}

body.dark-theme select {
    background-color: #3c3c3c;
    color: #d4d4d4;
    border: 1px solid #3e3e42;
}

body.dark-theme select:hover {
    background-color: #4a4a4a;
}

body.dark-theme select:focus {
    outline: 2px solid #007acc;
    outline-offset: 2px;
}

body.light-theme select {
    background-color: #ffffff;
    color: #000000;
    border: 1px solid #d4d4d4;
}

body.light-theme select:hover {
    background-color: #f3f3f3;
}

body.light-theme select:focus {
    outline: 2px solid #007acc;
    outline-offset: 2px;
}

button {
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-weight: 500;
}

button:active {
    transform: translateY(1px);
}

button:focus {
    outline: 2px solid #007acc;
    outline-offset: 2px;
}

/* Main content area */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 30px 20px 30px;
}

#editor-container {
    flex: 1;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* CodeMirror specific overrides */
.cm-editor {
    height: 100%;
}

.cm-scroller {
    overflow: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.cm-line {
    padding: 0 4px;
}

/* Diagnostics status bar */
#diagnostics-status {
    padding: 4px 12px;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    flex-shrink: 0;
    opacity: 0.8;
}

#diagnostics-status .count-error { color: #f44; }
#diagnostics-status .count-warning { color: #b8860b; }
#diagnostics-status .count-info { color: #4af; }

/* Footer */
footer {
    height: var(--footer-height);
    padding: 10px 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 13px;
    flex-shrink: 0;
}

footer a {
    text-decoration: none;
    margin-left: 5px;
}

footer a:hover {
    text-decoration: underline;
}

/* Keyboard shortcuts help panel */
#keyboard-help {
    font-size: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid #d4d4d4;
    overflow-y: auto;
    max-height: 200px;
}

#keyboard-help table {
    width: 100%;
    border-collapse: collapse;
}

#keyboard-help th {
    text-align: left;
    padding: 2px 8px;
    font-weight: 600;
    border-bottom: 1px solid #d4d4d4;
}

#keyboard-help td {
    padding: 2px 8px;
}

#keyboard-help kbd {
    display: inline-block;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 11px;
    border-radius: 3px;
    border: 1px solid #999;
    background: #f7f7f7;
    color: #333;
    box-shadow: 0 1px 0 #bbb;
}

body.dark-theme #keyboard-help {
    border-bottom-color: #3e3e42;
}

body.dark-theme #keyboard-help th {
    border-bottom-color: #3e3e42;
}

body.dark-theme #keyboard-help kbd {
    background: #3c3c3c;
    color: #d4d4d4;
    border-color: #555;
    box-shadow: 0 1px 0 #222;
}

/* Lint panel (F8 / Shift-F8 diagnostic navigation) */
.cm-panel.cm-panel-lint {
    background-color: #f5f5f5;
    border-top: 1px solid #d4d4d4;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 13px;
    max-height: 150px;
    overflow-y: auto;
}

.cm-panel.cm-panel-lint ul {
    padding: 0;
    margin: 0;
}

.cm-panel.cm-panel-lint [name="close"] {
    color: #616161;
}

body.dark-theme .cm-panel.cm-panel-lint {
    background-color: #252526;
    border-top: 1px solid #3e3e42;
    color: #d4d4d4;
}

body.dark-theme .cm-panel.cm-panel-lint [name="close"] {
    color: #858585;
}

/* Lint diagnostic tooltip (shown on gutter marker click) */
.cm-tooltip.cm-tooltip-lint {
    background-color: #ffffff;
    color: #1e1e1e;
    border: 1px solid #cccccc;
    border-radius: 4px;
    padding: 4px 8px;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

body.dark-theme .cm-tooltip.cm-tooltip-lint {
    background-color: #2d2d2d;
    color: #e0e0e0;
    border: 1px solid #555555;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

/* LSP Hover Tooltips */
.cm-tooltip.cm-tooltip-hover {
    background-color: #ffffff;
    color: #1e1e1e;
    border: 1px solid #cccccc;
    border-radius: 4px;
    padding: 8px 12px;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    z-index: 1000;
    opacity: 0.98;
}

body.dark-theme .cm-tooltip.cm-tooltip-hover {
    background-color: #2d2d2d;
    color: #e0e0e0;
    border: 1px solid #555555;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    opacity: 0.98;
}

.cm-lsp-hover {
    max-height: 400px;
    overflow-y: auto;
}

.cm-lsp-hover strong {
    color: #0078d4;
    font-weight: 600;
}

body.dark-theme .cm-lsp-hover strong {
    color: #4fc3f7;
}

.cm-lsp-hover pre {
    background-color: #f5f5f5;
    color: #1e1e1e;
    padding: 8px;
    border-radius: 3px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    border: 1px solid #e0e0e0;
}

body.dark-theme .cm-lsp-hover pre {
    background-color: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #404040;
}

.cm-lsp-hover code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    background-color: #f5f5f5;
    color: #1e1e1e;
    padding: 2px 4px;
    border-radius: 2px;
}

body.dark-theme .cm-lsp-hover code {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

.cm-lsp-hover p {
    margin: 6px 0;
}

.cm-lsp-hover a {
    color: #0078d4;
    text-decoration: none;
}

body.dark-theme .cm-lsp-hover a {
    color: #4fc3f7;
}

.cm-lsp-hover a:hover {
    text-decoration: underline;
}

/* Scrollbar styling for hover tooltips */
.cm-lsp-hover::-webkit-scrollbar {
    width: 8px;
}

.cm-lsp-hover::-webkit-scrollbar-track {
    background: transparent;
}

.cm-lsp-hover::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3);
    border-radius: 4px;
}

.cm-lsp-hover::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.5);
}

/* Responsive design */
@media (max-width: 768px) {
    :root {
        --header-height: 120px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    header h1 {
        font-size: 20px;
        text-align: center;
    }

    .controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .sample-selector {
        width: 100%;
    }

    .sample-selector select {
        flex: 1;
        min-width: 0;
    }

    main {
        padding: 0 15px 15px 15px;
    }

    footer {
        padding: 10px 15px;
        font-size: 12px;
    }

    button {
        font-size: 13px;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 18px;
    }

    .controls {
        flex-direction: column;
        gap: 8px;
    }

    .sample-selector {
        width: 100%;
        flex-direction: row;
    }

    button {
        width: 100%;
    }

    .sample-selector button {
        width: auto;
        min-width: 80px;
    }
}

/* Loading state (optional) */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 18px;
}

/* Share dropdown */
.share-wrapper {
    position: relative;
    display: inline-block;
}

.share-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 100;
    min-width: 280px;
    border-radius: 6px;
    padding: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    gap: 6px;
}

.share-dropdown[hidden] {
    display: none;
}

.share-dropdown:not([hidden]) {
    display: flex;
}

body.light-theme .share-dropdown {
    background-color: #ffffff;
    border: 1px solid #d4d4d4;
}

body.dark-theme .share-dropdown {
    background-color: #2d2d30;
    border: 1px solid #3e3e42;
}

.share-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.share-desc {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 6px;
}

.share-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s;
}

body.light-theme .share-option {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
}

body.light-theme .share-option:hover {
    background-color: #e8e8e8;
}

body.dark-theme .share-option {
    background-color: #3c3c3c;
    color: #d4d4d4;
    border: 1px solid #4a4a4a;
}

body.dark-theme .share-option:hover {
    background-color: #4a4a4a;
}

.share-option .share-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.share-copied {
    color: #22c55e !important;
    font-weight: 600;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    header, footer, .controls {
        display: none;
    }

    main {
        padding: 0;
    }

    body {
        height: auto;
    }

    .cm-editor {
        border: none;
        box-shadow: none;
    }
}
