/* ==========================================================================
   1. 基本レイアウトとタイポグラフィ
   ========================================================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 2em;
    background-color: #f4f7f9;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 2em auto;
    background: #fff;
    padding: 2em;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

h1, h2, h3, h4, h5, h6 {
    color: #2c3e50;
    margin-top: 1.2em;
    margin-bottom: 0.75em;
    line-height: 1.2;
}

h1 { font-size: 2em; text-align: center; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.25em; }
h4 { font-size: 1.1em; }

a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.2s;
}
a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* ==========================================================================
   2. ヘッダーとナビゲーション
   ========================================================================== */
.header {
    display: flex;
    align-items: center;
    padding-bottom: 1.5em;
    margin-bottom: 1.5em;
    border-bottom: 2px solid #e9ecef;
}

.header h1 {
    font-size: 1.8em;
    text-align: left;
    margin: 0;
    flex-grow: 1;
}

.header .actions {
    margin-left: auto;
    display: flex;
    flex-shrink: 0;
}

.back-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 50%;
    text-decoration: none;
    font-size: 24px;
    color: #555;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-right: 1em;
}
.back-button:hover {
    background-color: #e2e6ea;
    border-color: #ccc;
    text-decoration: none;
}

#patient-info {
    flex-grow: 1;
    text-align: center;
    font-size: 1.25em;
    font-weight: 500;
    line-height: 1.4;
}

/* ==========================================================================
   3. ボタン
   ========================================================================== */
.button {
    display: inline-block;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 10px;
}
.button-primary { background-color: #007bff; }
.button-primary:hover { background-color: #0056b3; text-decoration: none; color: white;}
.button-secondary { background-color: #6c757d; }
.button-secondary:hover { background-color: #5a6268; text-decoration: none; color: white; }
.button-success { background-color: #28a745; }
.button-success:hover { background-color: #1e7e34; text-decoration: none; color: white; }
.button-excel { background-color: #1d6f42; }
.button-excel:hover { background-color: #155734; text-decoration: none; color: white; }
.button-danger { background-color: #dc3545; }
.button-danger:hover { background-color: #c82333; text-decoration: none; color: white; }

.submit-button {
    display: block;
    width: 100%;
    padding: 1em 1.5em;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-top: 2em;
}
.submit-button:hover { background-color: #1e7e34; }

/* ==========================================================================
   4. フォームとタブ
   ========================================================================== */
.info-buttons {
    display: flex;
    margin-bottom: 2em;
}
.info-button {
    padding: 12px 20px;
    border: none;
    background-color: #f8f8f8;
    color: #555;
    cursor: pointer;
    flex-grow: 1;
    transition: all 0.2s;
    font-size: 14px;
    border-bottom: 3px solid #ddd;
}
.info-button.basic.active, .info-button.basic:hover { background-color: #28a745; color: white; border-bottom-color: #208038; }
.info-button.medical.active, .info-button.medical:hover { background-color: #17a2b8; color: white; border-bottom-color: #117a8b; }
.info-button.social.active, .info-button.social:hover { background-color: #ffc107; color: #212529; border-bottom-color: #d39e00; }
.info-button.eval.active, .info-button.eval:hover { background-color: #6f42c1; color: white; border-bottom-color: #59359a; }

.info-section > div {
    padding: 1.5em;
    background-color: #fff;
    border: 1px solid #ddd;
    border-top: none;
}

/* ==========================================================================
   5. スイッチパネルと入力エリア
   ========================================================================== */
#toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}
.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    padding: 8px 12px;
    border-radius: 50px;
    cursor: pointer;
    border: 1px solid #ddd;
    transition: all 0.2s;
}
.toggle-label:hover { border-color: #007bff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.toggle-label-text { font-size: 14px; color: #333; }
.toggle-input { display: none; }
.slider { position: relative; width: 44px; height: 24px; background-color: #ccc; border-radius: 24px; transition: background-color 0.3s; }
.slider::before { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; background-color: white; top: 2px; left: 2px; transition: transform 0.3s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.toggle-input:checked + .toggle-label { background-color: #007bff; border-color: #007bff; }
.toggle-input:checked + .toggle-label .toggle-label-text { color: white; font-weight: 600; }
.toggle-input:checked + .toggle-label .slider { background-color: #fff; }
.toggle-input:checked + .toggle-label .slider::before { background-color: #007bff; transform: translateX(20px); }

#active-fields-separator { border: none; height: 1px; background-color: #e9ecef; margin: 30px 0; }
#active-fields-container .active-category-group { margin-bottom: 25px; padding: 20px; background: #fdfdff; border: 1px solid #e0e7ff; border-radius: 8px; }
#active-fields-container .active-category-title { font-size: 1.3em; color: #0056b3; margin-top: 0; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid #e0e7ff; }
#active-fields-container .part-group { margin: 20px 0; }
#active-fields-container .part-name { font-size: 1.1em; color: #555; margin-bottom: 1em; }
#active-fields-container p { display: flex; align-items: center; flex-wrap: wrap; margin-bottom: 1.2em; gap: 1em; }
#active-fields-container label { margin-bottom: 0; flex-shrink: 0; }
#active-fields-container .input-with-unit { display: flex; align-items: center; }
#active-fields-container .input-with-unit input, #active-fields-container .input-with-unit select { width: 180px; padding: 0.7em; border: 1px solid #ccc; border-radius: 4px; }
#active-fields-container .unit { margin-left: 0.75em; color: #777; }


.side-by-side-container {
    display: flex;
    gap: 2em; /* 左右の入力欄の間のスペース */
    align-items: flex-end; /* ラベルと入力欄の下端を揃える */
}
.side-by-side-item {
    display: flex;
    align-items: center;
    gap: 0.5em;
}
.side-by-side-item label {
    font-weight: bold;
}

/* カメラ機能用スタイル */
.photo-area { margin-top: 10px; }
.photo-button { font-size: 12px; padding: 3px 8px; cursor: pointer; }
.photo-preview img { max-width: 200px; height: auto; border-radius: 5px; margin-top: 5px; }
.camera-modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0;
    width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);
    justify-content: center; align-items: center;
}
.camera-modal-content { background-color: #fefefe; padding: 20px; border-radius: 5px; text-align: center; }
#camera-view { max-width: 100%; border: 1px solid #ddd; }
.camera-controls button { margin: 10px 5px; }