/* ===== 基本設定 ===== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f5f7fb;
    color: #333;
    display: flex;
    flex-direction: column;
}

/* ===== ヘッダー ===== */
header {
    background: #ffffff;
    border-bottom: 1px solid #ddd;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* 現在時刻 */
#clock {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

/* ===== ナビゲーション ===== */
nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

nav a {
    text-decoration: none;
    color: #333;
    background: #f0f3f8;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    transition: 0.2s ease;
}

nav a:hover {
    background: #4f7cff;
    color: #fff;
    transform: translateY(-1px);
}

/* ログアウトだけ少し色を変える */
nav a[href$="logout.php"] {
    background: #ffecec;
    color: #d33;
}

nav a[href$="logout.php"]:hover {
    background: #e53935;
    color: #fff;
}

/* ===== main ===== */
main {
    flex: 1;
    width: 100%;
    max-width: 1000px;
    margin: 32px auto;
    padding: 0 20px;
}

form {
    padding: 0 20px;
    text-align: center;
}

/* ===== スマホ対応 ===== */
@media (max-width: 600px) {
    header {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
    }

    #clock {
        text-align: center;
        font-size: 13px;
    }

    nav {
        justify-content: center;
        gap: 8px;
    }

    nav a {
        font-size: 13px;
        padding: 8px 12px;
    }

    main {
        margin: 24px auto;
        padding: 0 14px;
    }
}

/* ===== フッター ===== */
footer {
    margin-top: 48px;
    padding: 20px;
    text-align: center;
    background: #ffffff;
    border-top: 1px solid #ddd;
    color: #777;
    font-size: 13px;
}

footer p {
    margin: 0;
}

.attendance-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    justify-content: center;
}
.attendance-form label {
    font-weight: bold;
}

.attendance-form input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #334;
    color: var(--fg);
}

.attendance-form select {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #334;
    color: var(--fg);
}

.attendance-form button {
    font-size: medium;
    background: #dfebff;
    padding: 6px 14px;
    border-radius: 999px;
}

.attendance-form button:hover {
    background: #4f7cff;
    color: #fff;
    transform: translateY(-1px);
}

.deletebtn {
    color: #ffffff !important;
    background: #ff5757 !important;
}

.deletebtn:hover {
    background: #ff9797 !important;
    transform: translateY(-1px) !important;
}

.time-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    justify-content: center;
}
.time-form label {
    font-weight: bold;
}

.time-form input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #334;
    color: var(--fg);
}

.time-form select {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #334;
    color: var(--fg);
}

.time-form button {
    font-size: medium;
    background: #dfebff;
    padding: 6px 14px;
    border-radius: 999px;
}

.time-form button:hover {
    background: #4f7cff;
    color: #fff;
    transform: translateY(-1px);
}

.calendar-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    justify-content: center;
}

.calendar-form label {
    font-weight: bold;
}

.calendar-form input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #334;
    color: var(--fg);
}

.calendar-form select {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #334;
    color: var(--fg);
}

.calendar-form button {
    font-size: medium;
    background: #dfebff;
    padding: 6px 14px;
    border-radius: 999px;
}

.calendar-form button:hover {
    background: #4f7cff;
    color: #fff;
    transform: translateY(-1px);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-top: 20px;
}

.calendar-weekday {
    padding: 10px;
    text-align: center;
    font-weight: bold;
    background: #f0ecff;
    border-radius: 8px;
}

.calendar-day {
    min-height: 110px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
}

.calendar-day.empty {
    background: transparent;
    border: none;
}

.calendar-date {
    font-weight: bold;
    margin-bottom: 6px;
}

.calendar-attendance p {
    margin: 3px 0;
    font-size: 0.9rem;
}

.calendar-attendance.no-record {
    color: #999;
}

.total-work-time {
    margin-top: 20px;
    font-size: 1.1rem;
    font-weight: bold;
}

