/* Base color variable for the website */
:root {
    --base-color: #363635; /* Dark gray */
}

/* Base layout: viewport-height flexbox structure */
html {
    height: 100vh;
    margin: 0;
}

.base-layout-body {
    height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.base-layout-navbar {
    flex: 0 0 52px;
    height: 52px;
    min-height: 52px;
}

.base-layout-main {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.base-layout-footer {
    flex: 0 0 50px;
    height: 50px;
    min-height: 50px;
    background-color: #f5f5f5;
    border-top: 1px solid #dbdbdb;
    display: flex;
    align-items: center;
}

/* Exercise page layout */
.exercise-page-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
}

.exercise-metadata {
    flex: 0 0 auto;
    padding: 1rem;
    margin: 0 auto;
    width: 100%;
}

.exercise-panels-wrapper {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    justify-content: center;
    padding-bottom: 1rem;
}

/* Wide containers for SQL and metadata */
.sql-wide-container {
    max-width: 1600px;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Standard container for Python, Scala, Open Question */
.exercise-standard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Exercise form page layout */
.exercise-form-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
}

.exercise-form-columns {
    flex: 1 1 auto;
    overflow: hidden;
    margin: 0 !important;
}

.exercise-form-columns .column {
    overflow-y: auto;
    height: 100%;
    padding: 1rem;
}

/* Add v-cloak to hide elements before Vue compiles them */
[v-cloak] {
    display: none;
}

.navbar-item strong {
    font-size: 1.25rem;
}

.section {
    padding-top: 2rem;
    padding-bottom: 1rem;
}

/* Loading animation enhancement */
.button.is-loading::after {
    border-color: transparent transparent #fff #fff !important;
}

/* Success and error text colors */
.has-text-success {
    color: #48c774 !important;
}

.has-text-danger {
    color: #f14668 !important;
}


.exercise .code-editor {
    border: 1px solid #dbdbdb;
    border-radius: 0.2rem;
    overflow: hidden;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* Console styles */
.console-container {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', 'Menlo', 'Consolas', monospace;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.console-history {
    white-space: pre-wrap;
    word-break: break-word;
}

.console-entry {
    margin-bottom: 0;
}

.console-input-line {
    display: flex;
    align-items: center;
    margin-top: 4px;
    width: 100%;
}

.console-prompt {
    flex-shrink: 0;
    margin-right: 8px;
    color: white;
}

/* Aggressive console input styling to override Bulma */
.console-container .console-input,
.console-container input.console-input,
.has-background-black .console-input,
.has-background-black input.console-input,
input[type="text"].console-input {
    flex: 1;
    min-width: 0;
    width: 100% !important;
    max-width: none !important;
    color: white !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-color: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    font-family: inherit;
    font-size: inherit;
}

.console-container .console-input:focus,
.console-container input.console-input:focus,
.has-background-black .console-input:focus,
.has-background-black input.console-input:focus,
input[type="text"].console-input:focus {
    color: white !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.console-input:disabled {
    opacity: 0.5;
}


/* result table styling */
.exercise .table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #dbdbdb;
    border-radius: 0.375rem;
}

.exercise .table-container .table {
    margin-bottom: 0;
}

.exercise .table-container .table thead th {
    background-color: #f5f5f5;
    font-weight: 600;
    border-bottom: 2px solid #dbdbdb;
    position: sticky;
    top: 0;
    z-index: 1;
}

.exercise .table-container .table tbody td {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hints and answers styling */
.exercise .notification code {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
}

.exercise .notification.is-success code {
    background-color: rgba(255, 255, 255, 0.2);
}

.notification.is-danger {
    white-space: pre-wrap;
}


/* Custom styles for the SQL exercise interface */
.exercise-controls {
    flex-wrap: wrap !important; /* Allow buttons to wrap to next line */
}

.exercise-controls .button:disabled {
    background-color: #cccccc; /* A neutral gray color */
    border-color: #cccccc;
    color: #666666; /* Darker text for readability */
    box-shadow: none;
}
.exercise-controls .button:disabled .icon i {
    color: #666666;
}
.exercise-output .table-container {
    max-height: 1200px;
    overflow-y: auto;
}

/* Two-column layout for exercise page (Python, Scala, Open Question, etc.) */
.exercise-container {
    display: flex;
    width: 100%;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
    min-height: 0;
}

.wide-container {
    max-width: 1400px !important; /* Important to override the default max-width */
    margin: 0 auto !important; /* Center the container */
}

.left-panel {
    width: 60%;
    padding-right: 1rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Keep scrolling for left panel content (exercise description, editor, output) */
    min-height: 0;
}

.right-panel {
    width: 40%;
    padding-left: 1rem;
    border-left: 1px solid #dbdbdb;
    display: flex;
    flex-direction: column;
    /* overflow-y: auto; REMOVED - let #chatbot .chat-content handle scrolling */
    min-height: 0;
}

/* chatbot is the container for the chatbot messages */
#chatbot {
    padding: 10px;
    flex: 1 1 auto; /* Allow the chatbot to fill the available space */
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for nested flex scrolling */
    /* Container itself shouldn't scroll; let the inner messages section scroll */
}

#chatbot div p, #chatbot div li {
    padding-bottom: 6px; /* add space btw paragraphs */
}

/* Neutral inline code color; avoid harsh red/overrides from Bulma */
code {
    color: #222;
}

#chatbot code {
    color: #222;
}

