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

:root {
    /* 藍綠色主題 */
    --primary-color: #0891b2; /* 深藍色 */
    --primary-hover: #0e7490;
    --secondary-color: #059669; /* 翠綠色 */
    --secondary-hover: #047857;
    --accent-color: #06b6d4; /* 天藍色 */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f0f9ff;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 4px solid var(--primary-color);
    border-bottom: 4px solid var(--secondary-color);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ayg-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ayg-emblem {
    width: 80px;
    height: 80px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-md);
    border: 3px solid var(--secondary-color);
}

.sun-symbol {
    font-size: 24px;
    margin-bottom: -5px;
}

.year-text {
    font-size: 12px;
    font-weight: bold;
}

.title-section h1 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 3px;
}

.event-title {
    color: var(--secondary-color);
    font-size: 13px;
    font-weight: 600;
}

.ioc-reference .badge {
    background: var(--secondary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 2px solid var(--primary-color);
}

/* Progress Bar */
.progress-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    position: relative;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--primary-color);
    width: var(--progress, 20%);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Form Sections */
.form-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
    display: none;
    animation: fadeIn 0.3s ease;
}

.form-section.active {
    display: block;
}

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

.form-section h2 {
    color: var(--text-primary);
    font-size: 24px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 14px;
}

.question-label {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.help-text {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 10px;
}

.required {
    color: var(--danger-color);
}

input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Select and Optgroup Styles */
select {
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
}

optgroup {
    font-weight: bold;
    font-style: normal;
    color: var(--primary-color);
    background: var(--bg-color);
}

optgroup option {
    font-weight: normal;
    color: var(--text-primary);
    background: white;
    padding-left: 20px;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.conditional-field {
    margin-top: 10px;
}

/* Mechanism Definitions */
.mechanism-definitions {
    margin-bottom: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    border-right: 4px solid var(--secondary-color);
}

.definition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.definition-item {
    background: white;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    line-height: 1.4;
    box-shadow: var(--shadow-sm);
}

.definition-item strong {
    color: var(--primary-color);
    display: inline-block;
    margin-bottom: 2px;
}

/* Radio and Checkbox Styles - Mobile Optimized */
.radio-group,
.checkbox-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 400;
    padding: 12px 18px;  /* 增大觸控區域 */
    border: 2px solid var(--border-color);
    border-radius: 10px;
    transition: all 0.3s ease;
    min-height: 44px;  /* iOS建議的最小觸控區域 */
    position: relative;
    /* 改善觸控反饋 */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.radio-label:hover,
.checkbox-label:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);  /* 微妙的懸停效果 */
}

.radio-label:active,
.checkbox-label:active {
    transform: translateY(0px);  /* 點擊時的反饋 */
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.2);
}

.radio-label input,
.checkbox-label input {
    margin-right: 10px;
    width: 18px;  /* 增大checkbox/radio大小 */
    height: 18px;
    cursor: pointer;
}

.radio-label input:checked + span,
.checkbox-label input:checked + span {
    color: var(--primary-color);
    font-weight: 500;
}

.consent.checkbox-label {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

/* Symptom Categories */
.symptom-category {
    margin-bottom: 25px;
    padding: 20px;
    background: var(--bg-color);
    border-radius: 8px;
}

.symptom-category h3 {
    color: var(--text-primary);
    font-size: 18px;
    margin-bottom: 15px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 15px;
    background: #f8f9fa;
    margin-top: 8px;
}

.injury-types-group {
    max-height: 300px;
}

.severity-levels-group {
    max-height: 120px;
}

/* Injury Entry */
.injury-list {
    margin-bottom: 20px;
}

.injury-entry {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.injury-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.injury-header h3 {
    color: var(--text-primary);
    font-size: 18px;
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 10px 16px;  /* 增大觸控區域 */
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;  /* 增大字體 */
    transition: all 0.3s ease;
    min-height: 44px;  /* 最小觸控區域 */
    min-width: 80px;
    /* 改善觸控反饋 */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn-remove:hover {
    background: #dc2626;
}

/* Severity Scale */
.severity-scale {
    margin-top: 10px;
}

.severity-slider {
    width: 100%;
    margin: 15px 0;
}

.severity-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.severity-value {
    text-align: center;
    margin-top: 10px;
    font-weight: 500;
    color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 14px 28px;  /* 增大觸控區域 */
    border: none;
    border-radius: 10px;
    font-size: 16px;  /* 增大字體 */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;  /* 確保最小觸控區域 */
    min-width: 120px;  /* 最小寬度 */
    /* 改善觸控反饋 */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-add {
    background: var(--success-color);
    color: white;
    border: 2px solid var(--secondary-color);
}

.btn-add:hover {
    background: #059669;
    border-color: var(--secondary-color);
    box-shadow: var(--shadow-md);
}

.btn-submit {
    background: var(--primary-color);
    color: white;
    padding: 14px 32px;
    font-size: 16px;
    border: 2px solid var(--secondary-color);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: var(--primary-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Form Navigation */
.form-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Review Section */
.review-section {
    margin-bottom: 30px;
}

.review-section h3 {
    color: var(--text-primary);
    font-size: 20px;
    margin-bottom: 15px;
}

.review-content {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 20px;
}

.review-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.review-item:last-child {
    border-bottom: none;
}

.review-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.review-value {
    color: var(--text-primary);
    font-size: 14px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: white;
    margin-top: 20px;
    font-size: 16px;
}

/* Success Message */
.success-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.success-message.active {
    display: flex;
}

.success-content {
    background: white;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    animation: slideUp 0.3s ease;
}

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

.success-icon {
    width: 80px;
    height: 80px;
    background: var(--success-color);
    color: white;
    font-size: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.success-content h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.success-content p {
    color: var(--text-secondary);
    margin-bottom: 15px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .form-navigation {
        flex-direction: column;
        gap: 10px;
    }

    .btn {
        width: 100%;
    }
}