/* レッスンスケジューラー スタイル */

/* カスタムコース色の定義 */
.course-jr {
    background-color: #EA80FC !important; /* ジュニア: #EA80FC */
}
.course-jr-text {
    color: #ffffff !important; /* 白文字 */
}

.course-sho1 {
    background-color: #76C694 !important; /* 初級1: #76C694 */
}
.course-sho1-text {
    color: #ffffff !important; /* 白文字 */
}

.course-sho2 {
    background-color: #51A1FD !important; /* 初級2: #51A1FD */
}
.course-sho2-text {
    color: #ffffff !important; /* 白文字 */
}

.course-chu1 {
    background-color: #FFBB00 !important; /* 中級1: #FFBB00 */
}
.course-chu1-text {
    color: #ffffff !important; /* 白文字 */
}

.course-chu2 {
    background-color: #FD8B46 !important; /* 中級2: #FD8B46 */
}
.course-chu2-text {
    color: #ffffff !important; /* 白文字 */
}

/* body要素は下記で再定義されています */

/* サイバーパンク風背景効果 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 40% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
    animation: backgroundPulse 8s ease-in-out infinite alternate;
}

@keyframes backgroundPulse {
    0% { opacity: 0.5; }
    100% { opacity: 0.8; }
}

.calendar-grid {
    display: grid;
    /* grid-template-columns and rows are now set by JS */
    gap: 1px; /* グリッド間の隙間を最小化 */
    transition: all 0.3s ease-in-out;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.time-slot-cell {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column; /* 縦方向のレイアウトに変更 */
    padding: 4px;
    min-height: 40px; /* より小さな最小高さに変更 */
    height: 100%; /* 親要素のサイズに合わせる */
    box-sizing: border-box;
}

/* 時間帯表示を上部に固定 */
.time-slot-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b; /* gray-500 */
    text-align: center;
    padding: 2px 0;
    border-bottom: 1px solid #e2e8f0; /* gray-200 */
    background-color: #f8fafc; /* gray-50 */
    margin-bottom: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.time-slot-header:hover {
    background-color: #e2e8f0; /* gray-200 */
}

.time-slot-header[contenteditable="true"] {
    background-color: #dbeafe; /* blue-100 */
    border-color: #3b82f6; /* blue-500 */
    outline: none;
}

/* コース表示エリア */
.course-display-area {
    flex-grow: 1;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 2px;
    background-color: #ffffff; /* 白色背景を追加 */
    border-radius: 4px; /* 少し角丸で視覚的に分離 */
    padding: 2px; /* 内側に少し余白 */
}

.calendar-cell {
    height: 100%; /* グリッドの行サイズに合わせる */
    box-sizing: border-box;
    display: flex;
    flex-direction: row; /* 水平方向に並べる */
    flex-wrap: nowrap; /* 1行に収める */
    gap: 0; /* 隙間を完全に削除 */
    align-items: stretch; /* セル全体に伸ばす */
    justify-content: stretch; /* 横方向も伸ばす */
    padding: 0; /* パディングを完全に削除 */
}

/* 週ラベルのスタイル */
.week-label {
    font-size: 0.75rem;
    line-height: 1.2;
    min-height: 100%;
}

/* 時間ラベルのスタイル */
.time-label {
    font-size: 0.7rem;
    line-height: 1.1;
    min-height: 100%;
    white-space: nowrap; /* 1行で表示するように折り返しを禁止 */
    overflow: hidden;
    text-overflow: ellipsis; /* 長すぎる場合は省略記号で表示 */
}

/* 編集可能な時間表示のスタイル */
.editable-time[contenteditable="true"] {
    background-color: #dbeafe !important; /* blue-100 */
    border-color: #3b82f6 !important; /* blue-500 */
    outline: none;
}

.calendar-cell > .time-slot-cell:last-child {
    border-bottom: none;
}

/* ヘッダーセクション - サイバー感アップ */
.header-section {
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(248, 250, 252, 0.9) 100%
    );
    backdrop-filter: blur(10px);
    box-shadow: 
        0 8px 32px rgba(59, 130, 246, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.header-section h1 {
    font-family: 'Noto Sans JP', sans-serif;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-section img {
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

/* カレンダーコンテナ - 完全固定サイズ */
#calendar-container {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.9) 0%, 
        rgba(248, 250, 252, 0.8) 100%
    ) !important;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    
    /* 完全固定サイズ - JavaScriptで制御 */
    overflow: hidden;
    box-sizing: border-box;
    position: relative;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* 重複削除 - 下記で再定義されています */

/* 表示設定パネルもモダン化 */
#display-options {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.9) 0%, 
        rgba(248, 250, 252, 0.8) 100%
    ) !important;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

#course-list {
    display: flex !important;
    flex-direction: row !important; /* 強制的に水平配置 */
    align-items: center !important; /* コースアイテムを中央配置 */
    justify-content: center !important; /* 中央寄せ */
    flex-wrap: wrap !important; /* 必要に応じて折り返し */
    gap: 8px !important; /* コース間のスペースを調整 */
    transition: all 0.3s ease-in-out !important; /* アニメーション */
    overflow: hidden !important; /* はみ出し防止 */
}

