:root {
    --miage-blue: #004a99;
    --miage-blue-dark: #003366;
    --miage-blue-light: #e6f0ff;
    --miage-gold: #c29b40;
    --miage-gray: #f4f4f4;
    --miage-text: #333333;
    --miage-border: #dddddd;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Open Sans', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: white;
    color: var(--miage-text);
    line-height: 1.6;
}

/* Header & Banner */
.login-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: #2d3748;
    color: white;
    font-size: 14px;
}

.btn-logout {
    background: transparent;
    border: 1px solid #718096;
    color: white;
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-logout:hover {
    background: #4a5568;
}

.bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 60px;
    background: white;
    border-bottom: 5px solid var(--miage-blue);
}

.title h1 {
    margin: 0;
    font-size: 32px;
    color: var(--miage-blue);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.title p {
    margin: 4px 0 0;
    color: #666;
}

/* UI Elements */
.grid {
    display: grid;
    grid-template-columns: 320px 1fr 360px 280px;
    gap: 20px;
    padding: 20px;
    align-items: start;
}

.admin-view .grid {
    grid-template-columns: 1fr;
}

.admin-view .card {
    width: 100%;
}

.card {
    background: white;
    border: none;
    border-radius: 0;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,.08);
}

.card h2 {
    margin: 0 0 20px;
    font-size: 20px;
    color: var(--miage-blue);
    border-bottom: 2px solid var(--miage-blue);
    padding-bottom: 10px;
    display: inline-block;
}

.card h3 {
    font-size: 16px;
    margin-top: 20px;
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 15px 0;
    overflow: hidden;
}

label {
    min-width: 70px;
    font-weight: 600;
    color: #444;
}

.assigned-case {
    flex: 1;
    padding: 10px;
    border: 1px dashed var(--miage-blue);
    background: var(--miage-blue-light);
    color: var(--miage-blue-dark);
    font-size: 13px;
}

/* Revealed facts section styling */
#revealedFactsSection {
    max-height: 90vh;
    overflow-y: auto;
}

.revealed-facts-list {
    margin: 15px 0;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
}

.revealed-fact {
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 12px;
    line-height: 1.4;
}

.revealed-fact:last-child {
    border-bottom: none;
}

.revealed-fact-label {
    font-weight: 600;
    color: var(--miage-blue-dark);
    margin-bottom: 3px;
}

.revealed-fact-value {
    color: #555;
    word-wrap: break-word;
}

.indicator-group {
    margin: 15px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 4px;
}

.indicator {
    margin-bottom: 12px;
}

.indicator:last-child {
    margin-bottom: 0;
}

.indicator label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    min-width: auto;
    color: var(--miage-blue-dark);
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--miage-blue), #4ba3e3);
    transition: width 0.3s ease;
    border-radius: 10px;
}

.indicator span {
    font-size: 11px;
    font-weight: 600;
    color: var(--miage-blue-dark);
}

.progress-info {
    margin: 15px 0;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.6;
}

.progress-info strong {
    color: var(--miage-blue-dark);
    font-weight: 700;
}

.teacher-only.hidden,
.student-only.hidden,
.admin-only.hidden,
.not-admin.hidden {
    display: none !important;
}

input, select, textarea {
    flex: 1;
    padding: 10px;
    border: 1px solid #d7dbe7;
    border-radius: 4px;
    font-size: 14px;
    max-width: 100%;
    min-width: 0;
    text-overflow: ellipsis;
}

button {
    padding: 12px 24px;
    border: none;
    background: var(--miage-blue);
    color: #fff;
    border-radius: 0;
    cursor: pointer;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

button:hover:not(:disabled) {
    background: var(--miage-blue-dark);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* Chat Styles */
.hint {
    color: #666;
    font-size: 13px;
    margin-top: 10px;
    font-style: italic;
}

.hint.success {
    color: #15803d;
    background: #f0fdf4;
    padding: 10px;
    border-left: 4px solid #15803d;
    font-style: normal;
    line-height: 1.5;
}

.hint.error {
    color: #b91c1c;
    background: #fef2f2;
    padding: 10px;
    border-left: 4px solid #b91c1c;
    font-style: normal;
    line-height: 1.5;
}

.chat {
    display: flex;
    flex-direction: column;
    min-height: 75vh;
}

.student-view .grid {
    grid-template-columns: 1fr;
}

.student-view .chat {
    min-height: calc(100vh - 220px);
}

.student-view .chatlog {
    min-height: 60vh;
}

.export-top button {
    width: 100%;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.chat-header h2 {
    margin: 0;
    flex: 1;
}

.btn-export-discrete {
    background: transparent;
    border: 1px solid #ccc;
    color: #666;
    padding: 6px 10px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-export-discrete:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: var(--miage-blue);
    color: var(--miage-blue);
}

.btn-export-discrete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-ghost {
    background: transparent;
    color: var(--miage-blue);
    border: 1px solid var(--miage-blue);
    padding: 8px 12px;
    font-size: 11px;
    letter-spacing: 0.3px;
    text-transform: none;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--miage-blue-light);
    box-shadow: none;
}

.chatlog {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--miage-border);
    border-radius: 4px;
    padding: 15px;
    background: #fff;
}

.msg {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
}

.bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 8px;
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 14px;
}

