/* CSS Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Page Management */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-bottom: 20px;
}

.logo {
    height: 80px;
    width: auto;
}

.logo-small {
    height: 40px;
    width: auto;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.header h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
    font-weight: 500;
}

.header h3 {
    font-size: 1.2rem;
    font-weight: 400;
    opacity: 0.9;
}

/* Current Time Display */
.current-time-display {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px 25px;
    border-radius: 10px;
    margin: 20px 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.current-time-display i {
    margin-right: 10px;
    color: #ffd700;
}

.current-time-display span {
    font-size: 1.4rem;
    font-weight: 600;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Login Form */
.login-form {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    margin: 0 auto;
}

.instructions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    border-left: 4px solid #007bff;
}

.instructions h4 {
    color: #007bff;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.instructions li:before {
    content: "•";
    color: #007bff;
    font-weight: bold;
    position: absolute;
    left: 0;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
}

/* Buttons */
.btn-primary, .btn-submit {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover, .btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.3);
}

.btn-submit {
    background: linear-gradient(135deg, #28a745, #20c997);
    margin-top: 20px;
}

.btn-submit:hover {
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
}

/* Exam Header */
.exam-header {
    background: white;
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-bottom: 2px solid #007bff;
}

/* Add top margin to exam content to compensate for fixed header */
.exam-content {
    background: white;
    margin: 100px 20px 20px 20px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.exam-info h3 {
    color: #333;
    margin-bottom: 5px;
}

.student-info {
    color: #666;
    font-size: 0.9rem;
}

.timer-info {
    text-align: right;
}

.time-display {
    color: #666;
    margin-bottom: 5px;
}

.countdown {
    font-size: 1.2rem;
    font-weight: bold;
    color: #dc3545;
}

.countdown.warning {
    color: #fd7e14;
    animation: pulse 1s infinite;
}

.countdown.danger {
    color: #dc3545;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.question-paper {
    padding: 40px;
    max-width: none;
}

/* Paper Header */
.paper-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #eee;
    padding-bottom: 20px;
}

.paper-header h2 {
    color: #333;
    margin-bottom: 20px;
}

.exam-details table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 auto;
    max-width: 800px;
}

.exam-details td {
    padding: 8px 15px;
    text-align: left;
    border: 1px solid #ddd;
}

.exam-details td:nth-child(odd) {
    background-color: #f8f9fa;
    font-weight: 600;
    width: 200px;
}

/* Learning Outcomes */
.learning-outcomes {
    background: #e3f2fd;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    border-left: 4px solid #2196f3;
}

.learning-outcomes h4 {
    color: #1976d2;
    margin-bottom: 15px;
}

.learning-outcomes ul {
    list-style: none;
    padding-left: 0;
}

.learning-outcomes li {
    margin-bottom: 10px;
    padding-left: 20px;
    position: relative;
}

