/* --- 共通のスタイル --- */
body {
    font-family: sans-serif;
    margin: 20px;
    background-color: #f4f4f4;
}

.box {
    padding: 20px;
    margin: 10px;
    background-color: #ffffff;
    border-radius: 8px;
}

h1, h2 {
    color: #333;
}


/* ---
  1. PC用（デフォルト）のスタイル
  「横幅が769px以上」のときに適用されます。
--- */
.container {
    display: flex; /* Flexboxを使って横並びにします */
    width: 90%;
    max-width: 1000px;
    margin: 0 auto; /* 中央揃え */
}

.left {
    flex: 2; /* 左カラムを2の割合で広く */
    background-color: #e0f7fa; /* 色を付けて分かりやすく */
}

.right {
    flex: 1; /* 右カラムを1の割合で */
    background-color: #fff9c4; /* 色を付けて分かりやすく */
}


/* ---
  【重要ポイント 2】
  これが「メディアクエリ」です。
  「もし、画面の幅が 768px 以下なら」... 以下の { } 内のCSSを適用します。
--- */
@media (max-width: 768px) {

    h1 {
        font-size: 24px; /* スマホ用にタイトルを少し小さく */
    }

    .container {
        /* 横並び (row) だったものを、縦並び (column) に変更 */
        flex-direction: column;
        width: 100%; /* スマホでは画面いっぱいに */
    }

    /* カラムの割合指定をリセットします。
     (flex-direction: column; のおかげで自動的に縦に積まれます)
    */
    .left, .right {
        flex: 1;
    }
}

/* ▼▼▼ ローディング画面のスタイル ▼▼▼ */
#loadingOverlay {
    position: fixed; /* 画面に固定 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8); /* 半透明の白 */
    z-index: 9999; /* 最前面に表示 */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: opacity 0.3s; /* フワッと消えるアニメーション */
}

/* クルクル回るリング */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3; /* 薄いグレー */
    border-top: 5px solid #3498db; /* 青色 */
    border-radius: 50%;
    animation: spin 1s linear infinite; /* 回転アニメーション */
}

/* 回転のアニメーション定義 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 文字のスタイル */
.loading-text {
    margin-top: 15px;
    color: #333;
    font-weight: bold;
}

/* ▼▼▼ レポート機能のスタイル ▼▼▼ */

/* 日付ボタン */
.date-btn {
    padding: 8px 16px;
    background-color: #e0e0e0;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}
.date-btn:hover {
    background-color: #d0d0d0;
}
.date-btn.active {
    background-color: #2196F3; /* 選択中は青くする */
    color: white;
}

/* テーブルの行 */
.report-row td {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

/* 異常値（アラート）のスタイル */
.alert-value {
    color: #D32F2F; /* 濃い赤 */
    font-weight: bold;
    background-color: #FFEBEE; /* 薄い赤背景 */
}

/* ▼▼▼ 一括入力フォームの行スタイル ▼▼▼ */
.bulk-row {
    transition: background-color 0.1s; /* 色がフワッと変わる */
    border-radius: 4px; /* 角を少し丸く */
}

/* マウスが乗った時 */
.bulk-row:hover {
    background-color: #e3f2fd !important; /* 薄い青色 */
}

/* 入力しようとフォーカスした時 (ここが重要！) */
.bulk-row:focus-within {
    background-color: #bbdefb !important; /* 少し濃い青色 */
    border-left: 5px solid #2196F3; /* 左に青い線を出して強調 */
}

/* ▼▼▼ グラフモーダル（ポップアップ）のスタイル ▼▼▼ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* 背景を少し暗く */
    z-index: 1000; /* 最前面 */
    display: none; /* 最初は隠す */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    width: 95%;
    max-width: 800px; /* PCでも広がりすぎないように */
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    position: relative;
    max-height: 90vh; /* 画面からはみ出さない */
    overflow-y: auto; /* 縦長ならスクロール */
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    background: none;
    border: none;
}
.modal-close-btn:hover { color: #000; }

/* ▼▼▼ ヘッダーとユーザーメニューのスタイル ▼▼▼ */

/* 画面上部の帯 */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #4CAF50; /* テーマカラー（緑） */
    color: white;
    margin: -20px -20px 20px -20px; /* bodyのmarginを打ち消して端まで広げる */
    border-radius: 0 0 8px 8px; /* 下だけ丸く */
}

.app-title {
    margin: 0;
    font-size: 1.2em;
}

/* 人型アイコン */
.user-icon {
    font-size: 1.5em;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* クリックした時に出るメニュー */
.user-menu-popup {
    position: absolute;
    top: 60px;
    right: 15px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: none; /* 最初は隠す */
    z-index: 2000;
    text-align: right;
}

/* ▼▼▼ プリセット編集画面のスタイル改善 ▼▼▼ */

/* モーダルのヘッダー部分（検索窓など）を固定 */
#presetModal .modal-content > div:nth-child(-n+4) {
    /* 簡易的に、モーダルの上部コンテンツを固定するのは構造上難しいので、
       リストの中の「番号付きアイテム」を固定するアプローチにします */
}

/* 番号付きの行（緑色の行）を上部に固定する */
/* JSで data-has-order="true" を付けた行を対象にします */
div[data-has-order="true"] {
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* 浮いている感じの影 */
}

/* 固定された要素が重ならないように、topの位置をずらす必要があるのですが、
   動的に増減するのでCSSだけでは限界があります。

   【代替案】もっと確実な方法：
   HTML構造を変えて、「番号付きエリア」と「候補エリア」を別の箱（div）に分けます。
*/
