/* GENERAL LAYOUT */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

#app-container {
    width: 100%;
    height: 100%;
}

.panel-height {
    height: calc(100vh - 70px);
    overflow-y: auto;
    padding: 1rem;
}

.navigation-panel {
    border-right: 1px solid #ddd;
}

.editor-panel {
    border-right: 1px solid #ddd;
}

.preview-panel {
    background-color: #f5f5f5;
    padding: 1.5rem;
    border-left: 1px solid #dbdbdb;
}

/* NOTIFICATIONS & INDICATORS */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.notification-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
}

.notification-area {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 300px;
    z-index: 9999;
}

.notification-area .notification {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    opacity: 0.95;
    transition: all 0.3s ease;
}

.notification-area .notification:hover {
    opacity: 1;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

:root {
    --saved-color: rgb(72, 199, 116);
    --saved-shadow-color: rgba(72, 199, 116, 0.8);
    --unsaved-color: rgb(255, 221, 87);
    --unsaved-shadow-color: rgba(255, 221, 87, 0.8);
}

.save-status-indicator {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    z-index: 999;
}

.save-status-indicator.saved {
    background-color: var(--saved-color);
    box-shadow: 0 0 8px var(--saved-shadow-color);
}

.save-status-indicator.unsaved {
    background-color: var(--unsaved-color);
    box-shadow: 0 0 8px var(--unsaved-shadow-color);
}

.autosave-indicator {
    position: fixed;
    bottom: 10px;
    left: 10px;
    font-size: 0.8rem;
    color: #888;
}

/* TYPOGRAPHY */
.is-family-monospace,
code,
pre,
.textarea.is-family-monospace,
.input.is-family-monospace {
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 0.95em;
    line-height: 1.5;
}

.light-text {
    color: inherit !important;
}

.section-label {
    font-style: italic;
    padding: 0;
}

/* TASK UI COMPONENTS */
.task-item-container {
    position: relative;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.task-row {
    position: relative;
    padding-right: 0; /* Buttons will overlay content */
}

/* BUTTONS: Shared styles for both hover buttons */
.hover-edit-task-btn, .hover-add-subtask-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 80%;
    max-height: 28px;
    padding: 0 0.5rem;
    background: white;
    border: 1px solid #3273dc;
    color: #3273dc;
    font-size: 0.7rem;
    font-weight: bold;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

/* Button positions */
.hover-edit-task-btn {
    right: 120px;
}

.hover-add-subtask-btn {
    right: 10px;
}

/* Button hover states */
.task-row:hover .hover-add-subtask-btn,
.task-row:hover .hover-edit-task-btn {
    opacity: 1;
}

.hover-add-subtask-btn:hover,
.hover-edit-task-btn:hover {
    background-color: #3273dc;
    color: white;
}

.generate-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    height: 80%;
    padding: 0 0.75rem;
    font-size: 0.8rem;
}

/* TASK ELEMENTS */
.task-header {
    padding: 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    display: block;
    transition: background-color 0.2s;
}

.task-header:hover {
    background-color: #f5f5f5;
}

.task-header.is-active {
    font-weight: bold;
}

.task-header.is-active .task-title {
    font-weight: bold;
}

.task-title {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.task-points {
    margin-right: 0.5rem;
    font-size: 0.85rem;
    color: #666;
}

.task-header.is-active .task-points {
    color: #333;
}

/* MENU & NAVIGATION */
.menu-list {
    margin-left: 0;
    padding-left: 0;
}

.menu-list li a {
    padding-left: 0.75rem;
}

.menu-list li ul {
    border-left: none;
}

.menu-list.status-list {
    margin-top: 1rem;
    border-top: 1px solid #eee;
    padding-top: 0.5rem;
}

.subtask-list {
    margin-left: 1rem;
    padding-left: 0;
}

/* SUBTASKS & SECTIONS: Common styling */
ul.menu-list .subtask-item,
ul.menu-list .section-item {
    position: relative;
    cursor: pointer;
    margin-bottom: 0.25rem;
    border-left: none;
    padding: 0;
    padding-left: 1rem;
    margin-left: -1rem;
}

.subtask-item:hover,
.section-item:hover {
    background-color: #f5f5f5;
    border-radius: 3px;
}

/* Ensure entire row is clickable */
.subtask-item a,
.section-item a {
    display: block;
    padding: 0.3rem 0.5rem;
    padding-left: 1.2rem;
    border-radius: 3px;
    position: relative;
    z-index: 1;
    text-decoration: none;
    color: inherit;
}

/* Prevent background color on link hover */
.subtask-item a:hover,
.section-item a:hover,
.subtask-item:hover a,
.section-item:hover a {
    background-color: transparent;
}

/* Active state styling */
.subtask-item a.is-active,
.section-item a.is-active,
.menu-list a.is-active {
    font-weight: bold;
    color: #333;
    background-color: transparent;
}

.subtask-points {
    margin-left: 0.5rem;
    font-size: 0.85rem;
    color: #666;
}

/* TRIANGLES: For items */
.subtask-item a:before,
.section-item a:before {
    content: "▶";
    font-size: 0.9em;
    position: absolute;
    left: -0.2em;
    top: 50%;
    transform: translateY(-60%);
    width: 0.7em;
    height: 0.7em;
    line-height: 0.7em;
    display: inline-block;
    opacity: 0;
    color: #777;
}

/* Show semi-transparent triangle on hover */
.subtask-item:hover a:before,
.section-item:hover a:before {
    opacity: 0.5;
}

/* Show full triangle when active */
.subtask-item a.is-active:before,
.section-item a.is-active:before {
    opacity: 1;
    color: #333;
}

/* FLEXBOX: Layout for subtask items */
.flex-container {
    display: flex !important;
    align-items: center !important;
    width: 100%;
    overflow: hidden;
}

.item-metadata {
    flex: 0 0 auto;
    white-space: nowrap;
    margin-right: 0.5rem;
}

/* PREVIEW: Sidebar preview styles */
.sidebar-preview {
    font-size: 0.8rem;
    color: #777;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* Crucial for text-overflow with flexbox */
}

.section-preview {
    font-size: 0.9rem;
    font-style: italic;
    color: #777;
}

/* ADD TASK LINK */
.add-task-link {
    display: flex;
    align-items: center;
    color: #3273dc;
    font-size: 0.9rem;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    background-color: #f0f0f0;
}

.add-task-link:hover {
    background-color: #f5f5f5;
    color: #2366d1;
}

.add-task-link .icon {
    margin-right: 0.3rem;
}

/* CONTENT PREVIEW */
.content-preview {
    font-size: 0.9rem;
}

.preview-text {
    color: #555;
    margin-bottom: 0.25rem !important;
    line-height: 1.4;
}

.block-count {
    margin-top: 0.25rem !important;
    font-style: italic;
}

/* BLOCK CONTAINERS & LAYOUT */
.block-wrapper {
    margin-bottom: 1.5rem;
}

.block-editor-container {
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.text-block-container,
.input-block-container {
    padding: 0;
    overflow: hidden;
}

.block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.block-type {
    font-weight: bold;
    font-size: 0.9rem;
    color: #555;
}

.block-actions {
    display: flex;
    gap: 0.25rem;
}

.block-content {
    padding: 0.75rem;
}

/* CONTENT SEQUENCE */
.content-sequence-item {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.75rem;
    background-color: #f9f9f9;
}

/* MARKDOWN EDITOR */
.md-toolbar {
    display: flex;
    flex-wrap: wrap;
    background-color: #f8f8f8;
    border-radius: 4px;
    padding: 4px;
    margin-bottom: 10px;
}

.md-toolbar-group {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.md-toolbar-group:not(:last-child) {
    border-right: 1px solid #ddd;
    padding-right: 8px;
}

.md-btn {
    background: transparent;
    border: none;
    color: #4a4a4a;
    cursor: pointer;
    font-size: 14px;
    margin: 0 2px;
    padding: 4px 8px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.md-btn:hover {
    background-color: #eaeaea;
}

.md-btn-bold {
    font-weight: bold;
}

.md-btn-italic {
    font-style: italic;
}

/* AUX-FILE REFERENCE TAGS IN PREVIEW */
code.aux-ref {
    background-color: #e8f4fd;
    border: 1px solid #b8daff;
    border-radius: 3px;
    padding: 0.1em 0.4em;
    font-size: 0.9em;
    color: #0d6efd;
    white-space: nowrap;
}

/* AUX-FILE DROPDOWN IN TOOLBAR */
.md-aux-dropdown .dropdown-menu {
    z-index: 100;
}

.md-aux-dropdown .dropdown-content {
    padding: 0.25rem 0;
}

/* CONTENT STYLING */
.content .katex {
    font-size: 1.1em;
}

.content .katex-display {
    margin: 1em 0;
}

/* AUTO-GROWING TEXTAREA */
.textarea.auto-grow {
    min-height: 60px;
    max-height: 50vh;
    overflow-y: hidden;
    resize: none;
    transition: height 0.15s ease-out;
    line-height: 1.5;
    padding: 0.75rem;
}

/* Sources/references textarea: compact single-line default, grows with content */
.textarea.sources-textarea {
    min-height: 2.5em;
    padding: 0.4rem 0.75rem;
}

/* Coversheet textarea: tall with scroll, capped at viewport */
.coversheet-editor textarea {
    min-height: 50vh;
    max-height: calc(100vh - 280px);
    overflow-y: auto !important;
    resize: vertical;
}

/* UTILITY CLASSES */
[x-cloak] { 
    display: none !important; 
}

/* MEDIA QUERIES */
@media screen and (max-width: 768px) {
    .columns {
        display: block;
    }
    
    .column {
        width: 100% !important;
    }
    
    .panel-height {
        height: auto;
        max-height: 500px;
    }
}

/* Validation Styles */
.validation-summary-panel {
    position: fixed;
    top: 5rem;
    right: 20px;
    width: 500px;
    max-width: 90vw;
    max-height: 0;
    background-color: white;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    transition: max-height 0.3s ease-in-out;
    overflow: hidden;
    z-index: 40;
    border: 1px solid #ddd;
    border-bottom: none;
}

.validation-summary-panel.is-active {
    max-height: 80vh;
}

.validation-header {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.validation-header h3 {
    margin-bottom: 0 !important;
}

.validation-content {
    padding: 10px 15px;
    max-height: calc(80vh - 60px);
    overflow-y: auto;
}

.validation-list {
    margin-top: 10px;
}

.validation-item {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 4px;
}

/* Visual indicators for input validation */
.input.is-danger,
.textarea.is-danger,
.select.is-danger select {
    border-color: #f14668;
}

.help.is-danger {
    color: #f14668;
}

/* For warning indicators in subtask/task list */
.validation-warning-icon {
    margin-left: 5px;
    color: #ffdd57;
}

.validation-error-icon {
    margin-left: 5px;
    color: #f14668;
}

/* Highlighted field animation for validation navigation */
.is-highlighted {
    animation: highlight-pulse 2s;
}

@keyframes highlight-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(241, 70, 104, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(241, 70, 104, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(241, 70, 104, 0);
    }
}

/* FILE MANAGEMENT */
.file-drop-zone {
    border: 2px dashed #dbdbdb;
    border-radius: 6px;
    background-color: #fafafa;
    transition: border-color 0.2s, background-color 0.2s;
    cursor: pointer;
}

.file-drop-zone:hover {
    border-color: #b5b5b5;
    background-color: #f5f5f5;
}

.file-drop-zone.is-dragover {
    border-color: #3273dc;
    background-color: #ebf0fa;
}

.file-drop-zone .file-input {
    display: none;
}

/* Resource/External Code/Feedback block containers */
.resource-block-container,
.external-code-block-container,
.feedback-block-container {
    padding: 0;
    overflow: hidden;
}

/* Resource preview in blocks */
.resource-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.resource-text-preview {
    font-family: 'JetBrains Mono', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.external-code-content {
    font-family: 'JetBrains Mono', monospace;
    white-space: pre;
    word-wrap: break-word;
}

/* Resource thumbnail in modals */
.resource-thumbnail {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.resource-thumbnail:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.resource-thumb-link:hover .icon {
    color: #3273dc;
}

/* Modal table compactness */
.modal-card-body .table td,
.modal-card-body .table th {
    vertical-align: middle;
    padding: 0.4em 0.5em;
}

.modal-card-body .buttons.are-small .button {
    margin-bottom: 0;
}

/* HELP / ABOUT MODAL */
.about-modal-card {
    max-width: 780px;
    width: 92vw;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .12);
    position: relative;
    margin: auto;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.about-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1;
}

.help-layout {
    display: flex;
    min-height: 0;
    flex: 1;
}

.help-nav {
    width: 160px;
    min-width: 160px;
    border-right: 1px solid #f0f0f0;
    padding: 1.5rem 0 1.5rem 0;
    background: #fafafa;
    border-radius: 8px 0 0 0;
}

.help-nav .menu-list a {
    font-size: 0.88rem;
    padding: 0.45rem 1.25rem;
    color: #555;
    border-radius: 0;
    border-left: 3px solid transparent;
}

.help-nav .menu-list a:hover {
    background: #f0f0f0;
    color: #333;
}

.help-nav .menu-list a.is-active {
    background: #eef3fc;
    color: #3273dc;
    font-weight: 600;
    border-left-color: #3273dc;
}

.help-content {
    flex: 1;
    padding: 1.75rem 2rem 1.25rem;
    overflow-y: auto;
    min-height: 0;
}

.help-content h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #222;
    margin-bottom: 1rem;
}

.help-content h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.help-content p,
.help-content li {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.65;
}

.help-content p {
    margin-bottom: 0.75rem;
}

.help-content ul {
    margin-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.help-content li {
    margin-bottom: 0.3rem;
}

.help-content code {
    background: #f5f5f5;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
    color: #c7254e;
}

.help-content strong {
    color: #333;
}

.about-modal-version {
    font-weight: 400;
    color: #888;
    font-size: 0.85rem;
    margin-left: 0.4rem;
}

.about-modal-card a {
    color: #3273dc;
    text-decoration: none;
    border-bottom: 1px solid rgba(50, 115, 220, .25);
}

.about-modal-footer {
    padding: 1rem 2rem 1.25rem;
    border-top: 1px solid #f0f0f0;
}

.about-modal-contact {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.about-modal-contact strong {
    color: #333;
}

.about-modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.about-modal-legal {
    font-size: 0.72rem;
    color: #aaa;
    margin: 0;
}

.about-modal-legal a {
    color: #999;
    border-bottom: none;
}

.about-modal-legal span {
    margin: 0 0.4rem;
}

/* Responsive: stack nav above content on small screens */
@media screen and (max-width: 600px) {
    .about-modal-card {
        max-width: 98vw;
        width: 98vw;
        max-height: 92vh;
    }
    .help-layout {
        flex-direction: column;
    }
    .help-nav {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid #f0f0f0;
        padding: 0.75rem 0;
        border-radius: 8px 8px 0 0;
    }
    .help-nav .menu-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.15rem 0;
    }
    .help-nav .menu-list a {
        padding: 0.35rem 0.9rem;
        border-left: none;
        border-bottom: 2px solid transparent;
    }
    .help-nav .menu-list a.is-active {
        border-left-color: transparent;
        border-bottom-color: #3273dc;
    }
    .help-content {
        padding: 1.25rem 1.25rem 1rem;
    }
}