/* リセットと基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ヘッダー */
header {
    text-align: center;
    padding: 1rem; /* 2remから1remに変更 */
    background-color: #2a2a2a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

header h1 {
    font-size: 1.5rem; /* 2remから1.5remに変更 */
}

/* メインエリア */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* 3カラムレイアウトコンテナ（空白:タイマー:タスク = 1:3:1） */
.layout-container {
    display: grid;
    grid-template-columns: 1fr 3fr 1fr;
    gap: 2rem;
    align-items: start;
}

/* 左側の空白スペース */
.spacer-left {
    /* 空のスペース */
}

/* タイマーセクション（中央カラム） */
.timer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 2rem;
}

/* モード切り替えタブ */
.mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 3rem;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    border: 2px solid #444;
    background-color: #2a2a2a;
    color: #999;
    cursor: pointer;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.tab-button:hover {
    background-color: #333;
    border-color: #666;
}

.tab-button.active {
    background-color: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

/* タイマー表示 */
.timer-display {
    margin-bottom: 3rem;
}

#time {
    font-size: 6rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    color: #e74c3c;
}

/* コントロールボタン */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
}

.controls button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#start-btn {
    background-color: #27ae60;
    color: white;
}

#start-btn:hover:not(:disabled) {
    background-color: #229954;
}

#pause-btn {
    background-color: #f39c12;
    color: white;
}

#pause-btn:hover:not(:disabled) {
    background-color: #e67e22;
}

#reset-btn {
    background-color: #95a5a6;
    color: white;
}

#reset-btn:hover:not(:disabled) {
    background-color: #7f8c8d;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 設定エリア */
.settings {
    margin-bottom: 3rem;
    width: 100%;
    max-width: 500px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center; /* 中央揃え */
}

.setting-item label {
    color: #999;
    font-size: 0.85rem;
    text-align: center; /* ラベルも中央揃え */
}

.setting-item input {
    padding: 0.5rem;
    background-color: #2a2a2a;
    border: 2px solid #444;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 1rem;
    text-align: center;
    width: 100%; /* 幅を100%に */
}

.setting-item input:focus {
    outline: none;
    border-color: #e74c3c;
}

.setting-item input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 設定リセットボタン */
.reset-settings-btn {
    width: 100%;
    padding: 0.5rem; /* 0.75remから0.5remに変更 */
    background-color: #555;
    color: #e0e0e0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem; /* 0.9remから0.85remに変更 */
    transition: background-color 0.2s ease;
}

.reset-settings-btn:hover {
    background-color: #666;
}

.reset-settings-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 統計表示 */
.stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background-color: #2a2a2a;
    border-radius: 8px;
    min-width: 150px;
}

.stat-label {
    color: #999;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e74c3c;
}

/* ============================================
   ToDoリストセクション（右カラム）
   ============================================ */

.todo-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

/* タイトルとハンバーガーメニュー */
.todo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    position: relative;
}

.todo-title {
    font-size: 1.1rem;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.todo-count-badge {
    font-size: 0.95rem;
    font-weight: bold;
    color: #888;
}

/* 残りが0個の時も同じ色 */
.todo-count-badge .count-number {
    color: inherit; /* 親要素の色を継承（赤にしない） */
}

/* 残りが1個以上の時のみ赤 */
.todo-count-badge.has-tasks .count-number {
    color: #e74c3c;
}

/* ハンバーガーメニューコンテナ */
.todo-menu-container {
    position: relative;
}

.todo-menu-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: opacity 0.2s ease;
}

.todo-menu-btn:hover {
    opacity: 0.7;
}

.hamburger-icon {
    width: 20px;
    height: 2px;
    background-color: #888;
    border-radius: 2px;
    transition: background-color 0.2s ease;
}

.todo-menu-btn:hover .hamburger-icon {
    background-color: #e0e0e0;
}

/* ドロップダウンメニュー */
.todo-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    min-width: 200px;
    z-index: 1000;
    display: none;
    overflow: hidden;
    margin-top: 0.5rem;
}

.todo-dropdown.active {
    display: block;
}

.dropdown-item {
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: #e0e0e0;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #333;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #333;
}

/* タスク入力フォーム */
.todo-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.todo-input {
    flex: 1;
    padding: 0.6rem 0.8rem;
    background-color: transparent;
    border: none;
    border-bottom: 2px solid #444;
    border-radius: 0;
    color: #e0e0e0;
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
}

.todo-input:focus {
    outline: none;
    border-bottom-color: #e74c3c;
}

.todo-input::placeholder {
    color: #666;
    font-size: 0.9rem;
}