.calendar-date a {
    color: #333;
    text-decoration: none;
    font-weight: bold;
}

.calendar-date a:hover {
    text-decoration: underline;
}

/* スマホ用 */
@media (max-width: 600px) {
    .calendar-grid {
        gap: 4px;
    }

    .calendar-day {
        min-height: 90px;
        padding: 5px;
        font-size: 0.75rem;
    }

    .calendar-weekday {
        padding: 6px;
        font-size: 0.8rem;
    }

    .calendar-attendance p {
        font-size: 0.7rem;
    }
}

/* ===== ページ見出し ===== */
h2 {
    margin: 0 0 24px;
    font-size: 24px;
    color: #333;
    text-align: center;
}

/* ===== 勤怠履歴テーブル ===== */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    border: none;
}

table th,
table td {
    padding: 14px 12px;
    text-align: center;
    border-bottom: 1px solid #e5e8ef;
    font-size: 14px;
}

table th {
    background: #4f7cff;
    color: #fff;
    font-weight: 700;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:nth-child(even) {
    background: #f8faff;
}

table tr:hover {
    background: #eef3ff;
}

/* ===== 総勤務時間 ===== */
.total-work-time {
    margin: 24px 0 16px;
    padding: 16px 20px;
    background: #ffffff;
    border-left: 5px solid #4f7cff;
    border-radius: 12px;
    font-size: 17px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
}

.total-work-time strong {
    color: #333;
}

/* ===== 戻るリンク ===== */
p a {
    display: inline-block;
    text-decoration: none;
    background: #f0f3f8;
    color: #333;
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 600;
    transition: 0.2s ease;
}

p a:hover {
    background: #4f7cff;
    color: #fff;
    transform: translateY(-1px);
}

/* ===== スマホ対応 ===== */
@media (max-width: 600px) {
    h2 {
        font-size: 20px;
        line-height: 1.5;
    }

    table {
        font-size: 13px;
        border-radius: 12px;
    }

    table th,
    table td {
        padding: 10px 6px;
        font-size: 12px;
    }

    p:has(strong) {
        font-size: 15px;
        padding: 14px 16px;
    }

    p a {
        width: 100%;
        text-align: center;
    }
}

/* ===== ユーザー一覧：操作ボタン ===== */
.user-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.delete-form {
    margin: 0;
}

/* 編集ボタン */
.btn-edit {
    display: inline-block;
    text-decoration: none;
    background: #eef3ff;
    color: #3366cc;
    border: 1px solid #c9d8ff;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    transition: 0.2s ease;
}

.btn-edit:hover {
    background: #4f7cff;
    color: #fff;
    border-color: #4f7cff;
    transform: translateY(-1px);
}

/* 削除ボタン */
.btn-delete {
    border: none;
    background: #ffecec;
    color: #d33;
    border: 1px solid #ffcaca;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-delete:hover {
    background: #e53935;
    color: #fff;
    border-color: #e53935;
    transform: translateY(-1px);
}

.login {
    display: flex;
    flex-direction: column;
    max-width: 420px;
    margin: 24px auto;
    padding: 32px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.login label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 600;
    color: #374151;
}

.login input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-sizing: border-box;
    outline: none;
}

