* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* ログイン画面 */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.5rem;
    color: #2c3e50;
}

/* フォーム */
.form-group {
    margin-bottom: 20px;
}

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

/* グローバル入力フォームスタイル */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
}

/* 高さ統一 (ボタンと揃える: 44px) */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
select {
    height: 44px;
}

/* フォーカス時のスタイル */
input:focus,
select:focus,
textarea:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}



button[type="submit"]:not(.btn) {
    width: auto;
    padding: 10px 24px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    white-space: nowrap;
    min-width: 100px;
    min-height: 44px;
}

button[type="submit"]:not(.btn):hover {
    background: #2980b9;
}

button[type="button"]:not(.btn) {
    width: auto;
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    white-space: nowrap;
    min-width: 100px;
    min-height: 44px;
}

/* 統一アクションボタン（大） - 横長で押しやすい形状 */
/* 統一アクションボタン（大） - グラデーション＆フルワイド */
.btn-action-lg {
    width: 100% !important;
    padding: 15px 30px !important;
    font-size: 1.1rem !important;
    font-weight: 700;
    border-radius: 8px !important;
    display: block !important;
    margin: 0 auto !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08) !important;
    transition: all 0.15s ease;
    /* 高さ統一 */
    min-height: 56px !important;
    line-height: 1.5 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-action-lg:hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 14px rgba(50, 50, 93, 0.1), 0 3px 6px rgba(0, 0, 0, 0.08) !important;
    opacity: 0.9;
}

/* 紫色のバリエーション（ルート最適化用） */
.btn-action-lg.btn-purple {
    background: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%) !important;
}

.btn-purple {
    background: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%) !important;
    color: #fff !important;
}

.btn-purple:hover {
    box-shadow: 0 4px 10px rgba(142, 68, 173, 0.3);
    opacity: 0.9;
}

.btn-action-lg.btn-purple:hover {
    box-shadow: 0 7px 14px rgba(142, 68, 173, 0.2), 0 3px 6px rgba(0, 0, 0, 0.08) !important;
}

/* オレンジ色のバリエーション（唱題行報告用） */
.btn-action-lg.btn-orange {
    background: linear-gradient(135deg, #ff6b35 0%, #e74c3c 100%) !important;
}

.btn-orange {
    background: linear-gradient(135deg, #ff6b35 0%, #e74c3c 100%) !important;
    color: #fff !important;
}

.btn-orange:hover {
    box-shadow: 0 4px 10px rgba(255, 107, 53, 0.3);
    opacity: 0.9;
}

.btn-action-lg.btn-orange:hover {
    box-shadow: 0 7px 14px rgba(255, 107, 53, 0.2), 0 3px 6px rgba(0, 0, 0, 0.08) !important;
}

/* ログインフォームなど、幅100%が必要な場所 */
.login-container button {
    width: 100%;
}

.error {
    background: #fee;
    color: #c00;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* ナビゲーション */
.navbar {
    background: #2c3e50;
    color: #fff;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar a {
    color: #fff;
    text-decoration: none;
    margin-left: 20px;
}

.navbar a:hover {
    text-decoration: underline;
}

/* メインコンテンツ */
.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

/* ページヘッダーのタイトル調整 */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* 垂直方向中央揃え */
    margin: 20px 0;
    min-height: 44px;
    /* ボタン高さに合わせる */
}

.page-header h1 {
    margin: 0;
    font-size: 1.25rem;
    /* 小さめ統一 (約20px) */
    font-weight: bold;
    line-height: 1.2;
    color: #2c3e50;
}

/* 後方互換性のため残すが基本は .page-header を使用 */
.container h1 {
    margin: 0;
    font-size: 1.25rem;
    /* コンテナ直下のh1も統一 */
    font-weight: bold;
    line-height: 1.5;
    color: #2c3e50;
}

/* ページヘッダー内のボタン統一 */
.page-header .btn,
.page-header .action-buttons .btn {
    height: 44px !important;
    line-height: 1.2 !important;
    /* フレックスボックスでの配置を補助 */
    padding: 0 20px !important;
    font-size: 1rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 100px !important;
    /* 極端な幅広指定(180px)を解除し、適度な幅に */
    margin: 0 !important;
}

.card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.card h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

/* テーブル */
table {
    width: 100%;
    border-collapse: collapse;
}

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

table th {
    background: #f8f9fa;
    font-weight: bold;
    text-align: center;
    vertical-align: middle;
}

table tr:hover {
    background: #f8f9fa;
}

/* ボタン類 */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 1rem;
    cursor: pointer;
    white-space: nowrap;
    min-width: 100px;
    min-height: 44px;
    line-height: 1.5;
    text-align: center;
    border: none;
}

.btn-primary {
    background: #3498db;
    color: #fff !important;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: #27ae60;
    color: #fff !important;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: #e74c3c;
    color: #fff !important;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
    min-width: 70px;
    min-height: 36px;
}

/* 操作ボタンの横並び */
.action-buttons {
    display: flex;
    gap: 5px;
    align-items: center;
}

.action-buttons form {
    margin: 0;
}


/* 詳細テーブル */
.detail-table {
    width: 100%;
}

.detail-table th {
    width: 120px;
    background: #f8f9fa;
    text-align: left;
}

.detail-table td {
    padding: 12px;
}

.btn-secondary {
    background: #6c757d;
    color: #fff !important;
}

.btn-secondary:hover {
    background: #5a6268;
    color: #fff !important;
    text-decoration: none;
}

/* 検索フォーム */
.search-form {
    margin: 0;
}

.search-row {
    display: grid !important;
    grid-template-columns: repeat(12, 1fr) !important;
    gap: 15px !important;
    align-items: end !important;
    width: 100% !important;
}

.search-item.col-md-2 {
    grid-column: span 2;
}

.search-item.col-md-4 {
    grid-column: span 4;
}

.search-item {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    width: 100% !important;
    min-width: 0 !important;
    /* Prevent flex items from overflowing */
}

.search-item label {
    font-size: 0.85rem;
    font-weight: bold;
}

.search-item input,
.search-item select {
    /* グローバルスタイルと一致させるが、レイアウト強制のため !important を維持 */
    height: 44px !important;
    padding: 0 12px !important;
    /* heightがある場合は垂直centerになるのでpadding調整 */
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-size: 1rem !important;
}

.search-item input:focus,
.search-item select:focus {
    border-color: #3498db !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1) !important;
}

.search-buttons {
    grid-column: 1 / -1 !important;
    display: flex !important;
    justify-content: center !important;
    gap: 10px !important;
    margin-top: 20px !important;
    padding-top: 10px;
    border-top: 1px solid #eee;
    /* Optional: adds subtle separation */
}

.search-buttons button,
.search-buttons .btn {
    width: auto !important;
    min-width: 120px !important;
}

@media (max-width: 1200px) {
    .search-row {
        grid-template-columns: repeat(6, 1fr) !important;
    }

    .search-item.col-md-2 {
        grid-column: span 3;
    }

    .search-item.col-md-4 {
        grid-column: span 6;
    }
}

@media (max-width: 768px) {
    .search-row {
        grid-template-columns: 1fr !important;
    }

    .search-item.col-md-2,
    .search-item.col-md-4 {
        grid-column: auto;
    }
}

/* 御講参詣記録検索フォーム */
.attendance-search-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr 1fr auto !important;
    gap: 15px !important;
    align-items: end !important;
    width: 100% !important;
}

