/* static/style.css */

/* === 基本設定とカラーパレット === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --color-orange-start: #ff8c00; /* ダークオレンジ */
    --color-orange-end: #ffa500;   /* ライトオレンジ */
    --color-dark: #212529;
    --color-medium-dark: #343a40;
    --color-light-gray: #f8f9fa;
    --color-white: #ffffff;
    --color-text-primary: #343a40;
    --color-text-secondary: #6c757d;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--color-light-gray);
    color: var(--color-text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* === ログインページ専用スタイル === */
.login-page-body {
    /* 背景は各HTMLファイルでアニメーションとして定義 */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.login-card {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 3em 2.5em;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
    box-sizing: border-box;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
}
.login-card h1 { font-size: 1.6em; margin-bottom: 0.2em; border: none; }
.login-card h2 { font-size: 1.1em; margin-bottom: 2em; color: var(--color-text-secondary); font-weight: 500; border: none; }
.login-form { display: flex; flex-direction: column; gap: 1.5em; }
.login-form input {
    background: var(--color-light-gray);
    border: 1px solid #dee2e6;
    text-align: center;
    padding: 1em;
    font-size: 1.1em;
    border-radius: 8px;
    transition: all 0.2s ease;
}
.login-form input:focus {
    outline: none;
    border-color: var(--color-orange-end);
    box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.2);
}
.login-form button {
    border: none;
    background: linear-gradient(45deg, var(--color-orange-start), var(--color-orange-end));
    color: var(--color-white);
    font-weight: 600;
    padding: 1em;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.3);
}
.login-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 165, 0, 0.4);
}


/* === 管理者ポータルレイアウト === */
.portal-container { display: flex; min-height: 100vh; }
.sidebar {
    flex-basis: 250px;
    flex-shrink: 0;
    background-color: var(--color-dark);
    color: #adb5bd;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    padding: 1.5em;
    text-align: center;
    background-color: #0000001a;
}
.sidebar-header h2 { margin: 0; border: none; color: var(--color-white); font-size: 1.2em; }
.sidebar-nav { flex-grow: 1; }
.sidebar-nav ul { list-style: none; padding: 1em 0; margin: 0; }
.sidebar-nav li a {
    display: block;
    padding: 0.9em 1.5em;
    margin: 0.3em 1em;
    color: #adb5bd;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
    font-weight: 500;
}
.sidebar-nav li a:hover {
    background-color: var(--color-medium-dark);
    color: var(--color-white);
}
.nav-separator { display: none; } /* セパレータは不要になったので非表示 */
.sidebar-footer { padding: 1em; }
.sidebar-nav li a.logout-link {
    background-color: #ffffff1a;
}
.sidebar-nav li a.logout-link:hover {
    background-color: #ffffff2a;
}
.main-content {
    flex-grow: 1;
    padding: 2em;
}


/* === コンテンツ汎用スタイル === */
h1 { font-size: 2em; color: var(--color-text-primary); border-bottom: 2px solid #dee2e6; padding-bottom: 0.5em; margin-bottom: 1em; }
.container {
    background: var(--color-white);
    padding: 2em;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    max-width: 1400px;
    margin: 0 auto;
}
button, a.button {
    cursor: pointer;
    color: var(--color-white);
    border: none;
    border-radius: 6px;
    padding: 0.6em 1.2em;
    font-size: 1em;
    font-weight: 500;
    background: linear-gradient(45deg, var(--color-orange-start), var(--color-orange-end));
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}
button:hover, a.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(255, 165, 0, 0.3);
}
input, select {
    font-size: 1em;
    padding: 0.7em;
    border-radius: 6px;
    border: 1px solid #ced4da;
    box-sizing: border-box;
    transition: all 0.2s ease;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--color-orange-end);
    box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.2);
}


/* === テーブル === */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5em;
    font-size: 0.95em;
}
th, td {
    padding: 0.6em 1em;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}
/* 1. 従業員管理ページのボタンのサイズを小さくする */
table .button, 
table .edit-btn, 
table .btn-attendance {
    padding: 0.3em 0.8em; /* 上下の余白を小さく */
    font-size: 0.9em;     /* 文字サイズを少し小さく */
    margin-left: 0.5em;
}

