/* リセットとベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* 管理者ページ用のワイドコンテナ */
body.admin-page .container {
    max-width: 1200px;
}

body.admin-page main {
    padding: 30px 40px;
}

/* 管理者ページのコンテンツ幅制限 */
body.admin-page #requestsTab,
body.admin-page #shiftsTab,
body.admin-page #usersTab {
    max-width: 900px;
    margin: 0 auto;
}

body.admin-page #calendarTab {
    max-width: 100%;
}

/* ヘッダー */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

header .subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* ナビゲーション */
nav {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-info {
    font-size: 14px;
    color: #495057;
}

.nav-info strong {
    color: #667eea;
}

.btn-logout {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: #c82333;
}

/* メインコンテンツ */
main {
    padding: 30px 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ボタン */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #28a745;
    color: white;
}

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

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

.btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 14px;
}

/* 情報ボックス */
.info-box {
    background: #e7f3ff;
    border-left: 4px solid #667eea;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.info-box h3 {
    margin-bottom: 12px;
    color: #667eea;
    font-size: 18px;
}

.info-box ul {
    list-style: none;
    padding-left: 0;
}

.info-box li {
    margin-bottom: 8px;
    line-height: 1.6;
    font-size: 14px;
}

/* ログインセクション */
.login-section {
    max-width: 400px;
    margin: 0 auto;
}

/* タブナビゲーション */
.tabs {
    display: flex;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    padding: 12px;
    background: #f8f9fa;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    color: #6c757d;
}

.tab.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.tab:hover {
    background: #e9ecef;
}

/* タイムスロット選択 */
.time-slots {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.time-slot {
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 600;
}

.time-slot:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.time-slot.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

/* シフトカード */
.shift-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid #667eea;
}

.shift-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.shift-date {
    font-weight: 700;
    font-size: 16px;
    color: #495057;
}

.shift-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-pending {
    background: #ffc107;
    color: #000;
}

.status-approved {
    background: #28a745;
    color: white;
}

.shift-time {
    font-size: 20px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 8px;
}

.shift-notes {
    font-size: 14px;
    color: #6c757d;
    margin-top: 8px;
}

/* リクエストカード（管理者用） */
.request-card {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.3s;
}

.request-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.request-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.request-user {
    font-weight: 700;
    font-size: 18px;
    color: #495057;
}

.request-date {
    font-weight: 600;
    color: #667eea;
}

.request-time-slots {
    margin: 12px 0;
}

.time-slot-tag {
    display: inline-block;
    background: #e7f3ff;
    color: #667eea;
    padding: 6px 12px;
    border-radius: 6px;
    margin-right: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

.request-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.shift-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
}

/* 空の状態 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
}

/* ローディング */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #667eea;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* カレンダーグリッド */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    padding: 8px;
}

.calendar-day:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.calendar-day.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.day-number {
    font-size: 18px;
    font-weight: 700;
}

.day-name {
    font-size: 10px;
    margin-top: 4px;
}

/* レスポンシブ対応 */
@media (max-width: 480px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
        min-height: 100vh;
    }

    header h1 {
        font-size: 24px;
    }

    main {
        padding: 20px 15px;
    }

    .time-slots {
        grid-template-columns: 1fr;
    }

    .calendar-grid {
        gap: 4px;
    }

    .day-number {
        font-size: 14px;
    }

    .day-name {
        font-size: 9px;
    }
}

