/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Noto Sans TC', 'Noto Sans JP', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.9;
    color: #212529;
    text-align: left;
    background-color: rgba(204, 202, 169, 0.8);
}

/* Header */
.header {
    background-color: hsla(0, 0%, 100%, 0.8);
    padding: 0.5rem 2rem;
    font-size: 30px;
    font-weight: bold;
    margin-bottom: 30px;
}

/* Main Layout - Side by Side with Resizable Panels */
.main-layout {
    display: flex;
    max-width: 1800px;
    margin: 30px auto;
    padding: 30px;
    align-items: flex-start;
    position: relative;
    gap: 0;
}

/* Left Side - Information */
.info-section {
    width: 35%;
    min-width: 300px;
    max-width: 70%;
    background-color: hsla(0, 0%, 100%, 0.9);
    border-radius: 30px;
    padding: 50px 40px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.24);
    resize: horizontal;
    overflow: auto;
}

/* Resize Handle */
.resize-handle {
    width: 10px;
    background: linear-gradient(90deg, transparent 2px, #ddd 2px, #ddd 4px, transparent 4px, transparent 6px, #ddd 6px, #ddd 8px, transparent 8px);
    cursor: col-resize;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 10px;
    border-radius: 5px;
    transition: background-color 0.2s;
    min-height: 200px;
}

.resize-handle:hover {
    background: linear-gradient(90deg, transparent 2px, #999 2px, #999 4px, transparent 4px, transparent 6px, #999 6px, #999 8px, transparent 8px);
}

.resize-handle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 100%;
    left: -5px;
    cursor: col-resize;
}

/* Prevent text selection during resize */
body.resizing {
    user-select: none;
    cursor: col-resize !important;
}

/* Right Side - Form */
.form-section {
    flex: 1;
    min-width: 400px;
    background-color: hsla(0, 0%, 100%, 0.9);
    border-radius: 30px;
    padding: 50px 80px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.24);
    overflow: auto;
}

/* Container - for results page */
.container {
    max-width: 1500px;
    margin: 30px auto;
    padding: 50px 80px;
    background-color: hsla(0, 0%, 100%, 0.9);
    border-radius: 30px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.24);
}

/* Headings */
h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #003060;
}

h2 {
    color: #003060;
    margin: 20px 0;
}

h3 {
    margin: 10px 0;
}

.warning {
    color: #930000;
    text-align: center;
}

/* Form Styles */
form {
    max-width: 900px;
    margin: 0 auto;
}

label {
    display: block;
    font-size: 20px;
    font-weight: 500;
    margin: 20px 0 10px 0;
    color: #003060;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    max-width: 300px;
    height: 2.5rem;
    font-size: 18px;
    padding: 5px 10px;
    border: 1px solid #d7d7d7;
    border-radius: 5px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

input[type="radio"],
input[type="checkbox"] {
    zoom: 2;
    margin: 0 5px 0 15px;
    cursor: pointer;
}

input[type="file"] {
    margin: 10px 0;
    font-size: 16px;
}

/* Button Styles */
.btn, button[type="submit"] {
    border-radius: 5px;
    padding: 15px 25px;
    font-size: 22px;
    text-decoration: none;
    color: #023738;
    display: inline-block;
    background-color: #bdcca9;
    box-shadow: 0px 5px 0px 0px rgb(164, 185, 136);
    border: 3px solid rgb(164, 185, 136);
    cursor: pointer;
    transition: all 0.2s;
    margin: 30px auto;
    display: block;
}

.btn:active, button[type="submit"]:active {
    transform: translate(0px, 5px);
    -webkit-transform: translate(0px, 5px);
    box-shadow: 0px 1px 0px 0px;
}

.btn:hover, button[type="submit"]:hover {
    background-color: rgb(164, 185, 136);
}

/* Table Styles */
table {
    width: 100%;
    text-align: center;
    border-collapse: collapse;
    margin: 20px 0;
}

table th {
    font-size: 24px;
    font-weight: 600;
    padding: 15px;
    background-color: rgba(204, 202, 169, 0.3);
    border: 1px solid #d7d7d7;
}

table td {
    font-size: 22px;
    padding: 15px;
    border: 1px solid #d7d7d7;
}

table tr:nth-child(even) {
    background-color: rgba(204, 202, 169, 0.1);
}

/* Chart Container */
.chart-container {
    margin: 30px auto;
    padding: 20px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.24);
    max-width: 800px;
}

/* Family Members Section */
#familyMembers {
    margin: 10px 0;
    padding: 15px;
    background-color: rgba(204, 202, 169, 0.1);
    border-radius: 5px;
}

#familyMembers label {
    display: inline-block;
    margin: 5px 15px 5px 0;
    font-size: 18px;
    font-weight: normal;
}

/* Links */
a {
    color: #0072E3;
    text-decoration: none;
}

a:visited {
    color: #0072E3;
}

a:hover {
    color: #003060;
    text-decoration: underline;
}

a:active {
    color: #003060;
}

/* Details/Summary */
details {
    margin: 20px 0;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
}

summary {
    font-size: 28px;
    font-weight: 600;
    color: #003060;
    cursor: pointer;
    margin-bottom: 10px;
}

details p {
    font-size: 18px;
    line-height: 1.6;
    margin: 10px 0;
}

/* Score Input Section with Images */
.score-input-section {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin: 30px 0;
}

.score-input-left {
    flex: 1;
}