/* 2. 本日の出勤状況ページの「●」のサイズを小さくする */
.table-dashboard td span {
    font-size: 1.1em !important; /* 1.5em から 1.1em に強制変更 */
    line-height: 1;              /* 行の高さを詰める */
}

thead th {
    background-color: var(--color-light-gray);
    font-weight: 600;
    border-top: 1px solid #dee2e6;
}
tbody tr:nth-child(even) { background-color: var(--color-light-gray); }
tbody tr:hover { background-color: #ffedd5; }
th a { text-decoration: none; color: inherit; }
th a:hover { color: var(--color-orange-start); }
.sort-arrow { font-size: 0.8em; margin-left: 0.5em; }

/* === フォーム === */
.filter-form, .employee-add-form {
    display: flex;
    gap: 1em;
    align-items: flex-end;
    padding: 1.5em;
    margin-bottom: 2em;
    background-color: var(--color-light-gray);
    border-radius: 8px;
}
.filter-form .form-group { display: flex; flex-direction: column; }
.filter-form label { margin-bottom: 0.5em; font-size: 0.9em; font-weight: bold; }
a.button.reset-btn { background: var(--color-text-secondary); }
a.button.reset-btn:hover { background: var(--color-medium-dark); box-shadow: none; }

/* === Flashメッセージ === */
.flash-message {
    padding: 1em; margin-bottom: 1.5em; border-radius: 8px; text-align: center;
    border: 1px solid; font-weight: 500;
}
.success { background-color: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.danger { background-color: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.info { background-color: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* --- フィルターフォームのデザイン微調整 (最終版) --- */

/* フォーム内の入力欄（日付、年月、セレクトボックス）の幅を統一 */
.filter-form input[type="date"],
.filter-form input[type="month"],
.filter-form select {
    width: 220px; /* すべての幅を220pxに統一 */
}

/* フォーム内のすべてのボタン・リンクの高さを揃える */
.filter-form button,
.filter-form a.button {
    height: 41px; /* paddingを考慮した高さに統一 */
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none; /* リンクの下線を常に非表示に */
}

/* リセットボタンの固有スタイル */
.reset-btn {
    background: var(--color-text-secondary); /* 通常時の背景色 */
    box-shadow: var(--shadow-sm);
    color: var(--color-white); /* 通常時の文字色 */
}

/* リセットボタンのホバーエフェクト */
.reset-btn:hover {
    background: var(--color-medium-dark);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
    color: var(--color-white); /* ホバー時の文字色 */
}

/* --- フィルターフォームのボタン位置を最終調整 --- */

/* ボタンを囲むコンテナ(.form-actions)をFlexboxにする */
.filter-form .form-actions {
    display: flex;       /* 中の要素（ボタン）を横に並べる */
    align-items: center; /* ★垂直方向の中央を揃える、これがズレを解消します */
    gap: 1em;            /* ボタンとリセットボタンの間のスペース */
}

/* --- 従業員編集モーダルウィンドウのスタイル --- */

/* モーダル表示時の背景オーバーレイ */
.modal-overlay {
    position: fixed; /* 画面に固定 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* 半透明の黒 */
    display: none; /* ★ 通常は非表示 */
    justify-content: center;
    align-items: center;
    z-index: 1000; /* 他の要素より手前に表示 */
    opacity: 0; /* 透明な状態から開始 */
    transition: opacity 0.3s ease; /* フェードイン/アウトのアニメーション */
}

/* モーダル本体（白いカード部分） */
.modal-content {
    background: var(--color-white);
    padding: 2em;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    position: relative;
    transform: scale(0.95); /* 少し小さい状態から開始 */
    transition: transform 0.3s ease;
}

/* モーダル表示時のアニメーション */
.modal-overlay.visible {
    display: flex;
    opacity: 1;
}
.modal-overlay.visible .modal-content {
    transform: scale(1);
}

/* モーダルの閉じるボタン */
.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.8em;
    color: var(--color-text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close-btn:hover {
    color: var(--color-dark);
}

/* モーダル内のフォーム */
.modal-form {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 1.2em;
    align-items: center;
}
.modal-form label {
    font-weight: 600;
    text-align: right;
}
.modal-form .form-actions {
    grid-column: 2 / 3; /* ボタンを右の列に配置 */
    text-align: right;
}

/* --- 従業員打刻モーダル用のスタイル --- */
.employee-modal-content {
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.employee-modal-header {
    text-align: center;
    padding-bottom: 1.5em;
    border-bottom: 1px solid #dee2e6;
}

.employee-modal-header h2 {
    margin: 0;
    border: none;
    font-size: 1.8em;
}

.employee-modal-body {
    padding-top: 2em;
    flex-grow: 1;
    /* ★ 修正: 中身(時計とボタン)を縦に並べて中央に配置 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center; /* 横方向も中央揃えに */
}

/* PIN認証フォーム */
#pin-auth-view {
    text-align: center;
}
#pin-auth-view p {
    font-size: 1.2em;
    color: var(--color-text-secondary);
    margin-top: 0;
    margin-bottom: 1.5em;
}
.record-actions-footer {
    display: flex;
    flex-direction: row; /* 縦並びから横並びに変更 */
    gap: 1.5em;
    width: 100%; /* 幅を100%に */
}
.record-actions-footer form {
    flex: 1;
}
.record-actions-footer button {
    font-size: 1.5em;
    font-weight: 600;
    padding: 1.2em;
    border-radius: 8px;
    width: 100%; /* ボタンをフォームの幅いっぱいに広げる */
}

.check-in {
    background: linear-gradient(45deg, #28a745, #20c997);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}
.check-out {
    background: linear-gradient(45deg, #dc3545, #fd7e14);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}
.record-actions-footer button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}

/* --- 従業員打刻ページ (index.html) の改良スタイル --- */

/* ページ全体のコンテナの幅を少し狭くする */
.employee-page-container {
    width: 750px;
}
/* ★ 追加: 新しい時計のスタイル */
.clock-container {
    text-align: center;
    margin-bottom: 1.5em;
    user-select: none;
}
#live-date {
    font-size: 1.5em;
    color: var(--color-text-secondary);
    margin-bottom: 0.2em;
    /* ★ 追加: 数字の幅を揃える */
    font-variant-numeric: tabular-nums;
}
#live-time {
    font-size: 4.5em;
    font-weight: 700;
    color: var(--color-dark);
    line-height: 1.2;
    /* ★ 修正: Courierフォント指定を削除し、標準フォントを継承 */
    font-family: inherit; 
    /* ★ 追加: 数字の幅を揃える */
    font-variant-numeric: tabular-nums;
}

/* ★ 追加: モーダル内の新しい時計スタイル */
.modal-date {
    font-size: 1.5em;
    color: var(--color-text-secondary);
    margin-bottom: 0.5em;
    /* ★ 追加: 数字の幅を揃える */
    font-variant-numeric: tabular-nums;
}
.modal-time {
    font-size: 3.5em;
    font-weight: 700;
    color: var(--color-dark);
    line-height: 1.2;
    /* ★ 修正: Courierフォント指定を削除し、標準フォントを継承 */
    font-family: inherit;
    /* ★ 追加: 数字の幅を揃える */
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.5em;
}

/* ★ 修正: 従業員検索コンテナを小さく、中央揃えに */
.employee-search-container {
    position: relative; 
    margin-bottom: 2em;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* 検索ボックス本体のスタイル */
#employee-search {
    width: 100%;
    font-size: 1.5em;
    padding: 0.8em;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    text-align: center;
    box-sizing: border-box;
    transition: all 0.2s ease;
}
#employee-search:focus {
    outline: none;
    border-color: var(--color-orange-end);
    box-shadow: 0 0 0 4px rgba(255, 165, 0, 0.2);
}

/* 検索結果リストのスタイル */
#search-results {
    list-style: none;
    padding: 0;
    margin: 0.2em 0 0 0;
    position: absolute;
    width: 100%;
    background: var(--color-white);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    max-height: 240px; /* 5-6人分表示されたらスクロール */
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    display: none; /* ★ 通常は非表示 */
    z-index: 100; /* 他の要素より手前に表示 */
}

#search-results li {
    padding: 1em;
    cursor: pointer;
    font-size: 1.1em;
    border-bottom: 1px solid var(--color-light-gray);
    text-align: center;
}
#search-results li:last-child {
    border-bottom: none;
}
#search-results li:hover {
    background-color: #ffedd5;
}

