/* =========================================
   1. GLOBAL RESET & LAYOUT
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #343a40;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-size: 16px; 
}

.main-container {
    flex: 1;
    width: 100%;
    max-width: 800px;
    margin: 20px auto;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

/* =========================================
   2. HEADER & BRANDING (Restored)
   ========================================= */
.header {
    margin: -30px -30px 30px -30px; 
    border-radius: 12px 12px 24px 24px; 
    padding: 30px; 
    color: white;
    position: relative;
    overflow: hidden;
    text-align: left; 
}

.header-ipos {
    background: linear-gradient(135deg, #0061f2 0%, #00c6f7 100%);
    box-shadow: 0 4px 12px rgba(0, 97, 242, 0.2);
}

.header h1 { font-size: 28px; font-weight: 700; margin: 0 0 10px 0; line-height: 1.2; }
.header p { font-size: 16px; opacity: 0.95; margin: 0; }

.inst-header-container {
    display: flex; /* Changed back to flex to show it */
    align-items: center; gap: 15px; margin-bottom: 20px;
    padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.3);
}

.inst-logo {
    max-height: 60px; max-width: 60px; width: auto;
    border-radius: 8px; background: white; padding: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.inst-info h3 { font-size: 18px; font-weight: 700; margin: 0; line-height: 1.2; }
.inst-info p { font-size: 14px; margin: 2px 0 0 0; opacity: 0.9; }

/* =========================================
   3. NAVIGATION & UI
   ========================================= */
.nav-bar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding: 0 5px;
}
.nav-link {
    text-decoration: none; color: #6c757d; font-weight: 600;
    font-size: 14px; display: flex; align-items: center; gap: 5px;
}
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 12px 24px; border: none; border-radius: 50px; font-weight: 600;
    cursor: pointer; text-decoration: none; font-size: 16px;
}
.btn-buccal { background: linear-gradient(135deg, #0061f2 0%, #00c6f7 100%); color: white; }
.btn-pdf { background: linear-gradient(135deg, #6c757d 0%, #495057 100%); color: white; }

/* =========================================
   4. FORM ELEMENTS
   ========================================= */
.question-card {
    background: #fff; border-radius: 8px; padding: 15px 20px;
    margin-bottom: 20px; border: 1px solid #eef2f6;
}
.q-label { font-weight: 700; color: #2c3e50; margin-bottom: 10px; display: block; font-size: 16px; }
.sub-label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 8px; color: #495057; margin-top: 15px; }

.scale-container { display: flex; justify-content: space-between; gap: 5px; margin: 10px 0; }
.scale-opt { flex: 1; text-align: center; position: relative; }
.scale-opt input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 2; left:0; top:0; }

.scale-opt label {
    display: flex; flex-direction: column; justify-content: center; height: 45px;
    background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px;
    color: #6c757d; font-weight: 400; transition: all 0.2s; font-size: 8px;
}
.scale-opt input:checked + label { background: #e3f2fd; border-color: #0061f2; color: #0061f2; }

.scale-desc { font-size: 11px; font-weight: 700; margin-top: 2px; line-height: 1.1; }

.score-box {
    background: #2c3e50; color: white; padding: 20px; border-radius: 12px;
    margin-top: 30px; display: flex; justify-content: space-between; align-items: center;
}
.score-title { font-size: 14px; opacity: 0.9; text-transform: uppercase; }
.score-val { font-size: 32px; font-weight: 800; color: #00c6f7; }

.other-symptom-row { margin-bottom: 15px; }
.other-input { margin-bottom: 5px; }

/* =========================================
   5. STANDARD FOOTER
   ========================================= */
.standard-footer {
    width: 100%;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 30px 20px;
    font-family: sans-serif;
    font-size: 13px;
    color: #64748b;
    text-align: center;
    margin-top: auto;
    line-height: 1.6;
}
.footer-inner { max-width: 600px; margin: 0 auto; }
.footer-disclaimer {
    border-top: 1px solid #e9ecef; margin-top: 15px; padding-top: 15px; 
    font-style: italic; line-height: 1.5;
}

#blank-qr-header, #qr-section { display: none; }

@media (max-width: 600px) {
    .main-container { margin: 0; border-radius: 0; padding: 15px; }
    .header { margin: -15px -15px 15px -15px; border-radius: 0; }
}

/* =========================================
   6. BASIC PRINT CLEANUP
   ========================================= */
@media print {
    .no-print { display: none !important; }
    
    body { background: white; font-size: 12pt; }
    .main-container { box-shadow: none; border: none; margin: 0; padding: 0; max-width: 100%; }

    #blank-qr-header { 
        display: block !important; margin-bottom: 20px; padding-bottom: 10px; 
        border-bottom: 1px dashed #ccc; text-align: center;
    }
    
    .standard-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        background: white;
    }
}

/* =========================================
   7. PDPA CONSENT MODAL
   ========================================= */
.modal-overlay {
    display: none; 
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-box {
    background: white;
    width: 90%;
    max-width: 500px;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
    animation: fadeIn 0.2s ease-out;
}

.modal-header h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 20px;
    font-weight: 700;
}

.modal-body p {
    font-size: 14px;
    color: #495057;
    line-height: 1.6;
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #0061f2;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-cancel {
    background: #e9ecef;
    color: #495057;
}

.btn-agree {
    background: linear-gradient(135deg, #0061f2 0%, #00c6f7 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 97, 242, 0.3);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   8. QR CODE EXACT WRAPPER STYLE
   ========================================= */
#blank-qrcode, #qrcode {
    display: inline-block !important; 
    background-color: #ffffff !important;
    border-radius: 16px;
    padding: 20px;
    margin: 20px auto;
    text-align: center;
    color-scheme: light only;
    isolation: isolate;
}

#blank-qrcode img, #blank-qrcode canvas,
#qrcode img, #qrcode canvas {
    display: block;
    background-color: #ffffff !important;
    border: 8px solid #ffffff !important;
    border-radius: 8px;
    filter: invert(0) !important; 
}