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

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 10px;
}

.user-info {
    margin-top: 1em;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
.user-info span{
    color: #ccc;
}

.logout-btn {
    padding: 5px;
    /* background-color: #ff4444; */
    background-color: #999;
    font-size: 8px;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    white-space: nowrap;
}

.task-lists {
    margin-bottom: 10px;
}

.list-selector {
    display: flex;
    gap: 10px;
    align-items: center;
}
.sort-controls{
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 1em;
}
#listSelector,#sortOrder {
    appearance: none;
    color: #333;
    background: #fff;
    border: 1px solid #ddd;
    height: 40px;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 1em;
    /* min-width: 200px; */
}
#listSelector{
    flex: 1;
}
#sortOrder{
    
}

.add-task {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#newTask {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0px 10px;
    background-color: #4CAF50;
    color: white; 
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

button:hover {
    background-color: #45a049;
}

.task-container {
    background-color: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h2 {
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h2 button {
    font-size: 10px;
    padding: 4px 8px;
}

ul {
    list-style: none;
}

/* タスクアイテムのスタイル */
.task-item {
    display: flex;
    flex-direction: column;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    touch-action: none; /* モバイルでのスクロールとドラッグの競合を防ぐ */
}

.task-header {
    display: flex;
    align-items: center;
    padding: 10px;
    gap: 10px;
    width: 100%;
    cursor: move; /* ドラッグ可能な領域であることを示す */
    user-select: none; /* テキスト選択を防ぐ */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.task-checkbox {
    margin: 0;
    flex-shrink: 0;
}

.task-title {
    flex-grow: 1;
    margin-right: 10px;
    word-break: break-word;
    cursor: pointer;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    color: #666;
    font-size: 0.9em;
}

.task-icons {
    display: flex;
    gap: 8px;
}

.task-icons i {
    font-size: 14px;
}

.task-due-date {
    white-space: nowrap;
}
.completed-header{
    margin-top: 1em;
}
.task-due-date.urgent {
    color: #dc3545;
    font-weight: 500;
}

/* 完了タスクのスタイル */
.task-item.completed .task-title {
    text-decoration: line-through;
    color: #999;
}

.task-item.completed .task-meta {
    opacity: 0.7;
}

/* タスクリストのスタイル */
#taskList, #completedList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#completedList {
    margin-top: 5px;
    opacity: 0.8;
}

/* ドラッグ&ドロップ時のスタイル */
.ui-sortable-helper {
    background-color: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    opacity: 0.9;
}

.ui-sortable-placeholder {
    background-color: #f1f1f1;
    border: 2px dashed #ccc;
    visibility: visible !important;
    height: 50px;
    margin-bottom: 5px;
}

/* モバイル向けの調整 */
@media screen and (max-width: 768px) {
    .task-header {
        padding: 12px; /* タッチターゲットを大きく */
    }

    .task-checkbox {
        width: 20px;
        height: 20px;
    }

    .task-title {
        font-size: 16px; /* 読みやすいサイズに */
    }

    /* ドラッグ中は背景色を変更してフィードバックを強化 */
    .ui-sortable-helper {
        background-color: #e9ecef;
        transform: scale(1.02);
        transition: transform 0.1s ease;
    }
}

/* タスク詳細のスタイル */
.task-details {
    display: none;
    padding: 10px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    max-height: calc(100vh - 250px); /* 画面の高さから他の要素の高さを引いた値 */
    overflow-y: auto; /* 縦方向のスクロールを有効化 */
    -webkit-overflow-scrolling: touch; /* iOSでのスムーズスクロール */
}

/* スマートフォン向けの調整 */
@media (max-width: 768px) {
    .task-details {
        max-height: calc(100vh - 200px); /* モバイル向けに高さを調整 */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* スクロールバーのカスタマイズ */
    .task-details::-webkit-scrollbar {
        width: 4px;
    }

    .task-details::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 2px;
    }

    .task-details::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 2px;
    }

    .task-details::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
}

/* タスク詳細の内部要素のスタイル */
.task-details .memo {
    margin-bottom: 15px;
    word-break: break-word; /* 長い単語の折り返し */
}

.task-details .image-container {
    margin-bottom: 15px;
    text-align: center;
}

.task-details img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* モーダルスタイル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: hidden;
    /* flexboxを使用して中央配置 */
    display: none; /* 初期状態は非表示 */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 8px;
    position: relative;
}
.modal-content-inner{
    overflow-y: auto;
    max-height: calc(100vh - 60px); /* 上下30pxずつの余白 */
    -webkit-overflow-scrolling: touch;

}
.sort-controls{
    display: flex;
    gap: 20px; /* 間隔を調整 */
    align-items: center;
    margin-bottom: 1em;
}


/* スマートフォン向けの調整 */
@media (max-width: 768px) {
    .modal-content {
        width: 90%;
        padding: 15px;
        height: auto;
    }
    .modal-content-inner{
        
        max-height: 90vh;
    }
    /* スクロールバーのカスタマイズ */
    .modal-content::-webkit-scrollbar {
        width: 4px;
    }

    .modal-content::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 2px;
    }

    .modal-content::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 2px;
    }

    .modal-content::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
}