.site-logout-fixed {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

/* ★ 追加: 従業員一覧の「勤怠編集」ボタン */
.btn-attendance {
    background: linear-gradient(45deg, #17a2b8, #138496);
    color: white;
    margin-left: 0.5em;
}
.btn-attendance:hover {
    background: #117a8b;
    box-shadow: none;
    transform: none;
}

/* ★ 追加: 勤怠編集モーダル */
.attendance-modal-content {
    max-width: 800px; /* 幅を広げる */
}

.attendance-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5em 1em;
    background-color: var(--color-light-gray);
    border-radius: 8px;
    margin-bottom: 1.5em;
}
.attendance-modal-header h3 {
    margin: 0;
    font-size: 1.5em;
    color: var(--color-dark);
}
.attendance-modal-header .month-nav-btn {
    font-size: 1.5em;
    padding: 0.2em 0.8em;
    background-color: #0000001a;
    border: none;
    color: var(--color-dark);
    cursor: pointer;
    border-radius: 4px;
}
.attendance-modal-header .month-nav-btn:hover {
    background-color: #0000003a;
}

.attendance-log-list {
    height: 50vh; /* ★ 修正: max-height から height に変更 */
    overflow-y: auto;
    border-top: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
}

.attendance-log-item {
    display: grid;
    /* 日付 | 出勤 | 退勤 | 保存 */
    grid-template-columns: 80px 1.2fr 1.2fr 100px;
    gap: 0.8em; /* パーツ間の隙間を縮小 */
    align-items: center;
    padding: 0.6em 1em; /* 上下の余白を縮小 */
    border-bottom: 1px solid #f1f3f5;
}
.attendance-log-item:nth-child(even) {
    background-color: var(--color-light-gray);
}

.log-date-label {
    font-weight: 600;
    font-size: 1.0em;
}
.log-date-label span {
    font-weight: 400;
    font-size: 0.9em;
    color: var(--color-text-secondary);
}
.log-input-group {
    display: flex;
    flex-direction: column;
}
.log-input-group label {
    font-size: 0.8em;
    color: var(--color-text-secondary);
    margin-bottom: 0.2em;
}
.log-input-group input[type="time"] {
    font-size: 1.0em;
    padding: 0.4em;
}

.log-save-btn {
    padding: 0.6em 1em;
    font-size: 0.9em;
}
.log-save-btn.saved {
    background: var(--color-text-secondary);
    cursor: not-allowed;
}

.rounded-time-log {
    display: block;
    font-size: 0.8em;
    color: #007bff; /* 以前の実時間表示で使っていた青色 */
    margin-top: 4px;
}

/* === 会社名 (打刻ページ用) === */
.company-title {
    font-size: 2.2em; /* ご要望の「少し大きめ」なサイズ */
    font-weight: 700;
    color: var(--color-text-secondary); /* 日付の色と統一 */
    text-align: center;
    margin-bottom: 0.5em; /* 白いカードとの間隔 */
    user-select: none;
    
    /* 共通スタイル(h1)の線を上書き */
    border-bottom: none; 
    padding-bottom: 0;
    margin-top: 0;
}

/* === ログ一覧ページの操作ボタン === */
.btn-log-edit {
    padding: 0.3em 0.8em;
    font-size: 0.9em;
    /* オレンジ色は .button のデフォルト */
}
.btn-log-delete {
    background: var(--color-text-secondary);
    padding: 0.3em 0.8em;
    font-size: 0.9em;
    margin-left: 0.5em;
}
.btn-log-delete:hover {
    background: var(--color-medium-dark);
    box-shadow: none;
    transform: none;
}

/* === ログ編集モーダルの静的テキスト === */
.modal-static-text {
    font-size: 1em;
    font-weight: 600;
    margin: 0;
    padding: 0.7em 0; /* inputと高さを合わせるための微調整 */
    color: var(--color-dark);
}

/* === ログ一覧の新規追加ボタン === */
.btn-add-log {
    background: linear-gradient(45deg, #28a745, #20c997);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}
.btn-add-log:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}

/* === ページネーション === */
.pagination-container {
    margin-top: 2em;
    display: flex;
    justify-content: center;
}
.pagination {
    display: flex;
    list-style: none;
    padding-left: 0;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid #dee2e6;
}
.page-link {
    display: block;
    padding: 0.7em 1em;
    color: var(--color-orange-start);
    text-decoration: none;
    background-color: var(--color-white);
    border-left: 1px solid #dee2e6;
}
.page-item:first-child .page-link {
    border-left: none;
}
.page-link:hover {
    background-color: var(--color-light-gray);
}
.page-item.active .page-link {
    background: linear-gradient(45deg, var(--color-orange-start), var(--color-orange-end));
    color: var(--color-white);
    font-weight: 600;
    border-color: var(--color-orange-start);
}
.page-item.disabled .page-link {
    color: var(--color-text-secondary);
    background-color: var(--color-light-gray);
    pointer-events: none;
}

/* --- 従業員管理テーブル 操作ボタン調整 --- */

/* ボタンを囲うラッパーの設定 */
.table-employees .action-buttons {
    display: flex;         /* ボタンを横並び(flex)にする */
    flex-wrap: nowrap;     /* 折り返さない */
    gap: 5px;              /* ボタン間の隙間を5pxに */
    justify-content: flex-start; /* 左寄せ */
}

/* ラッパー内のボタンのサイズを微調整 */
.table-employees .action-buttons .button,
.table-employees .action-buttons .btn-attendance {
    padding: 6px 8px;     /* 上下6px, 左右8pxの余白 (少し小さく) */
    font-size: 0.9em;     /* 文字サイズを少し小さく (90%) */
    white-space: nowrap;  /* ボタン内の文字も折り返さない */
    flex-shrink: 0;       /* コンテナが狭くてもボタン自体は縮まない */
}

/* --- インセンティブ管理モーダル (★専用クラス版) --- */

/* フォーム全体 (背景色など) */
.incentive-form {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 1.5em;
    box-sizing: border-box;
}

/* フォームの「行」 (横並びコンテナ) */
.incentive-form-row {
    display: flex;
    flex-wrap: wrap; /* 狭い画面では折り返す */
    gap: 1.5em;      /* 左右のアイテム間の隙間 */
    margin-bottom: 1.2em; /* 次の行との隙間 */
}

/* フォームの「グループ」 (ラベルと入力欄のセット) */
.incentive-form-group {
    flex: 1;          /* 均等に幅を分ける */
    min-width: 200px; /* 最小幅 */
}

/* グループ内の「ラベル」 */
.incentive-form-group label {
    display: block;   /* ★ ラベルは単独の行を占める */
    font-weight: 600;
    margin-bottom: 0.5em;
    color: #333;
}

/* グループ内の「入力欄」 */
.incentive-form-group input {
    display: block;   /* ★ 入力欄も単独の行を占める */
    width: 100%;      /* ★ 幅を100%にする */
    padding: 0.8em;
    font-size: 1em;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box; /* paddingを含めて幅100%にする */
}
/* 入力欄の種類ごとに指定 (念のため) */
.incentive-form-group input[type="month"],
.incentive-form-group input[type="number"],
.incentive-form-group input[type="text"] {
    width: 100%;
}


/* フォームの「登録ボタン」のコンテナ */
.incentive-form-actions {
    text-align: right; /* ボタンを右寄せ */
    margin-top: 1em;
}

/* --- 履歴テーブルのスタイル (これは前回と同じ) --- */
.incentive-history-list {
    max-height: 40vh;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-top: 1.5em;
}
.incentive-history-table {
    width: 100%;
    border-collapse: collapse;
}
.incentive-history-table th,
.incentive-history-table td {
    padding: 0.8em 1em;
    border-bottom: 1px solid #eee;
    text-align: left;
    vertical-align: middle;
}
.incentive-history-table th {
    background-color: #f7f7f7;
    font-weight: 600;
    position: sticky;
    top: 0;
}
.status-paid {
    color: #28a745;
    font-weight: bold;
    font-size: 0.9em;
}
.status-pending {
    color: #fd7e14;
    font-weight: bold;
    font-size: 0.9em;
}

/* --- ログ確認ページ カレンダーダッシュボード --- */

/* カレンダーと結果を横並びにするコンテナ */
.calendar-dashboard {
    display: flex;
    flex-wrap: wrap; /* 画面が狭ければ縦並びになる */
    gap: 2em;
    margin-bottom: 1.5em;
}

/* 左側 (カレンダー) */
.calendar-container {
    flex: 1;
    min-width: 320px;
}
/* flatpickrカレンダーのコンテナを中央寄せ */
#inline-calendar {
    max-width: 350px;
    margin: 0 auto;
}

/* 右側 (結果) */
.calendar-results {
    flex: 1.5; /* カレンダーより少し幅を広く取る */
    min-width: 300px;
    
    /* 結果をスクロール可能にする */
    max-height: 420px; /* カレンダーの高さに合わせる */
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 1.5em 1.5em 1.5em;
}

.calendar-results h3 {
    position: sticky; /* スクロールしても「出退勤サマリー」を固定 */
    top: 0;
    background: #fff;
    padding-top: 1.5em; /* 上下の余白 */
    padding-bottom: 0.5em;
    margin-bottom: 1em;
    border-bottom: 2px solid #f0f0f0;
}

/* 結果表示用の簡易テーブル */
.daily-summary-table {
    width: 100%;
    border-collapse: collapse;
}
.daily-summary-table th,
.daily-summary-table td {
    padding: 0.8em;
    border-bottom: 1px solid #eee;
    text-align: left;
}
.daily-summary-table th {
    font-weight: 600;
    background-color: #f9f9f9;
}

/* --- ログページ タブ切り替えボタン (v3・強制リセット) --- */
.view-toggle-buttons {
    display: flex;
    gap: 20px;
    margin-bottom: 1.5em;
    border-bottom: 2px solid #eee;
}
.view-toggle-buttons .toggle-btn {
    padding: 0.8em 1.0em;
    font-size: 1.1em;
    font-weight: 600;
    background: #fff !important; 
    color: #6c757d !important; 
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: -2px;
    border-radius: 0; 
    box-shadow: none;
}
.view-toggle-buttons .toggle-btn:hover {
    color: #0056b3 !important; 
    background: #f9f9f9 !important; 
    border-bottom: 3px solid transparent;
}
.view-toggle-buttons .toggle-btn.active {
    color: #007bff !important; 
    background: #fff !important; 
    border-bottom: 3px solid #007bff;
}

/* --- ログ確認ページ カレンダーダッシュボード (サイズ強制 v5) --- */
.calendar-dashboard {
    display: flex;
    flex-wrap: nowrap; /* ★ 折り返さない */
    gap: 2em;
    margin-bottom: 1.5em;
    width: 100%;
}

/* ★ 修正: 左カラム(カレンダーの親)のサイズを固定 (flexを削除) */
.calendar-container {
    width: 420px;     /* ★ 幅を 420px に固定 */
    min-width: 420px;   /* ★ 最小幅も 420px に固定 */
    flex-shrink: 0;   /* ★ 縮まないようにする */
}

/* ★ 修正: カレンダー本体は親の幅(420px)いっぱいに広がる */
#inline-calendar {
    width: 100% !important; 
    max-width: 100% !important;
    min-width: 100% !important;
    margin: 0; 
    font-size: 110% !important; 
}
#inline-calendar .flatpickr-calendar {
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important; 
    border: 1px solid #ddd; 
}
#inline-calendar .flatpickr-weekday {
    height: 32px !important;
    line-height: 32px !important;
    font-size: 1em !important;
}
#inline-calendar .flatpickr-day {
    height: 42px !important;       
    line-height: 42px !important;  
    flex-basis: 14.28% !important; 
    font-size: 1.1em !important; 
}
#inline-calendar .flatpickr-prev-month,
#inline-calendar .flatpickr-next-month {
    height: 42px !important; 
    padding: 10px !important; 
    top: 0 !important;
}
#inline-calendar .flatpickr-current-month {
     height: 42px !important; 
     line-height: 42px !important;
     font-size: 1.1em !important;
}