.bubble code {
    background: rgba(0,0,0,0.06);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
}

.bubble pre {
    margin: 8px 0;
    padding: 10px 12px;
    background: rgba(0,0,0,0.06);
    border-radius: 4px;
    overflow-x: auto;
    white-space: pre;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
}

.bubble ul {
    margin: 8px 0 8px 18px;
    padding: 0;
}

.bubble li {
    margin: 4px 0;
}

.msg.student {
    justify-content: flex-end;
    align-items: flex-end;
}

.msg.client {
    align-items: flex-start;
}

.msg.system {
    align-items: center;
}

.msg-meta {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 4px;
}

.msg.student .bubble {
    background: var(--miage-blue);
    color: #fff;
    border-bottom-right-radius: 0;
    box-shadow: 0 2px 5px rgba(0, 74, 153, 0.3);
}

.msg.client .bubble {
    background: #fff;
    color: var(--miage-text);
    border-bottom-left-radius: 0;
    border-left: 5px solid var(--miage-blue);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.msg.system .bubble {
    background: #f1f5f9;
    color: #444;
    font-size: 12px;
    margin: 0 auto;
    text-align: center;
}

.composer {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.composer input {
    border: 1px solid var(--miage-border);
    border-radius: 0;
    padding: 15px;
}

.composer input:focus {
    outline: none;
    border-color: var(--miage-blue);
    box-shadow: 0 0 0 2px var(--miage-blue-light);
}

.chat-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px dashed var(--miage-blue);
    color: var(--miage-blue-dark);
    font-size: 13px;
    margin-top: 10px;
    background: var(--miage-blue-light);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 74, 153, 0.2);
    border-top-color: var(--miage-blue);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results Display */
.pre {
    margin: 10px 0 0;
    background: #f8f9fa;
    color: #333;
    padding: 15px;
    border: 1px solid var(--miage-border);
    border-radius: 4px;
    overflow: auto;
    max-height: 300px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
}

.pre:empty {
    display: none;
}

.hidden {
    display: none !important;
}

.role-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.role-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #444;
}

.admin-users-compact {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.admin-users-header,
.admin-user-row {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 0.6fr 1fr;
    gap: 10px;
    align-items: center;
}

.admin-users-header {
    font-weight: 700;
    color: var(--miage-blue-dark);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.admin-user-row {
    padding: 8px 10px;
    border: 1px solid var(--miage-border);
    background: #fafafa;
    font-size: 13px;
}

.admin-user-row .actions {
    display: flex;
    gap: 8px;
}

.admin-user-row button {
    padding: 8px 10px;
    font-size: 11px;
}

.admin-user-row .danger {
    background: #b91c1c;
}

.admin-user-row .danger:hover {
    background: #991b1b;
}

.assignments-section {
    margin-top: 20px;
}

.assignments-compact {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.assignment-row {
    display: grid;
    grid-template-columns: 1fr 1.6fr 1fr;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--miage-border);
    background: #fafafa;
    font-size: 13px;
}

.assignment-header {
    font-weight: 700;
    color: var(--miage-blue-dark);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: transparent;
    border: none;
    padding: 0;
}

@media (max-width: 1100px) {
    .grid { grid-template-columns: 1fr; }
    .chat { min-height: 60vh; }
}

/* Evaluation Results Styling */
.evaluation-results {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid var(--miage-blue);
    border-radius: 12px;
    padding: 25px;
    margin-top: 15px;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.08);
}

.evaluation-results.hidden {
    display: none;
}

.evaluation-summary {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.score-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-value {
    font-size: 48px;
    font-weight: 800;
    color: var(--miage-blue);
    line-height: 1;
}

.score-total .score-label {
    font-size: 16px;
    color: #666;
    margin-top: 4px;
}

.score-label-main {
    font-size: 18px;
    font-weight: 600;
    color: var(--miage-blue-dark);
    flex: 1;
}

.criteria-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.criterion-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.criterion-item:hover {
    border-color: var(--miage-blue);
    box-shadow: 0 4px 8px rgba(0, 102, 204, 0.1);
}

.criterion-name {
    font-weight: 600;
    color: var(--miage-blue-dark);
    margin-bottom: 8px;
    font-size: 14px;
}

.criterion-score {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.criterion-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 10px;
}

.criterion-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--miage-blue) 0%, #4ba3e3 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.criterion-value {
    font-weight: 700;
    color: var(--miage-blue);
    font-size: 14px;
    min-width: 35px;
    text-align: right;
}

.reasoning-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.reasoning-section.hidden {
    display: none;
}

.reasoning-section h3 {
    color: var(--miage-blue-dark);
    font-size: 16px;
    margin-bottom: 12px;
}

.reasoning-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.reasoning-item {
    background: #f5f5f5;
    border-left: 4px solid var(--miage-blue);
    padding: 12px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
}

.reasoning-criterion {
    font-weight: 600;
    color: var(--miage-blue);
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
}

.reasoning-text {
    color: #555;
}