.learning-outcomes li:before {
    content: "✓";
    color: #4caf50;
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Integrity Statement */
.integrity-statement {
    background: #fff3cd;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border-left: 4px solid #ffc107;
}

.integrity-statement blockquote {
    font-style: italic;
    margin: 10px 0;
    padding: 15px;
    background: white;
    border-radius: 5px;
    border-left: 3px solid #ffc107;
}

/* Case Study */
.case-study {
    margin-bottom: 30px;
}

.case-study h3 {
    color: #6f42c1;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f5ff;
    border-radius: 8px;
    border-left: 4px solid #6f42c1;
}

.erd-section {
    margin-bottom: 25px;
}

.erd-section h4 {
    margin-bottom: 15px;
    color: #495057;
}

.erd-container {
    text-align: center;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

.erd-image {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.case-description {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    line-height: 1.8;
}

/* Questions */
.questions {
    margin-bottom: 40px;
}

.question {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.question h3 {
    color: #dc3545;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f8d7da;
}

.question p {
    margin-bottom: 15px;
    line-height: 1.8;
}

.question code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #e83e8c;
}

.sub-question {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #6c757d;
}

.entity-description {
    background: #e8f5e8;
    padding: 20px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #28a745;
}

.entity-description ul {
    list-style: none;
    padding-left: 0;
}

.entity-description li {
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 5px;
    border-left: 3px solid #28a745;
}

/* Hapus style lama yang bentrok */
/* #answerText style sudah dihapus karena tidak dipakai lagi */

/* Question Answer Sections */
.question-answer {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    margin-top: 25px;
    border-left: 4px solid #007bff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.question-answer h4 {
    color: #007bff;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: 600;
}

/* STYLING TEXTAREA ANSWER INPUT - ENHANCED */
textarea.answer-input {
    width: 100% !important;
    min-height: 200px !important;
    max-height: 400px !important;
    padding: 15px !important;
    border: 2px solid #dee2e6 !important;
    border-radius: 8px !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    font-size: 1rem !important;
    line-height: 1.6 !important;
    resize: vertical !important;
    background: #ffffff !important;
    color: #333333 !important;
    transition: all 0.3s ease !important;
    margin-bottom: 15px !important;
    box-sizing: border-box !important;
    display: block !important;
    overflow-y: auto !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

textarea.answer-input:focus {
    outline: none !important;
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15) !important;
    background: #ffffff !important;
}

textarea.answer-input:hover {
    border-color: #adb5bd !important;
}

textarea.answer-input::placeholder {
    color: #6c757d !important;
    font-style: italic !important;
    opacity: 0.8 !important;
}

/* Specific styling untuk semua textarea dengan ID answer */
#answer1, #answer2, #answer3, #answer4 {
    width: 100% !important;
    min-height: 200px !important;
    max-height: 400px !important;
    padding: 15px !important;
    border: 2px solid #dee2e6 !important;
    border-radius: 8px !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    font-size: 1rem !important;
    line-height: 1.6 !important;
    resize: vertical !important;
    background: #ffffff !important;
    color: #333333 !important;
    transition: all 0.3s ease !important;
    margin-bottom: 15px !important;
    box-sizing: border-box !important;
    display: block !important;
    overflow-y: auto !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

#answer1:focus, #answer2:focus, #answer3:focus, #answer4:focus {
    outline: none !important;
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15) !important;
    background: #ffffff !important;
}

#answer1:hover, #answer2:hover, #answer3:hover, #answer4:hover {
    border-color: #adb5bd !important;
}

.save-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #6c757d;
}

.save-status.saved {
    color: #28a745;
}

.save-status.saving {
    color: #ffc107;
}

.save-status.error {
    color: #dc3545;
}

.save-status.unsaved {
    color: #fd7e14;
}

/* Exam Controls */
.exam-controls {
    background: #e9ecef;
    padding: 25px;
    border-radius: 10px;
    margin-top: 30px;
    text-align: center;
    border: 2px solid #dee2e6;
}

.auto-save-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    color: #495057;
    font-weight: 500;
}

.auto-save-info i {
    color: #17a2b8;
}

/* Show ERD Button */
.show-erd-btn {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(111, 66, 193, 0.3);
}

.show-erd-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(111, 66, 193, 0.4);
    background: linear-gradient(135deg, #5a32a3, #4a2c8a);
}

.show-erd-btn i {
    font-size: 1rem;
}

/* ERD Modal */
.erd-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease;
}

.erd-modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.erd-modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.7) translateY(-50px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.erd-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.erd-modal-header h3 {
    color: #6f42c1;
    margin: 0;
    font-size: 1.5rem;
}

.erd-modal-close {
    background: #dc3545;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.erd-modal-close:hover {
    background: #c82333;
    transform: scale(1.1);
}

.erd-modal-image {
    text-align: center;
}

.erd-modal-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Enhanced question styling */ */
.question {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
}

.question::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    border-radius: 10px 10px 0 0;
}

/* Footer Message */
.footer-message {
    text-align: center;
    padding: 30px;
    background: #e3f2fd;
    border-radius: 8px;
    margin-top: 30px;
    border-left: 4px solid #2196f3;
}

.footer-message p {
    margin-bottom: 10px;
}

/* Success Page */
.success-message {
    text-align: center;
    background: white;
    padding: 60px 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    margin: 50px auto;
}

.success-message i {
    font-size: 4rem;
    color: #28a745;
    margin-bottom: 20px;
}

.success-message h2 {
    color: #28a745;
    margin-bottom: 20px;
}

.success-message p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.submission-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