/* --- (↓ カレンダー結果欄のCSS) --- */
.calendar-results {
    flex: 1.5; /* ★ 修正: 残りのスペースをすべて取る (1.5 → 1) */
    min-width: 300px;
    max-height: 600px !important; 
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 1.5em 1.5em 1.5em;
}
.calendar-results h3 {
    position: sticky; 
    top: 0;
    background: #fff;
    padding-top: 1.5em; 
    padding-bottom: 0.5em;
    margin-bottom: 1em;
    border-bottom: 2px solid #f0f0f0;
}
.daily-summary-table {
    width: 100%;
    border-collapse: collapse;
}
.daily-summary-table th,
.daily-summary-table td {
    padding: 0.8em;
    border-bottom: 1px solid #eee;
    text-align: left;
}
.daily-summary-table th {
    font-weight: 600;
    background-color: #f9f9f9;
}

/* --- カレンダー結果欄 ヘッダー (ログ追加ボタン) --- */
.calendar-results-header {
    display: flex;
    justify-content: space-between; /* 両端に配置 */
    align-items: center;
    
    /* 既存のh3のスタイルをこちらに移動 */
    position: sticky; 
    top: 0;
    background: #fff;
    padding: 1.5em 1.5em 0.5em 0; /* ★ padding-right を 0 に */
    margin: 0 0 1em 0; /* ★ h3からマージンを移動 */
    border-bottom: 2px solid #f0f0f0;
}
/* コンテナに追加したので、h3本体のスタイルは解除 */
.calendar-results h3 {
    position: static;
    padding: 0;
    margin: 0;
    border: none;
}
/* 新しく追加したボタンのマージン調整 */
#calendarAddLogBtn {
    margin: 0;
}

