﻿body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    display: flex;
    justify-content: center; /* コンテンツ全体を水平方向に中央揃え */
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 1500px; /* PCでのカレンダー表示に合わせて最大幅をさらに拡張 */
    width: 100%;
    box-sizing: border-box;
    /* PCでは高さやオーバーフローはコンテンツに任せる */
}

h1, h2, p {
    text-align: center;
    color: #333;
}

form {
    margin-top: 20px;
    text-align: center;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="text"] {
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    max-width: 300px;
}

.legend {
    text-align: center;
    margin-top: 15px;
    margin-bottom: 20px;
    font-size: 0.9em;
    color: #666;
}

.legend-item {
    display: inline-block;
    margin: 0 10px;
}

.mark {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    font-weight: bold;
    border-radius: 3px;
    margin-right: 5px;
    vertical-align: middle;
}

.mark.circle {
    border: 1px solid #ccc;
    background-color: #f0f0f0;
}
.mark.cross {
    background-color: #dc3545; /* 赤 */
    color: #fff;
}
.mark.triangle {
    background-color: #ffc107; /* 黄 */
    color: #333;
}


.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.calendar-nav a {
    text-decoration: none;
    color: #007bff;
    font-weight: bold;
}

.calendar-nav h2 {
    text-align: center;
    width: 100%;
    margin: 0;
}

.calendar {
    margin: 20px auto; /* コンテナ内でカレンダーを中央揃え */
    /* PCでは横スクロールしないように設定 */
    display: table; /* divではなくtable要素として振る舞う */
    border: 1px solid #eee;
    border-collapse: collapse;
    width: auto; /* コンテンツに合わせて幅を調整 */
    overflow-x: unset; /* 横スクロール解除 */
    /* white-space: normal; */ /* セル内のテキストは改行させる（td内で長文がある場合） -> この指定は下位の th, td に任せる */
}

.calendar table {
    width: 100%; /* 親要素（.calendar）の幅いっぱいに広がる */
    border-collapse: collapse;
    table-layout: fixed; /* カラム幅を固定してはみ出しを防ぐために追加 */
}

.calendar th, .calendar td {
    padding: 7px; /* パディングを調整 */
    text-align: center;
    border: 1px solid #eee;
    vertical-align: top; /* 日付番号を上揃えに */
    white-space: normal; /* ここを normal に変更 */
    word-break: normal; /* 長い単語を強制改行する設定を解除（nowrapと併用のため） */
    font-size: 1.0em; /* フォントサイズを大きく */
}

/* カレンダーの最初の列（チェックボックス）の幅を最小限に */
.calendar th:first-child,
.calendar td:first-child {
    width: 30px; /* チェックボックスが収まる最小限の幅に設定 */
}

/* カレンダーの名前の列 */
/* 名前が表示される2番目の列（チェックボックスの次）に幅を設定 */
/* th:nth-child(2) と td:nth-child(2) は、最初の th/td (チェックボックス) の次の要素です */
.calendar th:nth-child(2),
.calendar td:nth-child(2) {
    width: 120px; /* 名前の列の幅を固定 */
    white-space: normal; /* 名前が長い場合に改行されるようにする */
}


.calendar th {
    background-color: #f2f2f2;
    color: #555;
}

/* 希望提出カレンダーの日付セル */
.calendar-day {
    cursor: pointer;
    min-height: 120px; /* PCでの最小高さを確保 */
    background-color: #f9f9f9;
    transition: background-color 0.2s ease;
    position: relative; /* 子要素の配置のため */
}

.calendar-day:hover {
    background-color: #e0e0e0;
}

.day-number {
    font-size: 1.1em; /* This is for the day number *inside* the selectable cell, distinct from the th header */
    font-weight: bold;
    text-align: right; /* 日付番号を右寄せ */
    padding-right: 5px;
    height: 20px; /* 日付番号の表示エリア */
}