@media (max-width: 768px) {
    .attendance-search-row {
        grid-template-columns: 1fr 1fr !important;
    }

    .attendance-search-row button {
        grid-column: 1 / -1;
    }
}

@media (max-width: 480px) {
    .attendance-search-row {
        grid-template-columns: 1fr !important;
    }
}

/* トグルスイッチ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background-color: #3498db;
}

input:checked+.toggle-slider:before {
    transform: translateX(24px);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ハンバーガーメニュー */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 0;
}

.nav-links a {
    margin-left: 20px;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #2c3e50;
        flex-direction: column;
        padding: 10px 0;
        z-index: 1000;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a {
        margin: 0;
        padding: 12px 20px;
        border-bottom: 1px solid #3d566e;
    }

    .nav-links a:hover {
        background: #3d566e;
    }

    .navbar {
        position: relative;
    }
}

/* ボタンのテキスト色統一 */
.btn {
    color: #fff !important;
    text-decoration: none;
}

.btn:hover {
    opacity: 0.9;
}

/* テーブルのレスポンシブ対応 */
.table-container {
    overflow-x: auto;
    max-height: 70vh;
    overflow-y: auto;
    position: relative;
}

.table-container table {
    min-width: 600px;
    border-collapse: collapse;
}

.table-container table th,
.table-container table td {
    white-space: nowrap;
    padding: 8px 15px;
    /* スリム化: 上下paddingを縮小 */
}

.table-container thead th {
    position: sticky;
    top: 0;
    background: #2c3e50 !important;
    color: #fff !important;
    z-index: 10;
    text-align: center;
    vertical-align: middle;
}

.table-container tbody td {
    /* height: 45px; 固定高さを削除し、パディングで高さを確保 */
    vertical-align: middle;
}

.table-container tbody tr:nth-child(even) {
    background: #f9f9f9;
}

.table-container tbody tr:hover {
    background: #e8f4fc !important;
}

/* ヘッダーリンク（一般ユーザー用ナビゲーション） */
.header-links {
    display: flex;
    gap: 20px;
}

.header-links a {
    color: #fff;
    text-decoration: none;
}

.header-links a:hover {
    text-decoration: underline;
}

/* 検索項目幅の拡張用 */
.search-item.span-2 {
    grid-column: span 2;
}

@media (max-width: 480px) {
    .search-item.span-2 {
        grid-column: auto;
    }
}