/* css/som-rehearsal.css - V26: Visual Ease Background Fixes */

:root {
    --som-bg: #F4F7F9;
    --som-white: #FFFFFF;
    --som-blue: #164863;
    --som-blue-light: #EAF6FF;
    --som-accent: #427D9D;
    
    /* Badge Colors */
    --badge-green-bg: #E8F5E9; --badge-green-text: #2E7D32;
    --badge-yellow-bg: #FFF8E1; --badge-yellow-text: #F57F17;
    --badge-red-bg: #FFEBEE; --badge-red-text: #C62828;
    --badge-grey-bg: #F5F5F5; --badge-grey-text: #9E9E9E;
    
    /* Time Badge Colors */
    --badge-time-slow-bg: #FFEBEE; --badge-time-slow-text: #C62828;
    --badge-time-fast-bg: #E3F2FD; --badge-time-fast-text: #1976D2;
    --badge-time-avg-bg: #F5F5F5; --badge-time-avg-text: #616161;

    --som-yellow: #FADA34;
    --som-font: 'Lexend', sans-serif;
    --grid-cell-width: 90px;
    --tree-col-width: 340px;
}

body.som-rehearsal-app {
    margin: 0; padding: 0;
    font-family: var(--som-font);
    background-color: var(--som-bg);
    min-height: 100vh;
    height: 100dvh;
    overflow: hidden;
    color: var(--som-blue);
}