.selection-mark {
    position: absolute;
    bottom: 5px; /* 下部に配置 */
    left: 50%;
    transform: translateX(-50%); /* 中央寄せ */
    width: 30px;
    height: 30px;
    line-height: 30px;
    font-size: 1.5em;
    font-weight: bold;
    border-radius: 50%; /* 円形 */
    background-color: transparent;
    color: #ccc; /* デフォルトの色（薄い〇） */
    border: 2px solid #ccc; /* デフォルトの枠線 */
    display: flex; /* 中央揃えのため */
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

/* 選択されたマークのスタイル */
.selection-mark.cross {
    background-color: #dc3545; /* 赤 */
    color: #fff;
    border-color: #dc3545;
}

.selection-mark.triangle {
    background-color: #ffc107; /* 黄 */
    color: #333;
    border-color: #ffc107;
}


button[type="submit"] {
    background-color: #28a745;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    margin-top: 20px;
    transition: background-color 0.3s ease;
}

button[type="submit"]:hover {
    background-color: #218838;
}

a {
    display: inline-block;
    margin-top: 20px;
    color: #007bff;
    text-decoration: none;
    font-weight: bold;
}

a:hover {
    text-decoration: underline;
}

/* --- 提出された希望一覧ページ (view_requests.php) 用スタイル --- */

/* view_requests.php での最初の列（チェックボックス）の幅を最小限に */
.view-calendar th:first-child,
.view-calendar td:first-child {
    width: 30px; /* チェックボックスが収まる最小限の幅に設定 */
}

/* view_requests.php での名前の列の幅を固定 */
.view-calendar th:nth-child(2),
.view-calendar td:nth-child(2) {
    width: 120px; /* 名前の列の幅を固定 */
    white-space: normal; /* 名前が長い場合に改行されるようにする */
}


.view-calendar td {
    padding: 5px;
}

.view-day.circle {
    color: #4CAF50; /* 緑 */
    font-weight: bold;
}
.view-day.cross {
    color: #dc3545; /* 赤 */
    font-weight: bold;
}
.view-day.triangle {
    color: #ffc107; /* 黄 */
    color: #333;
    font-weight: bold;
}

.view-day.triangle {
    color: #DAA520 !important;
}

.view-day.paid-leave {
    color: #0000FF !important;
    font-weight: normal !important;
}

/* ========================================================= */
/* スマートフォン対応 (画面幅が768px以下の場合に適用) */
/* ========================================================= */
@media (max-width: 768px) {
    body {
        padding: 10px; /* パディングを少し減らす */
    }

    .container {
        padding: 15px; /* コンテナのパディングを減らす */
        border-radius: 5px;
        /* モバイル特有のコンテナスタイルを再適用 */
        height: 100vh;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    h1 {
        font-size: 1.8em;
    }

    h2 {
        font-size: 1.3em;
    }

    p, label, input[type="text"] {
        font-size: 0.95em;
    }

    .legend {
        font-size: 0.8em;
        margin-top: 10px;
        margin-bottom: 15px;
    }

    .legend-item {
        margin: 0 5px; /* 余白を減らす */
    }

    .mark {
        width: 18px;
        height: 18px;
        line-height: 18px;
        font-size: 0.9em;
    }

    .calendar-nav {
        font-size: 1em;
        margin-bottom: 10px;
    }

    .calendar-nav a {
        font-size: 0.9em;
    }

    .calendar-nav h2 {
        font-size: 1.3em;
    }

    .calendar {
        /* モバイルでは横スクロールが必要になる場合があるので再適用 */
        overflow-x: auto;
        white-space: normal; /* セル内では改行させない -> ここも normal に変更 */
        -webkit-overflow-scrolling: touch;
        display: block; /* tableをblockにしてoverflowを適用可能に */
    }

    .calendar table {
        /* モバイルではテーブルの最小幅を確保 */
        min-width: unset; /* モバイルでは最小幅を解除し、コンテンツに合わせて調整 */
        table-layout: auto; /* 自動で幅を調整させる */
    }

    .calendar th, .calendar td {
        padding: 6px; /* カレンダーのセルパディングを減らす */
        font-size: 0.9em; /* フォントサイズを調整 */
        white-space: normal; /* セル内のテキストは改行させる */
    }

    /* モバイルでのチェックボックス列と名前列の幅調整 */
    .calendar th:first-child,
    .calendar td:first-child {
        width: 30px; /* モバイルでもチェックボックスの幅を固定 */
    }
    .calendar th:nth-child(2),
    .calendar td:nth-child(2) {
        width: 80px; /* モバイルでの名前の列の幅。必要に応じて調整 */
        white-space: normal;
    }


    .calendar-day {
        min-height: unset;
        height: calc(100vw / 7); /* モバイルでは週表示の高さ */
        box-sizing: border-box;
    }

    .day-number {
        font-size: 1em; /* 日付番号のサイズ */
        padding-right: 3px;
        height: auto; /* 高さを自動調整 */
    }

    .selection-mark {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 35%;
        height: 35%;
        font-size: 1em;
        line-height: 1;
        bottom: unset;
    }

    button[type="submit"] {
        padding: 10px 20px;
        font-size: 16px;
    }
}

/* さらに小さい画面 (例: 幅375px以下) 向けの調整 */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.6em;
    }

    .calendar th, .calendar td {
        padding: 4px;
        font-size: 0.85em;
    }

    .calendar-day {
        min-height: unset;
    }

    .day-number {
        font-size: 0.9em;
    }

    .selection-mark {
        width: 22px;
        height: 22px;
        line-height: 22px;
        font-size: 1em;
    }
}