/* タスク詳細モーダルの外側クリック対応 */
.modal {
    background-color: rgba(0, 0, 0, 0.5);
}


/* Add responsive styles */
@media screen and (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
    }
    .user-info span{
        color: #ccc;
    }

    .list-selector {
        width: 100%;
        flex-wrap: wrap;
    }

    #listSelector {
        flex-grow: 1;
        /* min-width: 200px; */
    }
}

/* 画像モーダル */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    cursor: pointer;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    margin: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* タスク詳細モーダルの外側クリック対応 */
.modal {
    background-color: rgba(0, 0, 0, 0.5);
}

/* Add responsive styles */
@media screen and (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
    }

    .list-selector {
        width: 100%;
        flex-wrap: wrap;
    }

    #listSelector {
        flex-grow: 1;
        /* min-width: 200px; */
    }
}

.task-created-at{
    color: #ccc;
    font-size: 0.8em;
    text-align: right;
}
.image-container {
    position: relative;
    margin-top: 10px;
}

.image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.delete-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: #ff4444;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
}

.delete-image:hover {
    background-color: #ff0000;
}

#currentImage img {
    max-width: 200px;
    margin-top: 10px;
}

/* 画像コンテナとプレビュー */
#currentImage {
    position: relative;
    display: inline-block;
    margin: 10px 0;
}

#currentImage img {
    max-width: 200px;
    border-radius: 4px;
}

.delete-image-button {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #333;
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.delete-image-button:hover {
    background: #999;
    transform: scale(1.1);
}

.delete-image-button:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .delete-image-button {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
}

/* モーダル内のフォーム要素のスタイル */
.modal-content .form-group {
    margin-bottom: 20px;
}

.modal-content .form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 0.95em;
}

.modal-content .form-group input[type="text"],
.modal-content .form-group textarea,
.modal-content .form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background-color: #f8f9fa;
    color: #333;
    font-size: 1em;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.modal-content .form-group input[type="text"]:focus,
