:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-color: #ddd;
    --bg-color: #f4f6f8;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: #333;
    line-height: 1.6;
}

/* ヘッダー */
.main-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
}

.menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    margin-right: 15px;
    padding: 5px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

h1 {
    font-size: 1.2rem;
    margin: 0;
}

h2.page-title {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--dark-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
}

/* サイドメニュー */
.side-menu {
    position: fixed;
    top: 0;
    left: -250px;
    width: 250px;
    height: 100vh;
    background-color: white;
    box-shadow: 2px 0 5px rgba(0,0,0,0.2);
    transition: left 0.3s ease;
    z-index: 1000;
    padding: 20px 0;
}

.side-menu.open {
    left: 0;
}

.close-menu-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #333;
    min-width: 44px;
    min-height: 44px;
}

.side-menu nav ul {
    list-style: none;
    margin-top: 30px;
}

.side-menu nav ul li a {
    display: block;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    border-bottom: 1px solid var(--border-color);
    min-height: 48px; /* タップ領域 */
    display: flex;
    align-items: center;
}

.side-menu nav ul li a:hover {
    background-color: var(--light-color);
}

.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 900;
}

.menu-overlay.open {
    display: block;
}

/* メインコンテナ */
.container {
    padding: 15px;
    max-width: 800px;
    margin: 0 auto;
}

/* ログイン画面 */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: var(--primary-color);
}

.login-container {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.login-container h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 20px;
}

/* フォーム要素 */
.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group.row {
    display: flex;
    gap: 10px;
}
.form-group.row .col {
    flex: 1;
}

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

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 16px; /* iOSのズーム防止 */
    min-height: 44px;
}

button {
    cursor: pointer;
    font-size: 16px;
    border-radius: 4px;
    border: none;
    min-height: 44px;
}

.btn {
    padding: 10px 15px;
    font-weight: bold;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-lg {
    padding: 15px;
    font-size: 1.1rem;
}

.btn-text {
    background: none;
    border: none;
    font-size: 14px;
    font-weight: bold;
    min-width: 44px;
    min-height: 44px;
    padding: 5px;
}

.text-primary { color: var(--primary-color); }
.text-danger { color: var(--danger-color); }
.text-muted { color: var(--secondary-color); }
.text-center { text-align: center; }

/* 生徒カード（出欠入力） */
.student-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.student-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
}

.student-name {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0;
}

.control-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.control-row:last-child {
    margin-bottom: 0;
}

/* トグルボタン */
.toggle-group {
    display: flex;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    flex: 1;
}

.btn-toggle {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 0;
    min-height: 44px;
    font-size: 14px;
    font-weight: bold;
    color: var(--secondary-color);
    transition: all 0.2s;
}

.btn-toggle.active {
    color: white;
}

.btn-attendance {
    min-width: 56px;
    min-height: 44px;
    padding: 8px 14px;
    font-size: 16px;
    font-weight: bold;
    background-color: var(--secondary-color);
    color: white;
    border-radius: 4px;
    border: none;
    transition: background-color 0.2s;
}

.btn-attendance.active {
    background-color: var(--success-color);
}

.btn-pc {
    min-width: 72px;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: bold;
    background-color: #e9ecef;
    color: #333;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    transition: background-color 0.2s;
    white-space: nowrap;
}

.btn-pc.active {
    background-color: var(--success-color);
}

.payment-group {
    flex: 1;
}

.pc-group {
    display: flex;
    align-items: center;
}

.memo-group {
    flex: 1;
}

/* 固定フッター */
.sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255,255,255,0.9);
    padding: 15px;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    z-index: 100;
}

/* メッセージ表示 */
.flash-messages {
    margin-bottom: 15px;
}

.flash {
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    color: white;
}

.flash.success { background-color: var(--success-color); }
.flash.error { background-color: var(--danger-color); }

/* バッジ */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}
.badge-success { background-color: var(--success-color); color: white;}
.badge-danger { background-color: var(--danger-color); color: white;}
.badge-warning { background-color: var(--warning-color); color: #333;}

/* 設定ナビ */
.settings-nav {
    display: flex;
    margin-bottom: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-group-item {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    text-decoration: none;
    color: var(--secondary-color);
    font-weight: bold;
    border-right: 1px solid var(--border-color);
}

.btn-group-item.active {
    background-color: var(--primary-color);
    color: white;
}

/* アラート */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeeba;
}

/* ユーティリティ */
.mt-3 { margin-top: 15px; }
.mb-3 { margin-bottom: 15px; }
.mb-4 { margin-bottom: 20px; }
.mr-2 { margin-right: 10px; }
.ml-2 { margin-left: 10px; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.gap-2 { gap: 10px; }
.flex-grow-1 { flex-grow: 1; }
.border { border: 1px solid var(--border-color); }
.p-3 { padding: 15px; }
.rounded { border-radius: 8px; }
.bg-light { background-color: var(--light-color); }
.mt-muted { opacity: 0.6; }

/* 表示切替ボタン */
.view-toggle {
    display: flex;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.btn-view {
    flex: 1;
    padding: 10px;
    background: white;
    color: var(--secondary-color);
    border: none;
    font-weight: bold;
    font-size: 14px;
    border-right: 1px solid var(--border-color);
}

.btn-view:last-child {
    border-right: none;
}

.btn-view.active {
    background-color: var(--primary-color);
    color: white;
}

/* 出欠表 */
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

.attendance-table {
    border-collapse: collapse;
    white-space: nowrap;
}

.attendance-table th,
.attendance-table td {
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    text-align: center;
    font-size: 0.85rem;
}

.attendance-table .name-col {
    text-align: left;
    min-width: 80px;
    position: sticky;
    left: 0;
    background: white;
    z-index: 1;
}

.attendance-table thead th {
    background-color: var(--light-color);
    font-weight: bold;
}

.attendance-table thead th.name-col {
    background-color: var(--light-color);
    z-index: 2;
}

/* 記録リスト用 */
.date-divider {
    font-size: 1.1rem;
    margin: 20px 0 10px 0;
    color: var(--primary-color);
    border-bottom: 1px solid var(--primary-color);
}

.record-card {
    background: white;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.record-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.record-name {
    font-weight: bold;
    font-size: 1.05rem;
}

.record-details p {
    margin: 2px 0;
    font-size: 0.9rem;
    color: #555;
}

.record-actions {
    margin-top: 10px;
    text-align: right;
    border-top: 1px dashed var(--border-color);
    padding-top: 5px;
}