.login button {
    margin-top: 8px;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    background: #2563eb;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}

.addregister {
    text-align: center;
}

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

.logout {
    background: #ffecec;
    color: #d33;
}

.logout:hover {
    background: #e53935;
    color: #fff;
}

.backbtn {
    text-align: center;
}

.backbtn a {
    background: #d5e4ff;
}

.backbtn a:hover {
    background: #784fff;
    color: #fff;
    transform: translateY(-1px);
}

.title {
    text-align: center;
}

.menu {
    text-align: center;
}

/* ===== 出勤・退勤フォーム ===== */
.attendance-form {
    max-width: 420px;
    margin: 32px auto;
    padding: 28px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
}

/* 出勤・退勤ボタン共通 */
.btn-clock-in,
.btn-clock-out {
    width: 100%;
    max-width: 260px;
    border: none;
    padding: 16px 24px;
    border-radius: 999px;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

/* 出勤ボタン */
.btn-clock-in {
    background: #4f7cff;
}

.btn-clock-in:hover {
    background: #345fd6;
    transform: translateY(-2px);
}

/* 退勤ボタン */
.btn-clock-out {
    background: #f59e0b;
}

.btn-clock-out:hover {
    background: #d97706;
    transform: translateY(-2px);
}

/* 出勤済み・退勤済み表示 */
.clock-status {
    width: 100%;
    max-width: 300px;
    margin: 0;
    padding: 14px 18px;
    background: #f5f7fb;
    border-radius: 12px;
    text-align: center;
    color: #555;
    font-weight: 600;
}

/* スマホ対応 */
@media (max-width: 600px) {
    .attendance-form {
        margin: 24px auto;
        padding: 22px 18px;
    }

    .btn-clock-in,
    .btn-clock-out {
        font-size: 16px;
        padding: 14px 20px;
    }
}

/* ===== 管理者：ユーザー別勤怠カード ===== */
.attendance-user-card {
    margin-bottom: 24px;
    padding: 22px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
}

/* ユーザー名 + 勤怠修正ボタン */
.attendance-user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e8ef;
}

.attendance-user-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

/* 勤怠修正ボタン */
.btn-attendance-edit {
    display: inline-block;
    text-decoration: none;
    background: #eef3ff;
    color: #3366cc;
    border: 1px solid #c9d8ff;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    transition: 0.2s ease;
}

.btn-attendance-edit:hover {
    background: #4f7cff;
    color: #fff;
    border-color: #4f7cff;
    transform: translateY(-1px);
}

/* 勤怠ログ一覧 */
.attendance-log-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.attendance-log-list li {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr 1fr;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #edf0f5;
    font-size: 14px;
    color: #444;
}

.attendance-log-list li:last-child {
    border-bottom: none;
}

.attendance-log-list li:nth-child(even) {
    background: #f8faff;
}

.attendance-log-list span {
    word-break: keep-all;
}

/* スマホ対応 */
@media (max-width: 700px) {
    .attendance-user-card {
        padding: 18px;
    }

    .attendance-user-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-attendance-edit {
        width: 100%;
        text-align: center;
    }

    .attendance-log-list li {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 12px;
        border-radius: 10px;
        margin-bottom: 10px;
        background: #f8faff;
        border-bottom: none;
    }
}

/* ===== ユーザー編集フォーム ===== */
.user-edit-form {
    max-width: 460px;
    margin: 32px auto;
    padding: 28px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.user-edit-form label {
    display: block;
    margin-bottom: 20px;
}

.user-edit-form label span {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
    font-weight: 700;
}

.user-edit-form input,
.user-edit-form select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d8deea;
    border-radius: 999px;
    background: #f8faff;
    color: #333;
    font-size: 15px;
    outline: none;
    transition: 0.2s ease;
}

.user-edit-form input:focus,
.user-edit-form select:focus {
    border-color: #4f7cff;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(79, 124, 255, 0.12);
}

/* selectの見た目調整 */
.user-edit-form select {
    cursor: pointer;
}

/* 更新ボタン */
.btn-update {
    width: 100%;
    border: none;
    margin-top: 8px;
    padding: 14px 20px;
    border-radius: 999px;
    background: #4f7cff;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
    box-shadow: 0 4px 10px rgba(79, 124, 255, 0.28);
}

.btn-update:hover {
    background: #345fd6;
    transform: translateY(-1px);
}

/* スマホ対応 */
@media (max-width: 600px) {
    .user-edit-form {
        margin: 24px auto;
        padding: 22px 18px;
    }

    .user-edit-form input,
    .user-edit-form select {
        font-size: 14px;
    }
}