/* static/css/style.css */

/* --- Basic Reset & Defaults --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 1.6; color: #24292e; background-color: #ffffff; padding-bottom: 50px; }
.container { max-width: 1100px; margin: 25px auto; padding: 0; background-color: transparent; box-shadow: none; border-radius: 0; }
.hidden { display: none !important; }

/* --- Header --- */
header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; background-color: #24292e; color: #ffffff; padding: 16px 32px; margin-bottom: 25px; border-bottom: 1px solid #d1d5da; }
header h1 { margin: 0; font-size: 1.5em; font-weight: 600; }
#user-stats span { margin-left: 16px; font-size: 0.95em; background-color: rgba(255, 255, 255, 0.1); padding: 6px 12px; border-radius: 6px; }
#user-stats span span { font-weight: bold; background: none; padding: 0; margin-left: 6px; }

/* --- Sections --- */
section { margin-bottom: 25px; padding: 24px; border: 1px solid #d0d7de; border-radius: 6px; background-color: #ffffff; }
section:last-child { margin-bottom: 0; }
section h2, section h3, section h4, section h5 { margin-bottom: 16px; color: #24292e; font-weight: 600; padding-bottom: 8px; border-bottom: 1px solid #eaecef; }
#challenge-selection h2, .code-header h4 { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
#challenge-id-display { border-bottom: none; margin-bottom: 10px; font-size: 1.1em; color: #57606a; }
#challenge-id-display span { font-weight: bold; font-family: monospace; color: #24292e; margin-left: 5px; background-color: #f6f8fa; padding: 2px 6px; border-radius: 4px; border: 1px solid #d0d7de; }

/* --- Buttons --- */
button { padding: 8px 16px; font-size: 14px; font-weight: 500; cursor: pointer; border: 1px solid rgba(27, 31, 36, 0.15); border-radius: 6px; background-color: #f6f8fa; color: #24292e; transition: background-color 0.1s ease-in-out, border-color 0.1s ease-in-out; margin: 0 5px; line-height: 20px; vertical-align: middle; }
button:hover { background-color: #f3f4f6; border-color: rgba(27, 31, 36, 0.15); }
button:disabled { background-color: #f6f8fa; border-color: rgba(27, 31, 36, 0.15); color: #8c959f; cursor: not-allowed; opacity: 0.6; }
.action-buttons button { margin: 0; }
#submit-btn { background-color: #2c974b; border-color: rgba(27, 31, 36, 0.15); color: white; }
#submit-btn:hover { background-color: #258340; }
#next-challenge-btn { background-color: #0969da; border-color: rgba(27, 31, 36, 0.15); color: white; }
#next-challenge-btn:hover { background-color: #0454b4; }
#new-challenge-btn { background-color: #0969da; border-color: rgba(27, 31, 36, 0.15); color: white; }
#new-challenge-btn:hover { background-color: #0454b4; }

/* --- Challenge Controls (Dropdown + New Button) --- */
.challenge-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.challenge-controls label { font-weight: 500; color: #57606a; margin-right: -5px; }
#difficulty-select { padding: 7px 12px; font-size: 14px; border: 1px solid #d0d7de; border-radius: 6px; background-color: #f6f8fa; color: #24292e; cursor: pointer; line-height: 20px; min-width: 100px; }
#difficulty-select:hover { background-color: #f3f4f6; }
#difficulty-select:focus { outline: none; border-color: #0969da; box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.3); }

/* --- Code Header (Above Code) --- */
.code-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 0 5px; }
.code-header h4 { font-size: 1em; font-weight: 400; color: #57606a; }
.code-header .action-buttons { margin: 0; }
.code-header .action-buttons button { font-size: 12px; padding: 5px 10px; }

/* --- Code Comparison Container Layout --- */
#code-comparison-container { display: flex; gap: 0; width: 100%; border: 1px solid #d0d7de; border-radius: 6px; overflow: hidden; }
#code-comparison-container.code-view-mode #vulnerable-code-pane { width: 100%; border-right: none; }
#code-comparison-container.code-view-mode #fixed-code-pane { display: none; }
#code-comparison-container.diff-view-mode #vulnerable-code-pane,
#code-comparison-container.diff-view-mode #fixed-code-pane { width: 50%; flex: 1; border: none; }
#code-comparison-container.diff-view-mode #vulnerable-code-pane { border-right: 1px solid #d0d7de; }
#code-comparison-container.diff-view-mode #fixed-code-pane { display: block; }

/* Styling for individual code panes */
#vulnerable-code-pane, #fixed-code-pane { overflow: hidden; background-color: #ffffff; }
#vulnerable-code-pane pre, #fixed-code-pane pre { margin: 0 !important; border: none !important; border-radius: 0 !important; max-height: 60vh; position: relative; font-size: 13px !important; line-height: 1.5 !important; background-color: #ffffff !important; color: #24292e !important; text-shadow: none !important; white-space: pre !important; word-wrap: normal !important; padding-top: 0.5em !important; padding-bottom: 0.5em !important; padding-right: 1em !important; overflow: auto !important; }
#vulnerable-code-pane pre[class*="language-"].line-numbers,
#fixed-code-pane pre[class*="language-"].line-numbers { padding-left: 4.8em !important; }

/* --- Prism Base Overrides --- */
/* (Keep Prism token styles as they were) */
pre[class*="language-"] .token.comment, pre[class*="language-"] .token.prolog, pre[class*="language-"] .token.doctype, pre[class*="language-"] .token.cdata { color: #6a737d; }
pre[class*="language-"] .token.punctuation { color: #999; }
pre[class*="language-"] .token.namespace { opacity: .7; }
pre[class*="language-"] .token.property, pre[class*="language-"] .token.tag, pre[class*="language-"] .token.boolean, pre[class*="language-"] .token.number, pre[class*="language-"] .token.constant, pre[class*="language-"] .token.symbol, pre[class*="language-"] .token.deleted { color: #905; }
pre[class*="language-"] .token.selector, pre[class*="language-"] .token.attr-name, pre[class*="language-"] .token.string, pre[class*="language-"] .token.char, pre[class*="language-"] .token.builtin, pre[class*="language-"] .token.inserted { color: #690; }
pre[class*="language-"] .token.operator, pre[class*="language-"] .token.entity, pre[class*="language-"] .token.url, .language-css .token.string, .style .token.string { color: #9a6e3a; }
pre[class*="language-"] .token.atrule, pre[class*="language-"] .token.attr-value, pre[class*="language-"] .token.keyword { color: #07a; }
pre[class*="language-"] .token.function, pre[class*="language-"] .token.class-name { color: #DD4A68; }
pre[class*="language-"] .token.regex, pre[class*="language-"] .token.important, pre[class*="language-"] .token.variable { color: #e90; }
pre[class*="language-"] .token.important, pre[class*="language-"] .token.bold { font-weight: bold; }
pre[class*="language-"] .token.italic { font-style: italic; }
pre[class*="language-"] .token.entity { cursor: help; }

/* Line numbers on light background */
.line-numbers .line-numbers-rows { border-right-color: #d0d7de !important; background: #f6f8fa !important; position: absolute; top: 0; left: 0; width: 3.8em; letter-spacing: -1px; border-right: 1px solid #d0d7de; user-select: none; padding-top: 0.5em !important; height: 100%; }
.line-numbers-rows > span { display: block; counter-increment: linenumber; padding-right: 0.8em; text-align: right; line-height: 1.5; }
.line-numbers-rows > span:before { content: counter(linenumber); color: rgba(27, 31, 36, 0.3) !important; display: block; text-align: right; }


/* --- REMOVED ALL Diff Highlighting Styles --- */
/* Rules for .diff-line-removed, .diff-line-added, ::before pseudo-elements removed */


/* --- Assessment Area --- */
/* Styles for the inline assessment form */
.assessment-inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
 .assessment-inline-form label { font-weight: 500; margin-right: 0; flex-shrink: 0; }
 .assessment-inline-form select { padding: 7px 12px; font-size: 14px; border: 1px solid #d0d7de; border-radius: 6px; background-color: #f6f8fa; color: #24292e; cursor: pointer; line-height: 20px; min-width: 250px; flex-grow: 1; }
 .assessment-inline-form button { margin-top: 0 !important; flex-shrink: 0; }

/* --- Results Area --- */
#results-area { background-color: #f6f8fa; border-color: #d0d7de; }
#feedback-message { font-size: 1.1em; font-weight: 600; margin-bottom: 15px; padding: 10px 15px; border-radius: 6px; border: 1px solid transparent; }
#feedback-message.correct { color: #1a7f37; background-color: #dafbe1; border-color: #86e89a; }
#feedback-message.incorrect { color: #bc2c3a; background-color: #ffe3e6; border-color: #ffb1b8; }
#score-breakdown, #correct-answer { font-size: 1em; margin-bottom: 12px; color: #57606a; }
#correct-answer span { font-weight: 600; font-family: monospace; background-color: #eaecef; padding: 2px 5px; border-radius: 4px; color: #24292e; }
#solution-explanation { padding: 15px; background-color: #ffffff; border: 1px solid #d0d7de; border-radius: 6px; white-space: pre-wrap; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13px; line-height: 1.5; color: #24292e; }

/* --- Messages --- */
#loading-message { font-style: italic; color: #57606a; margin-top: 15px; text-align: center; }
#error-message { color: #cf222e; font-weight: 600; margin-top: 15px; padding: 12px 15px; border: 1px solid #ffb1b8; background-color: #ffe3e6; border-radius: 6px; }

/* --- Basic Responsiveness --- */
@media (max-width: 768px) {
    body { font-size: 14px;}
    .container { width: 100%; padding: 0; margin: 0; box-shadow: none; border-radius: 0; }
    section { margin-bottom: 15px; padding: 15px; border-radius: 0; border-left: 0; border-right: 0; }
    header { flex-direction: column; text-align: center; padding: 10px 15px; border-radius: 0;}
    header h1 { font-size: 1.3em;}
    #user-stats { margin-top: 10px; font-size: 0.9em;}
    pre[class*="language-"] { max-height: 55vh; font-size: 12px;}
    #code-comparison-container { flex-direction: column; gap: 0; border-radius: 0; border-left:0; border-right:0; }
    #code-comparison-container.diff-view-mode #vulnerable-code-pane,
    #code-comparison-container.diff-view-mode #fixed-code-pane { width: 100%; border: none; border-radius: 0;}
    #code-comparison-container.diff-view-mode #vulnerable-code-pane { border-bottom: 1px solid #d0d7de; }
    pre[class*="language-"].line-numbers { padding-left: 4.2em !important; }
    .line-numbers .line-numbers-rows { width: 3.2em; }
    .challenge-controls { flex-wrap: wrap; }
    .assessment-inline-form select { min-width: 200px; }
}

.account-dropdown {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px); /* Optional: slight upward movement on hide */
    transition: opacity 0.2s ease-out, visibility 0s linear 0.2s, transform 0.2s ease-out;
    /*
     opacity transitions over 0.2s.
     visibility changes instantly *after* the 0.2s opacity transition.
     transform also transitions (for the slide effect).
    */
    pointer-events: none; /* Important: prevent clicks when invisible */
}

.group:hover .account-dropdown,
.group:focus-within .account-dropdown { /* :focus-within is good for keyboard navigation */
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition-delay: 0s, 0s, 0s; /* Override any delay when showing */
    pointer-events: auto;
}