.todo-add-btn {
    padding: 0.6rem 1rem;
    background-color: transparent;
    color: #888;
    border: 1px solid #555;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

/* 入力中は赤く */
.todo-input:focus + .todo-add-btn,
.todo-add-btn.active {
    background-color: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

.todo-add-btn:hover {
    background-color: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

/* タスク一覧 */
.todo-list {
    list-style: none;
    margin-bottom: 1rem;
    flex: 1;
    overflow-y: auto;
    max-height: 500px;
    padding-right: 0.5rem;
}

/* カスタムスクロールバー */
.todo-list::-webkit-scrollbar {
    width: 6px;
}

.todo-list::-webkit-scrollbar-track {
    background: transparent;
}

.todo-list::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.todo-list::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* 個別タスクアイテム */
.todo-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.5rem;
    background-color: transparent;
    border: none;
    border-radius: 0;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
    position: relative;
    cursor: move;
}

.todo-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.todo-item.completed {
    opacity: 0.5;
}

.todo-item.dragging {
    opacity: 0.5;
}

.todo-item.hidden {
    display: none;
}

/* チェックボックス */
.todo-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #27ae60;
    flex-shrink: 0;
}

/* タスクテキスト */
.todo-text {
    flex: 1;
    color: #e0e0e0;
    font-size: 0.95rem;
    word-break: break-word;
    line-height: 1.4;
    min-width: 0;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
    color: #666;
}

/* アクションボタンコンテナ */
.todo-actions {
    display: flex;
    gap: 0.35rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.todo-item:hover .todo-actions {
    opacity: 1;
}

/* 編集ボタン */
.todo-edit-btn {
    padding: 0.4rem;
    background-color: transparent;
    color: #3498db;
    border: 1px solid #3498db;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.todo-edit-btn:hover {
    background-color: #3498db;
    color: white;
}

/* 削除ボタン */
.todo-delete-btn {
    padding: 0.4rem;
    background-color: transparent;
    color: #e74c3c;
    border: 1px solid #e74c3c;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.todo-delete-btn:hover {
    background-color: #e74c3c;
    color: white;
}

/* ToDoがない場合 */
.todo-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: #555;
    font-style: italic;
    font-size: 0.9rem;
}

/* フッター */
footer {
    text-align: center;
    padding: 1.5rem;
    background-color: #2a2a2a;
    color: #666;
    font-size: 0.9rem;
}

/* ============================================
   レスポンシブ対応
   ============================================ */

/* タブレット（1024px以下） */
@media (max-width: 1024px) {
    .layout-container {
        grid-template-columns: 0.5fr 3fr 1fr;
        gap: 1.5rem;
    }
}

/* スマートフォン（768px以下） */
@media (max-width: 768px) {
    .layout-container {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
    
    .spacer-left {
        display: none;
    }
    
    .timer-section {
        position: static;
    }
    
    .todo-section {
        max-width: 100%;
        order: 2;
    }
}

/* スマートフォン（600px以下） */
@media (max-width: 600px) {
    main {
        padding: 1rem;
    }
    
    .layout-container {
        gap: 2rem;
    }
    
    #time {
        font-size: 4rem;
    }
    
    .mode-tabs {
        flex-direction: column;
        width: 100%;
    }
    
    .tab-button {
        width: 100%;
    }
    
    .controls {
        flex-direction: column;
        width: 100%;
    }
    
    .controls button {
        width: 100%;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .stats {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .todo-form {
        flex-direction: column;
    }
    
    .todo-add-btn {
        width: 100%;
    }
    
    /* スマホでは常にアクションボタン表示 */
    .todo-actions {
        opacity: 1;
    }
}

/* ============================================
   通知設定エリア
   ============================================ */

.notification-settings {
    margin-bottom: 2rem;
    width: 100%;
    max-width: 500px;
}

.notification-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #2a2a2a;
    padding: 1.5rem;
    border-radius: 8px;
}

.notification-item {
    display: flex;
    align-items: center;
}

.notification-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 0.95rem;
    user-select: none;
}

.notification-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #e74c3c;
}

.test-notification-btn {
    padding: 0.75rem 1rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
    margin-top: 0.5rem;
}

.test-notification-btn:hover {
    background-color: #2980b9;
}

.test-notification-btn:active {
    transform: scale(0.98);
}

/* ユーザーフィードバックメッセージ */
.notification-message {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.9rem;
    transition: opacity 0.3s ease;
}

.notification-message.success {
    background-color: rgba(39, 174, 96, 0.2);
    border: 1px solid #27ae60;
    color: #2ecc71;
}

.notification-message.error {
    background-color: rgba(231, 76, 60, 0.2);
    border: 1px solid #e74c3c;
    color: #e74c3c;
}

.notification-message.info {
    background-color: rgba(52, 152, 219, 0.2);
    border: 1px solid #3498db;
    color: #3498db;
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
    .notification-controls {
        padding: 1rem;
    }
}

/* 音量コントロール */
.volume-control {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.5rem;
}

.volume-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: default;
    margin-bottom: 0.25rem;
}

.volume-icon {
    font-size: 1.1rem;
}

.volume-slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* 音量スライダーのスタイル */
.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    background: #444;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.volume-slider:hover:not(:disabled) {
    background: #555;
}

.volume-slider:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* スライダーのつまみ（WebKit系ブラウザ） */
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #e74c3c;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.volume-slider:disabled::-webkit-slider-thumb {
    background: #666;
    cursor: not-allowed;
}

/* スライダーのつまみ（Firefox） */
.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #e74c3c;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.volume-slider:disabled::-moz-range-thumb {
    background: #666;
    cursor: not-allowed;
}

/* Firefoxの点線を消す */
.volume-slider::-moz-focus-outer {
    border: 0;
}

/* 音量の数値表示 */
.volume-value {
    min-width: 45px;
    text-align: right;
    color: #e74c3c;
    font-weight: bold;
    font-size: 0.9rem;
}

/* 通知設定エリア */
.notification-settings {
    margin-top: 2rem;
    width: 100%;
    max-width: 500px;
}

/* 通知設定のタイトル */
.notification-title {
    color: #999;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-align: center;
}