.score-input-right {
    flex: 0 0 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Responsive Design */
@media (max-width: 1400px) {
    .main-layout {
        flex-direction: column;
        gap: 30px;
    }
    
    .info-section {
        width: 100%;
        max-width: 100%;
        resize: none;
    }
    
    .resize-handle {
        display: none;
    }
    
    .form-section {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .main-layout {
        padding: 20px 10px;
        gap: 20px;
    }
    
    .info-section,
    .form-section {
        padding: 30px 20px;
        width: 100%;
    }
    
    .container {
        padding: 30px 20px;
        margin: 20px 10px;
    }
    
    .header {
        font-size: 24px;
        padding: 0.5rem 1rem;
    }
    
    table th, table td {
        font-size: 16px;
        padding: 10px 5px;
    }
    
    .btn, button[type="submit"] {
        font-size: 18px;
        padding: 12px 20px;
    }
    
    .chart-container {
        padding: 10px;
    }
    
    .score-input-section {
        flex-direction: column;
    }
    
    .score-input-right {
        flex: 1;
        width: 100%;
    }
}

/* Result Page Specific Styles */
.result-container {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.24);
    overflow: hidden;
    margin-bottom: 20px;
    min-height: 300px;
    width: 90%;
    background-color: hsla(0, 0%, 100%, 0.9);
    border-radius: 30px;
    margin: 30px auto;
    padding: 50px 80px;
    display: flex;
    justify-content: space-around;
    flex-direction: column;
}

.result-table {
    width: 100%;
    text-align: center;
    height: 80%;
}

.chart-row {
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-direction: row;
    gap: 20px;
}

.chart-box {
    border-radius: 10px;
    background-color: white;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.24);
    padding: 20px 20px 0;
    position: relative;
    margin-bottom: 20px;
    flex: 1;
}

@media (max-width: 1600px) {
    .result-container {
        width: 95%;
        padding: 40px 60px;
    }
}

@media (max-width: 1200px) {
    .result-container {
        padding: 30px 40px;
    }
    
    .chart-row {
        flex-direction: column;
    }
    
    .chart-box {
        width: 100%;
        margin: 10px 0;
    }
    
    .chart-box canvas {
        max-width: 100%;
        height: auto !important;
    }
}

@media (max-width: 768px) {
    .result-container {
        padding: 20px;
        margin: 15px auto;
    }
    
    .result-table tr td,
    .result-table tr th {
        font-size: 16px !important;
        padding: 10px 5px;
    }
    
    .result-table p {
        font-size: 14px !important;
    }
    
    h3 span {
        font-size: 16px !important;
    }
}

/* Loading Spinner */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.active {
    display: block;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #003060;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Error Messages */
.error {
    color: #930000;
    font-weight: bold;
    padding: 10px;
    margin: 10px 0;
    background-color: rgba(255, 0, 0, 0.1);
    border-radius: 5px;
    border-left: 4px solid #930000;
}

/* Success Messages */
.success {
    color: #007700;
    font-weight: bold;
    padding: 10px;
    margin: 10px 0;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    border-left: 4px solid #007700;
}

/* FHIR Status Messages and Integration Styles */
#fhirStatusMessages {
    background-color: rgba(204, 202, 169, 0.15);
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    border: 1px solid rgba(204, 202, 169, 0.3);
    font-size: 16px;
    line-height: 1.6;
}

#fhirStatusMessages > div {
    padding: 5px 0;
    border-bottom: 1px solid rgba(204, 202, 169, 0.2);
}

#fhirStatusMessages > div:last-child {
    border-bottom: none;
}

/* FHIR Status Types */
.fhir-status {
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 6px;
    font-weight: 500;
    display: none;
}

.fhir-status.fhir-success {
    background-color: rgba(76, 175, 80, 0.1);
    border-left: 4px solid #4caf50;
    color: #2e7d32;
}

.fhir-status.fhir-warning {
    background-color: rgba(255, 193, 7, 0.1);
    border-left: 4px solid #ffc107;
    color: #e65100;
}

.fhir-status.fhir-error {
    background-color: rgba(244, 67, 54, 0.1);
    border-left: 4px solid #f44336;
    color: #c62828;
}

/* Field Status Indicators */
.field-status {
    display: inline-flex;
    align-items: center;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.field-status.fhir {
    background-color: #4caf50;
    border: 2px solid #c8e6c9;
}

.field-status.manual {
    background-color: #ff9800;
    border: 2px solid #ffcc02;
}

.field-status.empty {
    background-color: #757575;
    border: 2px solid #e0e0e0;
}

/* Patient Info Display */
#patientInfo {
    background-color: rgba(3, 48, 96, 0.05);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    border: 1px solid rgba(3, 48, 96, 0.1);
    display: none;
}

#patientInfo h3 {
    color: #003060;
    margin-bottom: 10px;
    font-size: 18px;
}

#patientDetails > div {
    margin: 5px 0;
    padding: 5px 0;
    color: #333;
    font-size: 14px;
}

/* Data Source Status Section */
#dataSourceStatus {
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    border: 1px solid rgba(204, 202, 169, 0.3);
    display: none;
}

#dataSourceStatus h4 {
    color: #003060;
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
}



/* FHIR Notes */
.fhir-note {
    color: #4caf50 !important;
    font-size: 12px !important;
    margin: 2px 0 !important;
    padding: 4px 0;
    font-weight: 500;
}

/* Responsive adjustments for FHIR components */
@media (max-width: 768px) {
    #fhirStatusMessages {
        font-size: 14px;
        padding: 12px;
    }
    
    .field-status {
        width: 10px;
        height: 10px;
    }
    
    #patientInfo,
    #dataSourceStatus {
        padding: 12px;
        margin: 10px 0;
    }
    
    .fhir-status {
        padding: 10px 12px;
        font-size: 14px;
    }
}