/* Reset untuk textarea jika ada konflik */
textarea {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Override untuk semua browser */
textarea.answer-input,
#answer1, #answer2, #answer3, #answer4 {
    /* Reset browser default */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    
    /* Font yang konsisten */
    font-family: 'Segoe UI', 'Segoe UI Emoji', 'Segoe UI Symbol', system-ui, -apple-system, BlinkMacSystemFont, sans-serif !important;
    
    /* Styling yang dipaksa */
    border-style: solid !important;
    border-width: 2px !important;
    border-image: none !important;
    
    /* Fix untuk scrollbar */
    scrollbar-width: thin !important;
    scrollbar-color: #cbd5e0 #f7fafc !important;
}

/* Custom scrollbar untuk webkit browsers */
textarea.answer-input::-webkit-scrollbar,
#answer1::-webkit-scrollbar, #answer2::-webkit-scrollbar, 
#answer3::-webkit-scrollbar, #answer4::-webkit-scrollbar {
    width: 8px !important;
}

textarea.answer-input::-webkit-scrollbar-track,
#answer1::-webkit-scrollbar-track, #answer2::-webkit-scrollbar-track,
#answer3::-webkit-scrollbar-track, #answer4::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 4px !important;
}

textarea.answer-input::-webkit-scrollbar-thumb,
#answer1::-webkit-scrollbar-thumb, #answer2::-webkit-scrollbar-thumb,
#answer3::-webkit-scrollbar-thumb, #answer4::-webkit-scrollbar-thumb {
    background: #cbd5e0 !important;
    border-radius: 4px !important;
}

textarea.answer-input::-webkit-scrollbar-thumb:hover,
#answer1::-webkit-scrollbar-thumb:hover, #answer2::-webkit-scrollbar-thumb:hover,
#answer3::-webkit-scrollbar-thumb:hover, #answer4::-webkit-scrollbar-thumb:hover {
    background: #a0aec0 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .exam-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header-left {
        flex-direction: column;
        gap: 10px;
    }
    
    .logos {
        gap: 15px;
    }
    
    .logo {
        height: 60px;
    }
    
    .logo-small {
        height: 30px;
    }
    
    .exam-content {
        margin: 10px;
    }
    
    .question-paper {
        padding: 20px;
    }
    
    .exam-details table {
        font-size: 0.9rem;
    }
    
    .exam-details td {
        padding: 6px 10px;
    }
    
    .question {
        padding: 20px;
    }
    
    textarea.answer-input,
    #answer1, #answer2, #answer3, #answer4 {
        min-height: 150px !important;
        padding: 12px !important;
        font-size: 0.9rem !important;
    }

    .btn-submit {
        width: 100%;
    }
    
    /* Mobile responsive for exam header */
    .exam-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
    }
    
    .header-left {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    .timer-info {
        text-align: center;
    }
    
    .exam-content {
        margin: 120px 10px 20px 10px;
    }
    
    /* Modal responsive */
    .erd-modal-content {
        margin: 10px;
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .show-erd-btn {
        font-size: 0.8rem;
        padding: 8px 15px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .header h2 {
        font-size: 1.3rem;
    }
    
    .header h3 {
        font-size: 1rem;
    }
    
    .login-form {
        padding: 30px 20px;
    }
    
    .question-paper {
        padding: 15px;
    }
    
    .exam-details table {
        font-size: 0.8rem;
    }
    
    .question {
        padding: 15px;
    }
    
    textarea.answer-input,
    #answer1, #answer2, #answer3, #answer4 {
        min-height: 120px !important;
        padding: 10px !important;
        font-size: 0.85rem !important;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .exam-header,
    .answer-controls,
    .btn-submit {
        display: none;
    }
    
    .exam-content {
        margin: 0;
        box-shadow: none;
    }
    
    .question-paper {
        padding: 20px;
    }
}

/* Animation for smooth transitions */
.page {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* SEB (Safe Exam Browser) optimizations */
html, body {
    overflow-x: hidden;
}

/* Disable text selection in certain areas */
.exam-header,
.paper-header,
.learning-outcomes,
.integrity-statement {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection in answer area */
#answerText {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Accessibility improvements */
button:focus,
input:focus,
textarea:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .question {
        border: 3px solid #000;
    }
    
    .btn-primary, .btn-submit {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