.calendar-cell .course-item {
    display: flex; /* Use flex for text centering */
    align-items: center; /* Vertically center text inside */
    justify-content: center; /* Center text horizontally */
    flex-direction: column; /* 2行表示のため縦配置に変更 */
    flex: 1 1 0; /* 均等分割（ベース幅を0にして強制的に等分） */
    width: 0; /* 明示的に幅を0に設定して等分を強制 */
    min-width: 0; /* 最小幅制約を削除 */
    height: 100%; /* セルの高さを100%使用 */
    min-height: 100%; /* 最小高さもセル全体 */
    white-space: nowrap; /* テキストが折り返さないように設定 */
    text-overflow: ellipsis; /* 長いテキストは省略記号で表示 */
    cursor: grab;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.08), /* 影を控えめに */
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    font-size: inherit; /* 親要素のフォントサイズを継承 */
    padding: 0; /* パディングを削除してピッチリフィット */
    margin: 0; /* マージンを完全に削除 */
    border-radius: 0; /* 角丸を削除してピッチリフィット */
    box-sizing: border-box;
}

/* 2行表示のコースアイテム内のテキスト行 */
.calendar-cell .course-item > div {
    display: block;
    width: 100%;
    text-align: center;
    line-height: 1.1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 2行表示の2行目のデフォルトマージン */
.calendar-cell .course-item > div:nth-child(2) {
    margin-top: 2px; /* デスクトップのデフォルト値、JSで上書きされる */
}

/* コース編集中のテキストエリア */
.calendar-cell .course-item textarea {
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    resize: none !important;
    text-align: center !important;
    padding: 2px !important;
    font-family: inherit !important;
    font-size: inherit !important;
    color: inherit !important;
    line-height: 1.1em !important;
    overflow: hidden !important;
}


/* コース一覧内のコースアイテムは従来通り */
.course-item {
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    cursor: grab;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    width: auto;
    min-height: 1.2em;
    font-size: inherit;
    padding: 0.1em 0.3em;
    margin: 0;
    border-radius: 2px;
}

/* コース一覧内のコースアイテムのみ固定幅を適用 */
#course-list .course-item {
    width: 120px !important; /* 120px固定幅 */
    min-width: 120px !important;
    max-width: 120px !important;
    padding: 0.75rem !important; /* パディングを調整 */
    font-size: 14px !important;
    min-height: 2.5rem !important;
    text-align: center !important;
    box-sizing: border-box !important;
}

/* コースアイテムのグロー効果 */
.course-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent
    );
    transition: left 0.6s ease;
}

.course-item:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.15),
        0 0 20px rgba(59, 130, 246, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.course-item:hover::before {
    left: 100%;
}

.course-item:active {
    cursor: grabbing;
    transform: translateY(0) scale(1.05);
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.2),
        0 0 30px rgba(59, 130, 246, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    animation: pulseGlow 0.3s ease-out;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2), 0 0 30px rgba(59, 130, 246, 0.5); }
    50% { box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3), 0 0 50px rgba(59, 130, 246, 0.8); }
    100% { box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2), 0 0 30px rgba(59, 130, 246, 0.5); }
}

.dragging {
    opacity: 0.5;
}

.drag-over {
    background-color: #e0f2fe !important; /* light-blue-100 */
    border: 2px dashed #38bdf8; /* light-blue-400 */
}

/* ==== MODERN FUTURISTIC UI STYLES ==== */