/* 更新ボタンのスタイル */
.refresh-button-container {
    text-align: right; /* ボタンを右寄せ */
    margin-bottom: 15px; /* カレンダーとの間にスペース */
}

.refresh-button {
    background-color: #007bff; /* 青色の背景 */
    color: white; /* 白い文字 */
    padding: 8px 15px; /* パディング */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    text-decoration: none; /* 下線を削除 */
    display: inline-block; /* ボタンとして表示 */
    transition: background-color 0.3s ease;
}

.refresh-button:hover {
    background-color: #0056b3; /* ホバー時の色 */
}

/* PC表示時のみ右上に固定する場合の追加スタイル */
@media (min-width: 769px) {
    .container {
        position: relative; /* ボタンの絶対配置の基準 */
    }
    .refresh-button-container {
        position: absolute; /* 親要素基準で絶対配置 */
        top: 30px; /* .container のパディングに合わせて調整 */
        right: 30px; /* .container のパディングに合わせて調整 */
        margin-bottom: 0; /* 不要なマージンを削除 */
        z-index: 10; /* 他の要素の上に表示 */
    }
}

/* ロゴのスタイル */
.logo-container {
    text-align: center; /* ロゴ画像を中央に配置 */
    margin-bottom: 30px; /* ロゴの下にスペース */
    padding-top: 20px; /* ロゴの上にパディング */
}

.logo-container img {
    max-width: 250px; /* ロゴの最大幅を調整 */
    height: auto; /* 高さを自動調整してアスペクト比を維持 */
    display: block; /* 中央寄せのためにブロック要素に */
    margin: 0 auto; /* 中央寄せ */
}

/* スマートフォン対応 (画面幅が768px以下の場合に適用) */
@media (max-width: 768px) {
    /* ... 既存のメディアクエリ内のCSSコード ... */

    .logo-container {
        margin-bottom: 20px;
        padding-top: 10px;
    }

    .logo-container img {
        max-width: 150px; /* スマートフォンでのロゴの最大幅 */
    }
}

/* さらに小さい画面 (例: 幅480px以下) 向けの調整 */
@media (max-width: 480px) {
    .logo-container {
        margin-bottom: 15px;
        padding-top: 5px;
    }

    .logo-container img {
        max-width: 200px; /* 非常に小さい画面でのロゴの最大幅 */
    }
}

/* --- 曜日による色分け（提出希望一覧 view_requests.php 用）--- */
th.saturday,
td.saturday {
    color: blue;
    font-weight: bold;
}

th.sunday,
td.sunday {
    color: red;
    font-weight: bold;
}