/* --- 新規従業員登録フォームのレイアウト修正 (はみ出し防止版) --- */
.employee-add-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: center;
    
    width: 100%;
    box-sizing: border-box; /* ★ これを追加！(paddingを含めて幅100%にする) */
    
    margin-bottom: 2em;
    padding: 1.5em;
    background-color: #f9f9f9;
    border-radius: 8px;
}

/* フォーム内の入力欄 */
.employee-add-form input,
.employee-add-form select {
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    height: 40px;
}

/* 登録ボタン (小さく左寄せ) */
.employee-add-form button {
    width: auto;       
    min-width: 120px;
    height: 40px;
    margin: 0;
    padding: 0 1.5em;
    
    background-color: #007bff;
    color: white;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    
    justify-self: start; 
}

.employee-add-form button:hover {
    background-color: #0056b3;
}

/* --- CRM 顧客編集フォーム --- */
.crm-edit-form {
    background-color: #fff;
    padding: 2em;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.form-section-title {
    margin-top: 0;
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 2px solid #eee;
    color: #2c3e50;
    font-size: 1.1em;
}
/* 2回目以降のタイトルには上余白をつける */
.form-section-title:not(:first-child) {
    margin-top: 1.5em;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5em;
}

.crm-edit-form label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 600;
    font-size: 0.9em;
    color: #555;
}