/* モダンなトグルスイッチ風チェックボックス */
input.custom-checkbox[type="checkbox"] {
    position: relative;
    width: 48px !important;
    height: 24px !important;
    background: linear-gradient(135deg, #1e293b, #334155) !important;
    border: 2px solid #475569 !important;
    border-radius: 50px !important;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 0 0 rgba(59, 130, 246, 0);
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

input.custom-checkbox[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    border-radius: 50%;
    transition: transform 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 0 0 0 rgba(59, 130, 246, 0);
}

input.custom-checkbox[type="checkbox"]:hover {
    border-color: #3b82f6 !important;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(59, 130, 246, 0.3);
    transform: scale(1.02);
    transition: all 0.3s ease;
}

input.custom-checkbox[type="checkbox"]:checked {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    border-color: #2563eb !important;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        0 0 25px rgba(59, 130, 246, 0.6);
    transition: all 0.4s ease;
}

input.custom-checkbox[type="checkbox"]:checked::before {
    transform: translateX(22px);
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(255, 255, 255, 0.8);
}

.custom-checkbox:checked::after {
    display: none; /* チェックマークは表示しない */
}

/* アスペクト比スイッチ */
input.aspect-switch[type="checkbox"] {
    position: relative;
    width: 56px !important;
    height: 28px !important;
    background: linear-gradient(135deg, #1e293b, #334155) !important;
    border: 2px solid #475569 !important;
    border-radius: 50px !important;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 0 0 rgba(59, 130, 246, 0);
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

input.aspect-switch[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    border-radius: 50%;
    transition: transform 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 0 0 0 rgba(59, 130, 246, 0);
}

input.aspect-switch[type="checkbox"]:hover {
    border-color: #3b82f6 !important;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(59, 130, 246, 0.3);
    transform: scale(1.02);
    transition: all 0.3s ease;
}

input.aspect-switch[type="checkbox"]:checked {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    border-color: #2563eb !important;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        0 0 25px rgba(59, 130, 246, 0.6);
    transition: all 0.4s ease;
}

input.aspect-switch[type="checkbox"]:checked::before {
    transform: translateX(26px);
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(255, 255, 255, 0.8);
}

/* カレンダーラッパーの基本設定 - 固定サイズ対応 */
#calendar-main-wrapper {
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* メインレイアウトにスクロール対応 */
body {
    font-family: 'Noto Sans JP', 'Inter', sans-serif;
    background: linear-gradient(180deg, 
        #ffffff 0%, 
        #e6efff 25%, 
        #acbacd 50%, 
        #b3c1d8 75%, 
        #7c869f 100%
    );
    background-attachment: fixed; /* 背景を固定してスクロールしても維持 */
    background-repeat: no-repeat;
    background-size: 100% 100vh; /* ビューポート全体をカバー */
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow-x: auto; /* 横スクロール許可 */
    overflow-y: auto; /* 縦スクロール許可 */
}

/* HTMLとbodyの基本設定を強化 */
html {
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: 100% 100vh;
    min-height: 100vh;
    width: 100%;
}

/* 週の交互背景色設定 - シンプルバージョン */
/* 奇数週（1,3,5週目）はwhite、偶数週（2,4週目）はbg-gray-50のまま */

/* ドラッグオーバー時の背景対応 */
.calendar-cell.bg-white.drag-over {
    background-color: #e0f2fe !important; /* 白背景でのドラッグ表示 */
    border: 2px dashed #38bdf8 !important;
}

.calendar-cell.bg-gray-100.drag-over {
    background-color: #e0f2fe !important; /* グレー背景でのドラッグ表示 */
    border: 2px dashed #38bdf8 !important;
}

/* カレンダーグリッド全体 - 背景ストライプは無効化（JavaScriptで個別セル背景制御） */
.calendar-grid {
    position: relative;
}

/* 大きなコンテンツでも背景が見えるように追加の背景設定 */
.mx-auto {
    background: transparent !important;
}

/* 固定サイズカレンダーでもスムーズな表示 */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        #ffffff 0%, 
        #e6efff 25%, 
        #acbacd 50%, 
        #b3c1d8 75%, 
        #7c869f 100%
    );
    z-index: -2;
    pointer-events: none;
}

/* 大きなカレンダーが表示される場合のレイアウト調整 */
.flex.flex-col.md\\:flex-row {
    overflow-x: auto !important;
}

/* コース一覧を水平配置用にスタイリング（フローティング対応） */
#course-list-wrapper {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.5) 0%, 
        rgba(248, 250, 252, 0.5) 100%
    );
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s ease-in-out; /* スムーズなアニメーション */
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    margin-bottom: 24px;
    width: fit-content !important; /* コンテンツサイズに合わせる */
    max-width: none !important;
    box-sizing: border-box !important;
    margin-left: auto !important; /* 中央寄せ */
    margin-right: auto !important;
    flex-shrink: 0;
    flex-grow: 0;
    
    /* スティッキー設定 - 画面下部に固定 */
    position: sticky !important;
    bottom: 16px !important; /* 画面下部から16px上に固定 */
    z-index: 100 !important; /* 他の要素より前面に表示 */
}

/* レスポンシブ対応 */
@media (max-width: 1024px) {
    #course-list-wrapper {
        padding: 12px;
    }
    
    #course-list .course-item {
        width: 100px;
        padding: 0.4rem;
        font-size: 0.8rem;
        min-height: 2rem;
    }
}

@media (max-width: 768px) {
    #course-list {
        justify-content: center; /* 小画面では中央寄せ */
    }
    
    #course-list .course-item {
        width: 90px;
        padding: 0.3rem;
        font-size: 0.75rem;
        min-height: 1.8rem;
    }
}

/* 最高優先度でコース一覧を水平配置に強制 - セレクタ詳細度を最大化 */
html body div#course-list,
html body .course-list-wrapper div#course-list,
div#course-list[style],
#course-list,
.course-list {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
}

/* Tailwindクラスの完全上書き - すべての可能性をカバー */
div#course-list.flex,
div#course-list.flex-row,
div#course-list.flex-col,
#course-list.flex,
#course-list.flex-row,
#course-list.flex-col,
.flex-col#course-list,
.flex-row#course-list {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
}

/* Tailwind CDNによる後読み込みクラスも強制上書き */
[class*="flex-col"]#course-list,
[class*="flex"]#course-list {
    flex-direction: row !important;
}

/* 追加の保険として、コース一覧ラッパー内のすべてのflexコンテナを対象 */
#course-list-wrapper * {
    box-sizing: border-box !important;
}

#course-list-wrapper div[id="course-list"] {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
}