/* アラート・メッセージ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

/* フィルター・検索エリア */
.filter-section {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.filter-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.filter-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* シフト編集フォーム */
.shift-form {
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.shift-form h3 {
    color: #667eea;
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

    .filter-row {
        flex-direction: column;
    }
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

/* カレンダー */
.calendar-section {
    margin-bottom: 30px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
}

.calendar-section-title {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 18px;
    padding: 12px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.calendar-header {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 15px;
    color: #495057;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding: 6px 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 15px;
    width: 100%;
}

.calendar-day-header {
    text-align: center;
    font-weight: 700;
    padding: 8px 4px;
    color: white;
    font-size: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 5px;
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.25);
}

.calendar-day {
    min-height: 80px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px;
    background: white;
    position: relative;
    overflow: visible;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
}

.calendar-day:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.calendar-day.empty {
    background: #fafafa;
    border-color: #f0f0f0;
    box-shadow: none;
}

.calendar-day.empty:hover {
    transform: none;
}

.calendar-day.clickable-empty:hover {
    background: #e7f3ff;
    border-color: #667eea;
}

.calendar-day.clickable-empty:hover .day-number {
    color: #667eea;
}

.calendar-day.has-shift {
    background: linear-gradient(135deg, #f0f4ff 0%, #e7f3ff 100%);
    border-color: #667eea;
    border-width: 2px;
}

.calendar-day.weekend {
    background: #f8f9fa;
    opacity: 0.5;
    cursor: default;
}

.calendar-day.weekend:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transform: none;
}

.calendar-day.weekend .day-number {
    color: #adb5bd;
    text-decoration: line-through;
}

.day-number {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 4px;
    color: #495057;
    padding-bottom: 3px;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.calendar-day.has-shift .day-number {
    color: #667eea;
    border-bottom-color: #667eea;
}

.shift-info {
    font-size: 10px;
    /* デフォルトの背景色は削除 - ステータス別のクラスで指定 */
    color: white;
    padding: 5px 4px;
    border-radius: 4px;
    margin-top: 3px;
    word-wrap: break-word;
    line-height: 1.3;
    font-weight: 700;
    text-align: center;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* シフト管理用の色分け */
/* 未承認シフト（黄色） */
.shift-info.request-pending,
.shift-info.shift-request {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%) !important;
    color: #000 !important;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.4) !important;
    font-weight: 700;
}

/* 承認済み・確定シフト（緑色） */
.shift-info.shift-confirmed {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%) !important;
    color: white !important;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.4) !important;
    font-weight: 700;
}

/* 複数日付選択用カレンダー */
.multi-date-selector {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.date-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
}

.date-selector-header span {
    font-size: 18px;
    font-weight: 600;
    color: #495057;
}

.btn-small {
    background: #667eea;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-small:hover {
    background: #5568d3;
}

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

.date-calendar-header {
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: #495057;
    padding: 8px 0;
}

.date-calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    background: white;
    font-size: 14px;
    transition: all 0.2s;
    padding: 4px;
    overflow: hidden;
}

.date-calendar-day:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.date-calendar-day.disabled {
    color: #adb5bd;
    cursor: not-allowed;
    background: #f8f9fa;
    opacity: 0.6;
}

.date-calendar-day.disabled:hover {
    border-color: #dee2e6;
    background: #f8f9fa;
}

.date-calendar-day.disabled .date-num {
    text-decoration: line-through;
}

.date-calendar-day.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    font-weight: 600;
}

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

.date-calendar-day .date-num {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
    width: 100%;
    text-align: center;
}

.date-calendar-day .mini-shift {
    font-size: 8px;
    padding: 2px 3px;
    border-radius: 3px;
    margin-top: 2px;
    width: 100%;
    text-align: center;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.date-calendar-day .mini-shift.request {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #000;
}

.date-calendar-day .mini-shift.confirmed {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
}

.date-calendar-day.selected .date-num {
    color: white;
}

.selected-dates-display {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    min-height: 50px;
}

.selected-dates-display strong {
    display: block;
    margin-bottom: 8px;
    color: #495057;
    font-size: 14px;
}

.selected-date-tag {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    margin: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.selected-date-tag:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
    transform: scale(0.95);
}

.selected-date-tag::after {
    content: " ×";
    margin-left: 5px;
    font-weight: bold;
}

/* 週合計表示（コンパクト版） */
.weekly-totals {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.week-total-card {
    background: white;
    border: 2px solid #667eea;
    border-radius: 6px;
    padding: 10px 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    min-width: 140px;
}

.week-total-card h4 {
    margin: 0 0 6px 0;
    font-size: 12px;
    color: #495057;
    font-weight: 700;
    text-align: center;
}

.week-total-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 3px 0;
    font-size: 11px;
}

.week-total-label {
    color: #6c757d;
    font-size: 10px;
}

.week-total-value {
    font-weight: 700;
    font-size: 13px;
}

.week-total-value.request {
    color: #ff9800; /* 未承認は黄色（オレンジ） */
}

.week-total-value.confirmed {
    color: #28a745; /* 承認済みは緑色 */
}

@media (max-width: 768px) {
    .calendar-day {
        min-height: 70px;
        padding: 6px;
    }

    .day-number {
        font-size: 14px;
    }

    .shift-info {
        font-size: 10px;
    }

    .calendar-grid {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .calendar-day {
        min-height: 60px;
        padding: 4px;
        aspect-ratio: unset; /* スマホでは正方形を解除 */
    }

    .day-number {
        font-size: 12px;
    }

    .shift-info {
        font-size: 9px;
        padding: 2px 4px;
    }

    .calendar-grid {
        gap: 3px; /* ギャップを狭めて全体を表示 */
    }
    
    /* 日付カレンダーのスマホ対応 */
    .date-calendar {
        gap: 3px;
    }
    
    .date-calendar-day {
        aspect-ratio: unset; /* スマホでは正方形を解除 */
        min-height: 60px;
        padding: 3px;
    }
    
    .date-calendar-day .date-num {
        font-size: 11px;
    }
    
    .date-calendar-day .mini-shift {
        font-size: 7px;
        padding: 1px 2px;
    }
}

/* トースト通知 */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: white;
    color: #333;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 15px;
    font-weight: 600;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-left: 4px solid #28a745;
}

.toast.success::before {
    content: '✓';
    display: inline-block;
    width: 24px;
    height: 24px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-weight: bold;
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast.error::before {
    content: '✕';
    display: inline-block;
    width: 24px;
    height: 24px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-weight: bold;
}

.toast.info {
    border-left: 4px solid #17a2b8;
}

.toast.info::before {
    content: 'ℹ';
    display: inline-block;
    width: 24px;
    height: 24px;
    background: #17a2b8;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-weight: bold;
}
