:root {
    --primary-color: #4f46e5;
    --secondary-color: #10b981;
    --background-color: #f9fafb;
    --surface-color: #ffffff;
    --text-color: #1f2937;
    --muted-text-color: #6b7280;
    --border-color: #e5e7eb;
    --danger-color: #ef4444;
    --font-family: "Inter", sans-serif;
    --border-radius: 0.5rem;
    --shadow: 0 0.25rem 0.5rem -0.125rem rgb(0 0 0 / 0.1), 0 0.125rem 0.25rem -0.125rem rgb(0 0 0 / 0.1);

    --r-background-color: #fff;
    --r-main-font: "Inter", sans-serif;
    --r-main-font-size: 2.5rem;
    --r-main-color: #1f2937;
    --r-block-margin: 1.5rem;
    --r-heading-margin: 0 0 1.5rem 0;
    --r-heading-font: "Inter", sans-serif;
    --r-heading-color: #1f2937;
    --r-heading-line-height: 1.2;
    --r-heading-letter-spacing: normal;
    --r-heading-text-transform: none;
    --r-heading-text-shadow: none;
    --r-heading-font-weight: 600;
    --r-heading1-text-shadow: none;
    --r-heading1-size: 2.5em;
    --r-heading2-size: 1.5em;
    --r-heading3-size: 1.25em;
    --r-heading4-size: 1em;
    --r-code-font: monospace;
    --r-link-color: #4f46e5;
    --r-link-color-dark: #3730a3;
    --r-link-color-hover: #6366f1;
    --r-selection-background-color: #c7d2fe;
    --r-selection-color: #fff;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

app-shell {
    width: 100%;
    max-width: 80rem;
    margin: 2rem;
}

.lms-container {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.lms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #fdfdff;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    width: 2rem;
    height: 2rem;
}

.lms-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}
        
.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.5rem;
}

.role-switcher {
    display: flex;
    align-items: center;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    border: 1px solid var(--border-color);
}

.role-switcher button {
    padding: 0.5rem 1rem;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-weight: 500;
    border-radius: 0.25rem;
    transition: background-color 0.2s, color 0.2s;
    color: var(--muted-text-color);
}
        
.role-switcher button:not(.active):hover {
    background-color: #eef2ff;
    color: var(--primary-color);
}

.role-switcher button.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 0.125rem 0.25rem 0 rgb(0 0 0 / 0.1), 0 0.125rem 0.125rem -0.125rem rgb(0 0 0 / 0.1);
}

.lms-main {
    padding: 1.5rem;
}
        
.lms-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: right;
    font-size: 0.875rem;
    color: var(--muted-text-color);
}

button, input[type="file"]::file-selector-button {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: var(--font-family);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

button:hover, input[type="file"]::file-selector-button:hover {
    background-color: #4338ca;
}
        
button:disabled {
    background-color: var(--muted-text-color);
    cursor: not-allowed;
}

button.secondary {
    background-color: var(--secondary-color);
}
button.secondary:hover {
    background-color: #059669;
}
button.danger {
    background-color: var(--danger-color);
}
button.danger:hover {
    background-color: #dc2626;
}
        
input[type="text"], input[type="password"], textarea, select {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-sizing: border-box;
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.5;
}
        
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: var(--surface-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

textarea {
    min-height: 25rem;
    resize: vertical;
}

textarea.code-editor {
    background-color: #263238;
    color: #eeffff;
    font-family: monospace;
    font-size: 0.875rem;
    min-height: 35rem;
}

.input-group {
    margin-bottom: 1rem;
}
        
.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

creator-view .creator-layout {
    display: grid;
    grid-template-columns: 18.5rem 1fr;
    gap: 1.5rem;
}
        
.editor-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
.editor-container.with-preview {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.curriculum-list {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: #fdfdff;
}

.curriculum-list-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
        
.curriculum-list-header h3 {
    margin: 0;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.curriculum-items {
    list-style: none;
    padding: 0.5rem;
    margin: 0;
    max-height: 22rem;
    overflow-y: auto;
}

.curriculum-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-radius: 0.25rem;
    cursor: grab;
    border: 1px solid transparent;
    margin-bottom: 0.5rem;
}
.curriculum-item:hover {
    background-color: var(--background-color);
}
.curriculum-item.active {
    background-color: #eef2ff;
    border-color: var(--primary-color);
    font-weight: 600;
}
.curriculum-item.drag-over {
    border-top: 2px solid var(--primary-color);
}
.curriculum-item .item-icon {
    margin-right: 1rem;
}
.curriculum-item .item-title {
    flex-grow: 1;
}

.editor-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.editor-panel .input-group {
    margin-bottom: 1.5rem;
}

.empty-editor-state {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: var(--muted-text-color);
    box-sizing: border-box;
}

.empty-editor-state h3 {
    margin: 0 0 2rem 0;
    color: var(--text-color);
}

.empty-editor-state ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

.empty-editor-state li {
    margin-bottom: 1rem;
}

.empty-editor-state li:last-child {
    margin-bottom: 0;
}

.empty-editor-state li p {
    margin: 0;
}
        
.editor-preview {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    background-color: #fdfdff;
}
        
.editor-preview .reveal {
    height: 100%;
    width: 100%;
}

.creator-actions-panel {
    background-color: var(--surface-color);
    box-shadow: var(--shadow);
    border-radius: var(--border-radius);
}

.action-tabs {
    display: flex;
    position: relative;
    z-index: 1;
}

.action-tabs button {
    flex: 1;
    padding: 1rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-weight: 500;
    color: var(--muted-text-color);
    transition: all 0.2s;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    margin-bottom: -1px;
    margin-right: -1px;
}

.action-tabs button:last-child {
    margin-right: 0;
}

.action-tabs button:hover {
    background-color: #eef2ff;
    color: var(--text-color);
}

.action-tabs button.active {
    color: var(--primary-color);
    background-color: var(--surface-color);
    border-bottom-color: transparent;
}

.action-tab-content {
    display: none;
    padding: 1.5rem;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.action-tab-content.active {
    display: grid;
}

#load-content {
    grid-template-columns: 1fr;
    gap: 2rem;
}

#save-content {
    grid-template-columns: 1fr;
}

.action-group h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}
.action-group p {
    font-size: 0.875rem;
    color: var(--muted-text-color);
    margin-top: 0;
    margin-bottom: 1rem;
    min-height: 3em;
}
.action-group button {
    width: 100%;
}
        
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 37.5rem;
    text-align: center;
}
        
