/* General Body and Font Styling */
:root {
    --primary-color: #0d6efd; /* Blue color for buttons and highlights */
    --secondary-color: #495057; /* Dark gray for header */
    --light-gray: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #212529;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #6f42c1; /* For Marked */
    --clear-response-color: #6c757d; /* Gray for Clear Response */
    --answered-marked-color: #6f42c1;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #eef1f4;
    margin: 0;
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Disable text selection (copy-paste) */
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10+ and Edge */
    user-select: none; /* Standard syntax */
}


/* === CUSTOM MODAL (POPUP) STYLES === */
.modal-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.25);
    text-align: center;
    width: 90%;
    max-width: 450px;
}
.modal-content h3 {
    margin-top: 0;
    color: var(--primary-color);
}
.modal-content p {
    margin: 1rem 0 2rem 0;
    line-height: 1.6;
}
.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}


/* === LOGIN PAGE STYLES === */
.login-page-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.login-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--secondary-color);
    color: #fff;
    padding: 10px 30px;
    flex-shrink: 0;
}
.header-info-left p, .header-info-right p {
    margin: 4px 0;
}
.header-info-left .instruction-text {
    font-size: 0.8rem;
    color: #ccc;
}
.header-info-right {
    display: flex;
    align-items: center;
    gap: 20px;
}
.candidate-photo {
    width: 90px;
    height: 100px;
    border: 3px solid #fff;
    background-color: #eef1f4;
}
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
}
.login-box {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 8px;
}
.login-box h3 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 1.5rem;
    color: var(--secondary-color);
    background-color: var(--light-gray);
    padding: 15px;
    border-radius: 8px 8px 0 0;
    margin: -30px -30px 25px -30px;
    border-bottom: 1px solid var(--border-color);
}
.input-group {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0 10px;
}
.input-group i {
    color: #6c757d;
}
.input-group input {
    border: none;
    outline: none;
    padding: 15px 10px;
    flex-grow: 1;
    font-size: 1rem;
}
.keyboard-icon {
    cursor: pointer;
    transition: color 0.3s;
}
.keyboard-icon:hover {
    color: var(--primary-color);
}
.sign-in-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
}

/* === ON-SCREEN KEYBOARD STYLES === */
.keyboard-container {
    display: none;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;
    background-color: #e1e3e7;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    padding: 10px;
    box-sizing: border-box;
}
.keyboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    font-weight: bold;
}
#keyboard-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 5px;
}
.keyboard-key {
    padding: 15px;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    background-color: #fff;
    box-shadow: 0 2px 2px rgba(0,0,0,0.1);
    cursor: pointer;
    flex-grow: 1;
    min-width: 40px;
    text-align: center;
    transition: background-color 0.2s;
}
.keyboard-key:hover {
    background-color: #f0f0f0;
}
.keyboard-key.key-backspace { flex-grow: 2; }
.keyboard-key.key-shift { flex-grow: 1.5; }
.keyboard-key.key-space { flex-grow: 8; }


/* === INSTRUCTIONS PAGE STYLES === */
.instructions-body {
    background-color: #e9ebee;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.instructions-card {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.instructions-title {
    text-align: center;
    margin-bottom: 25px;
    color: #333;
}

.instructions-content h2 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.2rem;
    color: #444;
}

.legend-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
}

.palette-indicator {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 10px;
    border: 1px solid #ccc;
}

.agreement-container {
    margin-top: 20px;
    text-align: center;
}

#start-test-btn {
    display: block;
    margin: 20px auto 0;
}