.crm-edit-form input,
.crm-edit-form select {
    width: 100%;
    padding: 0.8em;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
}

/* --- CRM 顧客詳細ページ --- */
.customer-info-box {
    background-color: #f8f9fa;
    padding: 1.5em;
    border-radius: 8px;
    margin-top: 1em;
}
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1em 2em;
    margin-bottom: 1em;
}
.info-item label {
    display: block;
    font-size: 0.8em;
    color: #666;
    margin-bottom: 2px;
}
.info-item span {
    font-weight: 500;
    font-size: 1.05em;
}
.info-full label {
    display: block;
    font-size: 0.8em;
    color: #666;
    margin-bottom: 4px;
}
.info-content {
    background: #fff;
    padding: 1em;
    border: 1px solid #ddd;
    border-radius: 4px;
    white-space: pre-wrap; /* 改行を反映 */
}

/* --- タイムライン (履歴) --- */
.add-interaction-box {
    background-color: #eef2f7;
    padding: 1.5em;
    border-radius: 8px;
    margin-bottom: 2em;
    border: 1px solid #d1d9e6;
}

.timeline {
    position: relative;
    padding-left: 20px;
}
.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 6px;
    width: 2px;
    background-color: #ddd;
}

.timeline-item {
    display: flex;
    margin-bottom: 1.5em;
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -19px; /* 線の位置に合わせる */
    top: 15px;
    width: 12px;
    height: 12px;
    background-color: #3498db;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px #ddd;
}