.spinner {
    border: 0.25rem solid rgba(0, 0, 0, 0.1);
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s ease infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.student-welcome-view {
    text-align: center;
}
.load-option-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1.5rem auto;
    max-width: 32rem;
}
.course-loader {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.course-loader select {
    flex-grow: 1;
}
.course-loader button {
    flex-shrink: 0;
    width: auto;
}
        
.student-view-layout {
    display: grid;
    grid-template-columns: 18.5rem 1fr;
    gap: 1.5rem;
    min-height: 75vh;
}

.student-course-header {
    display: flex;
    justify-content: space-between;
    align-items: center; 
}
        
.student-nav {
    border-right: 1px solid var(--border-color);
}
        
.student-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
        
.student-nav li {
    padding: 1rem;
    cursor: pointer;
    border-left: 0.25rem solid transparent;
}
        
.student-nav li:hover {
    background-color: var(--background-color);
}
        
.student-nav li.active {
    border-left-color: var(--primary-color);
    background-color: #eef2ff;
    font-weight: 600;
}

.student-nav li.completed {
    color: var(--muted-text-color);
    text-decoration: line-through;
}

.student-content {
    padding-left: 1.5rem;
}
        
.student-item-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.reveal {
    height: 60vh;
    width: 100%;
}
.reveal .slides {
    text-align: left;
}
.reveal h1, .reveal h2, .reveal h3 {
    text-align: left;
}
.answer-section {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: start;
}

.answer-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
    max-width: 500px;
}

.answer-feedback {
    padding: 1rem;
    border-radius: var(--border-radius);
}
.answer-feedback.correct {
    background-color: #d1fae5;
    color: #065f46;
}
.answer-feedback.incorrect {
    background-color: #fee2e2;
    color: #991b1b;
}

.code-exercise-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.run-code-btn {
    margin: 1rem 0;
}
.test-results-container {
    background: #1f2937;
    color: #f3f4f6;
    padding: 1rem;
    border-radius: var(--border-radius);
    font-family: monospace;
    min-height: 6.5rem;
    max-height: 18.5rem;
    overflow-y: auto;
}
.test-result {
    padding: 0.5rem;
    border-bottom: 1px solid #374151;
}
.test-result:last-child {
    border-bottom: none;
}
.test-result.passed {
    color: #34d399;
}
.test-result.failed {
    color: #f87171;
}

progress-bar {
    display: block;
    width: 100%;
    margin-bottom: 1rem;
}
.progress-bar-container {
    background-color: var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}
.progress-bar-fill {
    background-color: var(--secondary-color);
    height: 0.5rem;
    width: 0%;
    transition: width 0.3s ease-in-out;
}

.update-notification {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 2000;
}
.update-notification button {
    background-color: var(--primary-color);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}