/* Inline code from markdown (not within pre) */
:not(pre) > code {
    background-color: #f5f5f5;
    padding: 0.15rem 0.35rem;
    border-radius: 0.25rem;
}

/* Dark mode adjustments for code readability */
@media (prefers-color-scheme: dark) {
    /* Inline code */
    :not(pre) > code,
    #chatbot :not(pre) > code {
        background-color: #2a2a2a;
        color: #eaeaea;
    }

    /* Fenced code blocks (Prism or plain) */
    pre,
    pre code,
    pre[class*="language-"],
    code[class*="language-"] {
        background-color: #1e1e1e !important;
        color: #eaeaea;
    }

    /* Generic code color override */
    code,
    #chatbot code {
        color: #eaeaea;
    }

    /* Notifications containing code */
    .exercise .notification code {
        background-color: rgba(255, 255, 255, 0.08);
        color: #eaeaea;
    }
}

/* Dark mode: minimal overrides for SQL page panels and tables */
@media (prefers-color-scheme: dark) {
    /* Panels */
    .exercise-container-sql .schema-panel,
    .exercise-container-sql .editor-panel,
    .exercise-container-sql .chatbot-panel-sql {
        background-color: #1a1a1a;
        box-shadow: none;
        border: 1px solid #2a2a2a;
    }

    /* Editor chrome */
    .exercise-container-sql .code-editor {
        border-color: #2a2a2a;
    }

    /* Result table */
    .exercise-container-sql .table-container {
        border-color: #2a2a2a;
    }
    .exercise-container-sql .table {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    .exercise-container-sql .table-container .table thead th {
        background-color: #222222 !important;
        color: #dddddd;
        border-bottom: 1px solid #2a2a2a;
    }
}

.user-message {
    background-color: #E8E8E880; /* Light gray background for user messages */

    border-radius: 0.2rem;
    margin-left: auto; /* Pushes the message to the right */
    max-width: 90%; /* Limit the width of the message */
    box-shadow: none;
    border: 1px solid lightgray;
    font-size: 16px;
    padding: 10px;
    text-align: left; /* Explicitly align text to the left */
}

.user-message code {  /* make the code white, so it stands out */
    background-color: white;
}

.assistant-message {
    text-align: left; /* Align text to the left */
    border-radius: 0.2rem;
    margin-right: auto; /* Pushes the message to the left */
    max-width: 90%; /* Limit the width of the message */
    box-shadow: none;
    border: 1px solid lightgray;
    padding: 10px;
    font-size: 16px;
}

/* Scale + Fade animation for new assistant messages */
@keyframes scaleAndFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.assistant-message.message-new {
    animation: scaleAndFadeIn 300ms ease-out;
    transform-origin: top left; /* Anchors the scaling to the top-left corner */
} 

/* Messages area inside chatbot; scrollable and fills available space */
#chatbot .chat-content {
    position: relative;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

/* Floating jump-to-latest button */
#chatbot .jump-to-latest {
    position: sticky;
    bottom: 8px;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.initial-question {
    width: 100%;
    max-width: 100%;
} 

/* Three-panel layout for SQL exercises */
.exercise-container-sql {
    display: grid;
    grid-template-columns: 252px 1fr 500px; /* Schema | Editor/Results | Chatbot */
    gap: 1rem;
    height: 100%;
    min-height: 500px;
    width: 100%;
}

.schema-panel, .editor-panel {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1rem;
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    min-height: 0;
}

.chatbot-panel-sql {
    display: flex;
    flex-direction: column;
    /* overflow-y: auto; REMOVED - let #chatbot .chat-content handle scrolling */
    padding: 1rem;
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    min-height: 0;
}

.schema-summary {
    cursor: pointer;
}

.exercise-description { font-weight: 200; }

/* Teacher course detail visibility styles */
.teacher-course .handle { cursor: grab; }
.teacher-course .sortable-ghost { background: #f0f0f0; opacity: 0.7; }
.teacher-course .exercise-description { margin-left: 45px; }
.teacher-course .is-greyed { color: #9a9a9a; }
.teacher-course .is-greyed a, .teacher-course .is-greyed .tag { color: #b5b5b5; }
.teacher-course .is-greyed .exercise-title { text-decoration: line-through; }

/* Password reset form styles */
.password-reset-form label {
    font-weight: bold;
}
.password-reset-form input {
    margin-bottom: 1em;
    margin-top: 1em;
}

.password-reset-form span.helptext {
    display: block;
}

.password-reset-form .errorlist {
    margin-top: 1em;
    color: #f14668;
    font-weight: bold;
}

.choose-new-password-form {
    min-width: 800px;
}

/* Removed .sticky-footer-nav - footer now in base.html layout */


/* Three-dot typing indicator and helper text */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem;
}
.typing-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7a7a7a;
    opacity: 0.25;
    animation: typing-bounce 1s infinite ease-in-out;
    animation-delay: var(--ti-delay, 0ms);
}
.typing-indicator .helper-text {
    font-size: 0.875rem;
    color: #7a7a7a;
    margin-left: 2px;
}
@keyframes typing-bounce {
    0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* Pathway Recommendation Styling - removed (replaced by Bulma components) */

/* Tooltip styles */
.tooltip-container {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip-icon {
    margin-left: 5px;
    color: #ababab;
    border: 1px solid #ababab;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.tooltip-text {
    visibility: hidden;
    width: 300px;
    background-color: #555;
    color: #fff;
    text-align: justify;
    border-radius: 6px;
    padding: 5px 10px;
    position: absolute;
    z-index: 1070;
    bottom: 125%;
    left: 50%;
    margin-left: -150px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.8rem;
    font-weight: 400;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #555 transparent transparent transparent;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.thumbs-container {
    position: absolute; 
    right: 4px; 
    bottom: -12px;
    display: flex; 
    gap: 0px; 
    background: white;
}
/* Hollow by default; turn solid black when selected */
.assistant-message .thumbs-container .button.is-white .icon i { color: #7a7a7a; }
.assistant-message .thumbs-container .button.is-white.selected .icon i { color: #000; }

/* Auth screens */
.auth-frame {
    background: var(--base-color);
    border: 2px solid var(--base-color);
    border-radius: 2px;
    padding: 10px; /* black frame thickness */
    margin-top: 30px;
}
.auth-grid {
    display: grid;
    grid-template-columns: 180px 1fr; /* logo | content */
    gap: 0;
    background: #fff; /* inner card */
    border-radius: 2px;
    overflow: hidden;
}
.auth-side-logo {
    background: var(--base-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.auth-logo {
    max-width: 170px;
    width: 100%;
    height: auto;
    filter: none;
}
.auth-content {
    padding: 1.25rem 1.25rem 1.5rem 1.25rem;
}

@media (max-width: 768px) {
    .auth-grid { grid-template-columns: 1fr; }
    .auth-side-logo { padding: 0.75rem; }
}

/* Left-align labels and fields in auth forms */
.auth-content .field.is-horizontal .field-label {
    text-align: left;
    justify-content: flex-start;
    flex: 0 0 6rem; /* fixed label column width for alignment */
    align-self: flex-start; /* top align when help text wraps */
}
.auth-content .field.is-horizontal .field-label .label {
    text-align: left;
}
.auth-content .field.is-horizontal .field-body {
    align-items: flex-start;
}
.auth-content .field.is-horizontal { align-items: flex-start; }
.auth-content .field.is-horizontal .field-body .field {
    flex: 1 1 auto; /* ensure input column stretches uniformly */
}
.auth-content .field .help { margin-top: 0.25rem; }

/* Vertically center auth pages */
.auth-container {
    min-height: calc(70vh); /* viewport middle but a bit higher */
    display: flex;
    align-items: center; /* vertical centering */
    justify-content: center; /* center horizontally too */
    margin-top: 0 !important; /* override base mt-5 */
    padding-top: 0;
    padding-bottom: 0;
}
.auth-container .columns {
    width: 100%;
}
.auth-container .auth-frame {
    margin-top: 0; /* cancel extra top gap on auth frame */
}

/* Course detail styles */
.handle { cursor: grab; }
.sortable-ghost { background: #f0f0f0; opacity: 0.7; }
.is-greyed { color: #9a9a9a; }
.is-greyed a, .is-greyed .tag { color: #b5b5b5; }
.is-greyed .exercise-title { text-decoration: line-through; }
.exercise-title-line { font-weight: bold; }
.exercise-list {
    min-height: 50px; /* Make empty lists droppable */
    padding: 10px;
}
.teacher-view .exercise-list {
    border: 1px dashed #dbdbdb;
    border-radius: 4px;
}
.exercise-list:empty {
    background-color: #fafafa;
}
.exercise-list p {
    color: #7a7a7a;
    text-align: center;
}

/* Make whole exercise row clickable without changing appearance */
.exercise-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.exercise-link:hover {
    background-color: #cac8c8;
}

/* Dark mode: ensure readable text on intentionally light boxes */
@media (prefers-color-scheme: dark) {
    .has-background-light .title,
    .box.has-background-light .title,
    .has-background-light h1,
    .has-background-light h2,
    .has-background-light h3,
    .has-background-light h4,
    .has-background-light h5,
    .has-background-light h6 {
        color: #1a1a1a !important;
    }

    .has-background-light strong,
    .box.has-background-light strong {
        color: #1a1a1a !important;
    }
}