.timeline-date {
    width: 60px;
    text-align: right;
    margin-right: 15px;
    padding-top: 10px;
    flex-shrink: 0;
}
.timeline-date .date-main {
    font-weight: bold;
    color: #333;
}
.timeline-date .date-sub {
    font-size: 0.85em;
    color: #888;
}

.timeline-content {
    flex: 1;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 1em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.timeline-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5em;
    font-size: 0.9em;
    border-bottom: 1px solid #f5f5f5;
    padding-bottom: 0.5em;
}
.recorder-name {
    color: #555;
    font-weight: 600;
}
.next-action-badge {
    background-color: #fff3cd;
    color: #856404;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}
.timeline-body {
    line-height: 1.6;
    white-space: pre-wrap; /* 改行を反映 */
}

/* --- 顧客一覧 ホバーツールチップ --- */
#customer-tooltip {
    position: absolute;
    display: none; /* 最初は隠す */
    z-index: 1000; /* 最前面に */
    background-color: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 8px;
    min-width: 250px;
    max-width: 450px;
    width: max-content;
    font-size: 0.9rem;
    color: #333;
    pointer-events: none; /* マウスイベントを透過させる（チラつき防止） */
    line-height: 1.6;
}

/* ツールチップ内のレイアウト */
.tooltip-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed #eee;
    padding-bottom: 4px;
    margin-bottom: 4px;
}
.tooltip-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
.tooltip-label {
    font-weight: bold;
    color: #666;
    margin-right: 10px;
}
.tooltip-val {
    text-align: right;
    font-weight: 500;
}