/* === TEST PAGE STYLES === */
.test-body-v2 {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    box-sizing: border-box;
}
.test-container {
    width: 100%;
    max-width: 1400px;
    height: 95vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.test-header-v2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--secondary-color);
    color: #fff;
    flex-shrink: 0;
}
.header-left .logo-title {
    font-size: 1.5rem;
    font-weight: 700;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #fff;
    border: 2px solid var(--primary-color);
}
.timer { 
    font-size: 1.3rem; 
    font-weight: 500; 
    color: #fff;
}
.timer.warning-time {
    color: #ffc107;
    font-weight: 700;
}
.subjects-bar {
    display: flex;
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    flex-shrink: 0;
    overflow-x: auto;
}
.subject-tab {
    padding: 1rem 1.5rem;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 500;
    color: #6c757d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}
.subject-tab.active, .subject-tab:hover {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}
.main-content-area {
    display: flex;
    flex: 1;
    overflow-y: hidden;
}
.question-area-v2 {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}
.question-top-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 1.5rem;
}
.question-top-info h3 { margin: 0; font-size: 1rem; color: #6c757d; }
.question-top-info p { margin: 0; font-size: 1rem; }
.question-content #question-number { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
.question-content #question-text { font-size: 1.2rem; margin-bottom: 2rem; line-height: 1.6; }
.options-list { list-style-type: none; padding: 0; }
.option-item label {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}
.option-item input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 1rem;
}
.option-item label:hover { background-color: var(--light-gray); }
.option-item.selected label {
    background-color: #e7f1ff;
    border-color: var(--primary-color);
}
.question-palette-v2 {
    width: 320px;
    padding: 1.5rem;
    background-color: var(--light-gray);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.palette-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.palette-indicator { width: 20px; height: 20px; border-radius: 4px; }
.answered { background-color: var(--success-color); }
.not-answered { background-color: var(--danger-color); }
.not-visited { background-color: #fff; border: 1px solid #ccc; }
.marked { background-color: var(--warning-color); }
.answered-marked {
    background: var(--answered-marked-color);
    position: relative;
}
.answered-marked::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    background: var(--success-color);
    border-radius: 50%;
}
.palette-subject-title {
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: #fff;
    border-radius: 4px;
    text-align: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}
.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    gap: 0.75rem;
    overflow-y: auto;
    flex: 1;
}
.palette-button {
    width: 100%;
    height: 45px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #ccc;
    background-color: #fff;
    color: var(--text-color);
}
.palette-button.current { border: 3px solid var(--primary-color); font-weight: 700; }
.palette-button.not-answered { background-color: var(--danger-color); color: #fff; border-color: var(--danger-color); }
.palette-button.answered { background-color: var(--success-color); color: #fff; border-color: var(--success-color); }
.palette-button.marked { background-color: var(--warning-color); color: #fff; border-color: var(--warning-color); }
.palette-button.answered-marked { background-color: var(--answered-marked-color); color: #fff; border-color: var(--answered-marked-color); position: relative; }
.palette-button.answered-marked::after { content: ''; position: absolute; bottom: 5px; right: 5px; width: 8px; height: 8px; background: var(--success-color); border-radius: 50%; border: 1px solid #fff; }
.test-footer-v2 {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: #fff;
    flex-shrink: 0;
}
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    text-decoration: none;
    color: white;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { background-color: #ccc; cursor: not-allowed; }
.btn-primary { background-color: #0d6efd; color: white; }
.btn-success { background-color: #198754; color: white; }
.btn-warning { background-color: var(--warning-color); color: white; }
.btn-danger { background-color: var(--clear-response-color); color: white; }
.btn-secondary { background-color: var(--clear-response-color); color: white; }


/* === SUMMARY PAGE STYLES === */
.summary-body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    box-sizing: border-box;
}
.summary-card {
    background-color: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 800px;
}
.summary-title { font-size: 2rem; color: #28a745; margin-bottom: 20px; }
.summary-content {
    margin-top: 20px;
    font-size: 1.1rem;
    text-align: left;
    display: inline-block;
}
.summary-content p { margin: 10px 0; display: flex; justify-content: space-between; }
.summary-content strong { margin-right: 20px; }
.correct { color: #28a745; font-weight: bold; }
.wrong { color: #dc3545; font-weight: bold; }
.unattempted { color: #6c757d; }
.detailed-review-container { margin-top: 40px; width: 100%; text-align: left; }
.review-item { background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 8px; padding: 15px; margin-bottom: 15px; }
.review-item p { margin: 5px 0; }
.review-question { font-weight: 500; color: #333; }
.review-option { padding: 5px; border-radius: 4px; margin: 2px 0; border: 1px solid #eee; }
.correct-answer-highlight { background-color: #d4edda; border: 1px solid #c3e6cb; color: #155724; font-weight: bold; }
.user-wrong-answer { background-color: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; text-decoration: line-through; }
.website-logo { max-width: 150px; margin-bottom: 20px; }


/* === MOBILE RESPONSIVENESS (Combined) === */
@media (max-width: 992px) {
    .test-body-v2, .instructions-body-v2, .summary-body { padding: 0; }
    .test-container, .instructions-container, .summary-card {
        height: auto;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        padding: 1rem;
        box-sizing: border-box;
        overflow-y: auto;
    }
    .main-content-area {
        flex-direction: column;
        overflow-y: visible;
    }
    .question-area-v2 {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        overflow-y: visible;
    }
    .question-palette-v2, .palette-grid {
        width: 100%;
        box-sizing: border-box;
        overflow-y: visible;
    }
}
@media (max-width: 768px) {
    .login-header, .test-header-v2 {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 1rem;
    }
    .header-info-right {
        flex-direction: column-reverse;
        text-align: center;
    }
    .keyboard-container {
        max-width: 100%;
    }
    .keyboard-key {
        padding: 10px 5px;
        min-width: 25px;
    }
    .subjects-bar { padding: 0 1rem; }
    .subject-tab { padding: 0.75rem; font-size: 0.9rem; flex-grow: 1; text-align: center; }
    .test-footer-v2 { 
        position: sticky;
        bottom: 0;
        left: 0;
        width: 100%;
        z-index: 100;
        background-color: #fff;
        flex-direction: column; 
        gap: 0.75rem; 
        padding: 1rem;
        box-sizing: border-box;
    }
    .btn { width: 100%; box-sizing: border-box; }
    .instructions-container, .summary-card { padding: 1.5rem; }
    .legend-grid { grid-template-columns: 1fr; }
}