.app-view { display: none; height: 100%; width: 100%; flex-direction: column; animation: fadeIn 0.3s ease; overflow-y: auto; }
.app-view.active { display: flex !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- 1. TEACHER LANDING --- */
#view-teacher-landing { justify-content: center; align-items: center; padding: 20px; }
.login-container { background: var(--som-white); padding: 40px; border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.05); width: 100%; max-width: 500px; text-align: center; }
.logo-area h1 { font-family: 'DM Sans', sans-serif; font-weight: 300; margin: 0; font-size: 1.8rem; }
.badge { background: var(--som-blue-light); color: var(--som-blue); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; margin-top: 5px; display: inline-block; }
.welcome-msg { margin: 30px 0; }
.big-select { width: 100%; padding: 15px; font-size: 1.1rem; border-radius: 8px; border: 1px solid #ccc; font-family: var(--som-font); color: var(--som-blue); margin-bottom: 20px; background: var(--som-white);}

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; }
.action-card { color: var(--som-white); border: none; width: 100%; padding: 25px 15px; border-radius: 12px; font-size: 1.1rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 10px; transition: transform 0.2s; height: 100%; }
.action-card:hover { transform: translateY(-3px); box-shadow: 0 4px 15px rgba(22, 72, 99, 0.15); }
.action-card i { font-size: 2rem; }
.action-card small { font-size: 0.75rem; opacity: 0.85; font-weight: normal; margin-top: auto; }
.action-card.primary { background: var(--som-blue); }
.action-card.primary i { color: var(--som-yellow); }
.action-card.secondary-action { background: var(--som-white); border: 2px solid #ddd; color: var(--som-blue); }
.action-card.secondary-action:hover { border-color: var(--som-blue); background: var(--som-blue-light); }
.action-card.secondary-action i { color: var(--som-blue); }
.action-card.secondary-action small { color: #666; }

.secret-trigger { position: fixed; bottom: 20px; right: 20px; width: 40px; height: 40px; opacity: 0.05; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: var(--som-blue); z-index: 9999; }
.secret-trigger:hover { opacity: 1; background: var(--som-white); border-radius: 50%; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }

/* --- 2. DASHBOARD --- */
#view-dashboard { background: var(--som-bg); height: 100vh; overflow: hidden; }
.dashboard-header { background: var(--som-white); border-bottom: 1px solid #eee; padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; height: 60px; flex-shrink: 0; z-index: 30; }
.dash-title { display: flex; align-items: center; gap: 15px; }
.btn-icon-back { background: none; border: 1px solid #eee; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; color: var(--som-blue); display: flex; align-items: center; justify-content: center; transition: background 0.2s;}
.btn-icon-back:hover { background: var(--som-bg); }
.title-text h1 { margin: 0; font-size: 1.2rem; }
.subtitle { color: #888; font-size: 0.8rem; }
.btn-secondary { background: var(--som-white); border: 1px solid #ddd; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 0.8rem; color: #555; transition: all 0.2s; }
.btn-secondary:hover { background: var(--som-bg); border-color: #ccc; color: #333; }

/* Insights Deck */
.insights-deck { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); 
    gap: 15px; 
    padding: 15px 20px; 
    background-color: var(--som-bg); 
    border-bottom: 1px solid #eee; 
    flex-shrink: 0; 
}

.insight-card { background: var(--som-white); border-radius: 10px; padding: 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.03); border: 1px solid #e0e0e0; display: flex; flex-direction: column; justify-content: space-between; }
.insight-label { font-size: 0.75rem; text-transform: uppercase; color: #999; letter-spacing: 0.5px; margin-bottom: 5px; font-weight: 700; }
.insight-value { font-size: 1.1rem; font-weight: 600; color: var(--som-blue); margin-bottom: 10px; line-height: 1.3; }
.insight-action { align-self: flex-start; }
.text-red { color: #C62828; } .text-green { color: #2E7D32; } .text-orange { color: #F57F17; }

.tree-grid-wrapper { flex: 1; overflow: auto; position: relative; background: var(--som-white); height: calc(100% - 180px); }
#tree-grid-table { border-collapse: separate; border-spacing: 0; min-width: 100%; }
#tree-grid-head th { position: sticky; top: 0; background: var(--som-white); z-index: 10; height: 50px; border-bottom: 1px solid #ddd; padding: 0 5px; font-size: 0.85rem; font-weight: 600; color: var(--som-blue); white-space: nowrap; text-align: center; min-width: var(--grid-cell-width); }
.clickable-header { cursor: pointer; transition: background 0.2s; }
.clickable-header:hover { background-color: var(--som-blue-light) !important; color: var(--som-accent); }
#tree-grid-head th.corner-cell { position: sticky; left: 0; top: 0; z-index: 20; width: var(--tree-col-width); min-width: var(--tree-col-width); text-align: left; padding-left: 20px; background: var(--som-white); border-right: 1px solid #eee; box-shadow: 2px 0 5px rgba(0,0,0,0.02); }
.tree-col { position: sticky; left: 0; background: var(--som-white); z-index: 5; border-right: 1px solid #eee; border-bottom: 1px solid #f0f0f0; padding: 8px 10px; width: var(--tree-col-width); max-width: var(--tree-col-width); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; cursor: pointer; user-select: none; box-shadow: 2px 0 5px rgba(0,0,0,0.02); }
.row-book .tree-col { font-weight: 700; background-color: var(--som-white); padding-left: 15px; border-bottom: 1px solid #ddd; }
.row-chapter .tree-col { font-weight: 600; color: #444; padding-left: 35px; }
.row-episode .tree-col { font-weight: 400; color: #666; padding-left: 55px; font-size: 0.8rem; }
.tree-toggle-icon { display: inline-block; width: 16px; text-align: center; color: #ccc; margin-right: 5px; transition: transform 0.2s; }
.expanded .tree-toggle-icon { transform: rotate(90deg); color: var(--som-accent); }
.data-cell { border-bottom: 1px solid #f5f5f5; text-align: center; padding: 6px; height: 40px; vertical-align: middle; background: var(--som-white); }
.status-badge { display: inline-flex; justify-content: center; align-items: center; width: 45px; height: 24px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; cursor: default; transition: transform 0.1s; }
.status-badge:hover { transform: scale(1.1); }
.badge-secure { background-color: var(--badge-green-bg); color: var(--badge-green-text); }
.badge-partial { background-color: var(--badge-yellow-bg); color: var(--badge-yellow-text); }
.badge-insecure { background-color: var(--badge-red-bg); color: var(--badge-red-text); }
.badge-none { background-color: var(--badge-grey-bg); color: var(--badge-grey-text); }
tr:hover .tree-col { background-color: var(--som-bg); }
tr:hover .data-cell { background-color: var(--som-bg); }
.hidden-row { display: none; }
.grid-tooltip { position: fixed; pointer-events: none; z-index: 1000; background: var(--som-white); border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); padding: 12px; min-width: 180px; font-size: 0.85rem; transition: opacity 0.15s ease; }
.grid-tooltip.hidden { opacity: 0; visibility: hidden; }
.tooltip-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; border-bottom: 1px solid #eee; padding-bottom: 6px; }
#tt-student-name { font-weight: bold; color: var(--som-blue); font-size: 0.95rem; }
.mini-badge { padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; font-weight: bold; }
.tt-topic { color: #666; margin-bottom: 4px; line-height: 1.3; }
.tt-status { font-weight: 600; color: #333; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 2000; display: flex; justify-content: flex-end; }
.modal-overlay.hidden { display: none; }
.modal-slide-panel { width: 450px; max-width: 90%; background: var(--som-white); height: 100%; box-shadow: -5px 0 20px rgba(0,0,0,0.1); display: flex; flex-direction: column; animation: slideInRight 0.3s ease; }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.modal-header { padding: 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; background: var(--som-bg); }
.modal-title-group h2 { margin: 0; font-size: 1.5rem; color: var(--som-blue); }
.status-pill { background: var(--badge-green-bg); color: var(--badge-green-text); padding: 3px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; margin-top: 5px; display: inline-block; }
.btn-icon-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #999; }
.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.report-section { margin-bottom: 30px; }
.report-section h3 { font-size: 1.1rem; margin-bottom: 5px; color: var(--som-blue); display: flex; align-items: center; gap: 8px; }
.report-sub { font-size: 0.85rem; color: #888; margin-bottom: 15px; }
.report-list { list-style: none; padding: 0; margin: 0; }
.report-list li { padding: 10px; border: 1px solid #eee; border-radius: 8px; margin-bottom: 8px; font-size: 0.9rem; color: #555; background: var(--som-white); display: flex; justify-content: space-between; align-items: center; }
.rep-info { display: flex; flex-direction: column; }
.rep-title { font-weight: 500; color: #333; }
.rep-badges { display: flex; gap: 8px; align-items: center; }
.badge-time { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.badge-time-slow { background-color: var(--badge-time-slow-bg); color: var(--badge-time-slow-text); }
.badge-time-fast { background-color: var(--badge-time-fast-bg); color: var(--badge-time-fast-text); }
.badge-time-avg { background-color: var(--badge-time-avg-bg); color: var(--badge-time-avg-text); }
.report-list li span.score { font-size: 0.8rem; padding: 2px 6px; font-weight: bold; border-radius: 4px; }
.modal-footer { padding: 20px; border-top: 1px solid #eee; display: flex; gap: 10px; background: var(--som-bg); }

/* --- MANAGER VIEW STYLES --- */
#view-student-manager { background: var(--som-bg); }
.manager-content { padding: 30px; max-width: 1200px; margin: 0 auto; display: flex; gap: 40px; align-items: flex-start; }
.manager-grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.manager-card { background: var(--som-white); padding: 25px; border-radius: 12px; border: 1px solid #eee; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
.manager-card:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); border-color: var(--som-blue-light); }
.mgr-icon { width: 60px; height: 60px; background: var(--som-blue-light); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 15px auto; color: var(--som-blue); font-size: 1.5rem; }
.manager-card h3 { margin: 0 0 10px 0; font-size: 1.1rem; color: var(--som-blue); }
.manager-card p { font-size: 0.9rem; color: #666; line-height: 1.4; margin: 0; }
.roster-preview { flex: 0 0 350px; background: var(--som-white); border-radius: 12px; border: 1px solid #eee; box-shadow: 0 4px 15px rgba(0,0,0,0.04); padding: 20px; display: flex; flex-direction: column; max-height: calc(100vh - 120px); }
.roster-preview h3 { font-size: 1.2rem; margin: 0 0 15px 0; color: var(--som-blue); border-bottom: 2px solid var(--som-blue-light); padding-bottom: 10px; }
.roster-list { overflow-y: auto; flex: 1; }
.roster-item { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #f5f5f5; align-items: center; }
.roster-item:last-child { border-bottom: none; }
.btn-text { background: none; border: none; color: var(--som-accent); font-weight: 600; cursor: pointer; font-size: 0.85rem; }
.btn-text:hover { text-decoration: underline; }

/* --- STUDENT DASHBOARD --- */
#view-pupil-dash { background-color: var(--som-bg); }
#view-pupil-dash header.app-header { background: var(--som-white); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #ddd; box-shadow: 0 2px 4px rgba(0,0,0,0.03); }
#pupil-name-display { font-weight: 700; font-size: 1.2rem; color: var(--som-blue); }
.btn-logout { background: none; border: 1px solid #ddd; border-radius: 20px; padding: 6px 15px; color: #666; cursor: pointer; font-size: 0.85rem; transition: all 0.2s; }
.btn-logout:hover { border-color: var(--som-blue); color: var(--som-blue); }
.dash-content { padding: 25px 20px; max-width: 600px; margin: 0 auto; }
.task-card { background: var(--som-white); padding: 30px; border-radius: 16px; border-left: 6px solid var(--som-yellow); box-shadow: 0 4px 20px rgba(0,0,0,0.06); margin-bottom: 40px; transition: transform 0.2s;}
.task-card:hover { transform: translateY(-2px); }
.task-meta { text-transform: uppercase; font-size: 0.75rem; color: #999; letter-spacing: 1px; margin-bottom: 8px; font-weight: 700; }
.task-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 10px; color: var(--som-blue); line-height: 1.2; }
.task-info { color: #555; margin-bottom: 25px; font-size: 1rem; display: flex; gap: 15px; align-items: center; }
.btn-primary { background: var(--som-blue); color: #fff; border: none; padding: 16px; width: 100%; border-radius: 10px; font-size: 1.2rem; font-weight: 600; cursor: pointer; box-shadow: 0 4px 10px rgba(22, 72, 99, 0.2); transition: background 0.2s, transform 0.1s; }
.btn-primary:hover { background: var(--som-accent); transform: scale(1.01); }
.btn-primary:active { transform: scale(0.98); }
.all-done-card { text-align: center; padding: 40px; background: var(--som-white); border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); color: #888; }
.history-section h3 { font-size: 1.3rem; color: var(--som-blue); margin-bottom: 15px; font-weight: 700; }
.history-list { display: flex; flex-direction: row; gap: 15px; overflow-x: auto; padding-bottom: 15px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.history-item { flex: 0 0 220px; display: flex; flex-direction: column; align-items: flex-start; padding: 18px; background: var(--som-white); border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); border-left: 4px solid transparent; transition: transform 0.2s; scroll-snap-align: start; }
.history-item:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.history-dot { width: 12px; height: 12px; border-radius: 50%; margin-bottom: 10px; flex-shrink: 0; }
.dot-green { background-color: var(--badge-green-text); } .dot-yellow { background-color: var(--badge-yellow-text); } .dot-red { background-color: var(--badge-red-text); }
.h-info { display: flex; flex-direction: column; width: 100%; margin-bottom: 10px; }
.h-date { font-size: 0.7rem; color: #aaa; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.h-title { font-weight: 600; font-size: 1rem; color: #333; line-height: 1.3; white-space: normal; } 
.score { font-weight: 700; font-size: 0.9rem; color: var(--som-blue); background: var(--som-blue-light); padding: 4px 10px; border-radius: 6px; align-self: flex-start; }

/* --- REHEARSAL QUIZ AREA --- */
#view-rehearsal { background: var(--som-bg); flex-direction: column; height: 100vh; overflow: hidden; } 
.progress-bar-container { height: 8px; background: #f0f0f0; width: 100%; flex-shrink: 0; }
.progress-fill { height: 100%; background: var(--som-accent); transition: width 0.3s ease-out; }
.question-container { flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 40px; padding: 30px; max-width: 1200px; margin: 0 auto; width: 100%; position: relative; overflow: hidden; }
.q-area { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 1.6rem; text-align: center; line-height: 1.5; color: var(--som-blue); overflow-y: auto; padding-right: 10px; transition: font-size 0.2s ease;}
.input-area { flex: 0 0 350px; width: 350px; padding: 20px; background: var(--som-white); border-radius: 16px; }
.display-box { background: var(--som-bg); height: 60px; border-radius: 12px; margin-bottom: 15px; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; color: var(--som-blue); border: 2px solid #E0E0E0; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.numpad button { padding: 20px 0; border: none; background: var(--som-white); border-radius: 12px; font-size: 1.4rem; font-weight: 600; cursor: pointer; color: var(--som-blue); box-shadow: 0 4px 0 #E0E0E0; border: 1px solid #E0E0E0; transition: all 0.1s; }
.numpad button:active { transform: translateY(4px); box-shadow: 0 0 0 #E0E0E0; }
.numpad .btn-del { color: #888; font-size: 1.2rem; }
.numpad .btn-enter { background: var(--som-blue); color: var(--som-white); box-shadow: 0 4px 0 #0f354a; border: none; }
.numpad .btn-enter:active { box-shadow: 0 0 0 transparent; }
.feedback-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--som-white); display: flex; justify-content: center; align-items: center; z-index: 100; animation: fadeIn 0.2s; }
.feedback-overlay.hidden { display: none; }
.feedback-card { text-align: center; width: 100%; max-width: 400px; padding: 20px; }
.icon-box { font-size: 5rem; margin-bottom: 20px; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.correct .icon-box { color: #2E7D32; } .correct .icon-box::after { content: '\f00c'; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.incorrect .icon-box { color: #C62828; } .incorrect .icon-box::after { content: '\f00d'; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feedback-text { font-size: 1.8rem; font-weight: 700; margin-bottom: 30px; color: var(--som-blue); line-height: 1.4; }

/* --- SUMMARY VIEW --- */
#view-summary { justify-content: center; align-items: center; background: var(--som-blue); color: #fff; }
.summary-content { text-align: center; width: 100%; max-width: 400px; padding: 30px; }
.completion-icon { font-size: 6rem; color: var(--som-yellow); margin-bottom: 20px; animation: popIn 0.5s; }
.summary-content h2 { margin-bottom: 40px; font-size: 2rem; color: #fff;}
.stats-grid { display: flex; gap: 20px; margin-bottom: 40px; justify-content: center; }
.stat-box { background: rgba(255,255,255,0.1); padding: 15px; border-radius: 12px; min-width: 100px; }
.stat-box .label { display: block; font-size: 0.8rem; opacity: 0.7; margin-bottom: 5px; text-transform: uppercase; color: #fff;}
.stat-box .value { display: block; font-size: 1.5rem; font-weight: 700; color: #fff;}
.summary-content .btn-primary { background: var(--som-yellow); color: var(--som-blue); }

@media (max-width: 900px) {
    .manager-content { flex-direction: column; }
    .roster-preview { width: 100%; flex: 0 0 auto; max-height: 400px; }
    .action-grid { grid-template-columns: 1fr; }
    .insights-deck { grid-template-columns: 1fr; }
    .question-container { flex-direction: column; gap: 20px; padding: 20px; }
    .q-area { height: auto; flex: 1; font-size: 1.3rem; }
    .input-area { width: 100%; max-width: 400px; flex: 0 0 auto; padding: 0; background: none; }
    :root { --tree-col-width: 200px; --grid-cell-width: 60px; }
    .status-badge { width: 30px; font-size: 0.7rem; } .dash-controls { display: none; }
}

/* =========================================
   PUPIL ACCESSIBILITY CONTROLS & THEMES
========================================= */
.pupil-access-bar {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding: 10px 20px 0;
    width: 100%;
    box-sizing: border-box;
}

.pupil-access-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #999; /* Subtle grey */
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 8px;
    padding: 8px 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.pupil-access-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--som-blue);
}

/* Visual Ease Overrides for the Rehearsal App */
body.send-mode-cream {
    --som-bg: #F7E7CE;
    --som-white: #FFFBF0;
    --som-blue: #2C3E50;
    --som-blue-light: #DBC1AD;
    --som-accent: #8A7968;
}

body.send-mode-yellow {
    --som-bg: #FFFACD;
    --som-white: #FFFFE0;
    --som-blue: #000000;
    --som-blue-light: #F0E68C;
    --som-accent: #556B2F;
}

body.send-mode-pink {
    --som-bg: #FFE4E1;
    --som-white: #FFF0F5;
    --som-blue: #4A0E2A;
    --som-blue-light: #E6BECC;
    --som-accent: #A05275;
}

body.send-mode-green {
    --som-bg: #DCFCE7;
    --som-white: #F0FFF4;
    --som-blue: #14532D;
    --som-blue-light: #86EFAC;
    --som-accent: #16A34A;
}