/* --- CRM一覧テーブルの調整 (行間を狭く) --- */
.crm-table-dense th,
.crm-table-dense td {
    padding: 6px 8px !important; /* 上下6px, 左右8px (通常より狭く) */
    font-size: 0.9rem; /* 文字サイズも少し小さくして情報量を増やす */
    line-height: 1.4;
}

/* ページネーションのデザイン (ログ一覧と同じスタイルを使用) */
.pagination-container {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}
.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    gap: 5px;
}
.page-item .page-link {
    padding: 8px 12px;
    border: 1px solid #ddd;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
}
.page-item.active .page-link {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}
.page-item.disabled .page-link {
    color: #ccc;
    pointer-events: none;
}

/* --- CRM 登録・編集フォーム レイアウト調整 --- */

/* 基本情報エリア: 5列グリッド */
.grid-basic {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5等分 */
    gap: 15px;
    margin-bottom: 1.5em;
}
/* 住所は残り幅いっぱい使う (4列分またぐ) */
.span-address {
    grid-column: span 4; 
}

/* 属性エリア: 4列グリッド */
.grid-attrs {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4等分 */
    gap: 15px;
}

/* レスポンシブ対応 (画面が狭いときは1列に戻す) */
@media (max-width: 768px) {
    .grid-basic, .grid-attrs {
        grid-template-columns: 1fr;
    }
    .span-address {
        grid-column: auto;
    }
}

/* 自動リサイズテキストエリア用 */
.auto-resize-textarea {
    width: 100%;
    min-height: 100px;
    resize: none; /* 右下のツマミを消す */
    overflow: hidden; /* スクロールバーを消す */
    padding: 0.8em;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
    line-height: 1.5;
}