.modal-content .form-group textarea:focus,
.modal-content .form-group select:focus {
    outline: none;
    border-color: #4CAF50;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.modal-content .form-group textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

.modal-content .form-group input[type="file"] {
    display: none;
}

.modal-content .form-group .file-upload-label {
    display: inline-block;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.modal-content .form-group .file-upload-label:hover {
    background-color: #45a049;
}

/* モーダル内のボタンスタイル */
.modal-content button[type="submit"] {
    background-color: #4CAF50;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
}

.modal-content button[type="submit"]:hover {
    background-color: #45a049;
    transform: translateY(-1px);
}

.modal-content button[type="submit"]:active {
    transform: translateY(0);
}

/* スマートフォン向けの調整 */
@media (max-width: 768px) {
    .modal-content .form-group input[type="text"],
    .modal-content .form-group textarea,
    .modal-content .form-group select {
        padding: 10px;
        font-size: 16px; /* iOSでズームを防ぐ */
    }

    .modal-content .form-group label {
        font-size: 0.9em;
    }

    .modal-content button[type="submit"] {
        padding: 12px 20px;
        font-size: 16px;
    }
}

/* 日付選択のカスタマイズ */
.modal-content .datepicker {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    cursor: pointer;
}

/* プレースホルダーのスタイル */
.modal-content .form-group input::placeholder,
.modal-content .form-group textarea::placeholder {
    color: #999;
    font-size: 0.9em;
}

/* 現在の画像表示エリア */
#currentImage {
    margin-top: 10px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
    text-align: center;
}

#currentImage img {
    max-width: 100%;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 閉じるボタンのスタイル */
.close {
    position: absolute;
    right: 15px;
    top: 15px;
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    z-index: 1;
}

.close:hover {
    background: #e9ecef;
    color: #333;
    transform: scale(1.1);
}

.close:active {
    transform: scale(0.95);
}

/* スマートフォン向けの調整 */
@media (max-width: 768px) {
    .close {
        width: 40px;
        height: 40px;
        font-size: 28px;
        right: 10px;
        top: 10px;
    }
}

/* 完了タスクセクション */
.completed-tasks-toggle {
    margin: 10px 0;
    text-align: center;
}

.toggle-button {
    border: none;
    cursor: pointer;
    
    display: inline-flex;
    align-items: center;
    transition: all 0.3s ease;
}
.toggle-button.active {
    background: #ccc;
}
.toggle-button:hover {

}

.toggle-button i {
    margin-right: 5px;
    transition: transform 0.3s ease;
}
#toggleCompletedTasks{
    height: 30px;
    font-size: 0.5em;
}
#clearCompleted{
    background: none;
    color: #666;
    font-size: 0.5em;
    height: auto;
    margin-top: 10px;

}
#completedTasksSection {
    margin-top: 10px;
}

.completed-list .task-item {
    opacity: 0.7;
}

.completed-list .task-title {
    text-decoration: line-through;
    color: #666;
}

/* スマートフォン向けの調整 */
@media (max-width: 768px) {
    .toggle-button {
        
        
    }
}

/* リスト削除ボタン */
.delete-list-button {
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    
}

.delete-list-button:hover {
    color: #333;
    transform: scale(1.1);
}

.delete-list-button:active {
    transform: scale(0.95);
}

/* リストコントロール */
.list-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.list-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

#addTask{
display: block;
}

/* メッセージ表示領域 */
#sortMessage {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 20px 30px;
    border-radius: 8px;
    font-size: 1.2em;
    opacity: 0; /* 初期状態は非表示 */
    visibility: hidden; /* 初期状態は非表示 */
    transition: opacity 0.5s, visibility 0.5s; /* フェードイン・アウトのアニメーション */
    z-index: 1001; /* モーダルより前面に表示 */
}

/* 表示状態 */
#sortMessage.show {
    opacity: 1; /* 表示 */
    visibility: visible; /* 表示 */
}

/* 画像プレビュー */
.image-preview {
    margin: 10px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 4px;
    display: block;
    margin-bottom: 8px;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background: #fff;
    border-radius: 4px;
    font-size: 0.9em;
}

.file-name {
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80%;
}

.clear-image {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.clear-image:hover {
    color: #333;
    transform: scale(1.1);
}

/* ファイル選択ボタンのカスタマイズ */
.form-group input[type="file"] {
    display: none;
}

.file-upload-label {
    display: inline-block;
    padding: 8px 16px;
    background: #f0f0f0;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.file-upload-label:hover {
    background: #e0e0e0;
}

.file-upload-label i {
    margin-right: 8px;
}


/* style.css */
/* ... 既存のスタイル ... */
.taskListContainer{
    position: relative;
}
.task-list-overlay {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    width: 87%;
    height: 100%;
    background-color: none; /* 透明にする */
    z-index: 10; /* タスクリストの上に重ねる */
    cursor: default; /* カーソルをデフォルトに戻す */
}

.task-container {
    position: relative; /* オーバーレイの基準位置にする */
    background-color: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}