/* Created: 2026-01-04 */
/* Daily Todo Manager - 스타일시트 */

/* ===== CSS 변수 (테마) ===== */
:root {
    --bg-color: #f5f5f5;
    --container-bg: #fff;
    --text-color: #333;
    --text-secondary: #666;
    --text-muted: #888;
    --border-color: #ddd;
    --item-bg: #f9f9f9;
    --item-hover: #f0f0f0;
    --dashboard-bg: #f8f9fa;
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --danger-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* 다크 모드 */
body.dark {
    --bg-color: #1a1a2e;
    --container-bg: #16213e;
    --text-color: #eee;
    --text-secondary: #aaa;
    --text-muted: #777;
    --border-color: #3a3a5a;
    --item-bg: #1f2940;
    --item-hover: #2a3a50;
    --dashboard-bg: #1f2940;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* ===== 리셋 및 기본 스타일 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    padding: 20px;
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
}

/* ===== 접근성: 스킵 링크 ===== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: #fff;
    padding: 8px 16px;
    z-index: 1000;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    top: 0;
}

/* 스크린 리더 전용 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== 컨테이너 ===== */
.container {
    max-width: 600px;
    margin: 0 auto;
    background-color: var(--container-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: background-color 0.3s;
}

/* ===== 헤더 ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

h1 {
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: var(--item-bg);
    transform: scale(1.05);
}

.icon-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
}

/* ===== 격언 섹션 ===== */
.quote-section {
    background: linear-gradient(135deg, var(--primary-color), #6f42c1);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    text-align: center;
}

.quote-text {
    color: #fff;
    font-size: 14px;
    font-style: italic;
    opacity: 0.95;
}

/* ===== 입력 섹션 ===== */
.input-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

#todo-input {
    flex: 1;
    min-width: 180px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background-color: var(--container-bg);
    color: var(--text-color);
    transition: all 0.3s;
}

#todo-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#todo-input::placeholder {
    color: var(--text-muted);
}

.input-section button[type="submit"] {
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.input-section button[type="submit"]:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.input-section button[type="submit"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
}

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

#category-select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background-color: var(--container-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s;
}

#category-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ===== 대시보드 ===== */
.dashboard {
    background-color: var(--dashboard-bg);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    transition: background-color 0.3s;
}

.progress-section {
    margin-bottom: 10px;
}

.progress-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: center;
    font-weight: 500;
}

.progress-bar {
    height: 10px;
    background-color: var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #6f42c1);
    border-radius: 5px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-fill.complete {
    background: linear-gradient(90deg, var(--success-color), #20c997);
}

.motivation-message {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    min-height: 20px;
}

.category-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.stat-item {
    font-size: 12px;
    color: var(--text-secondary);
    background-color: var(--container-bg);
    padding: 4px 12px;
    border-radius: 15px;
    border: 1px solid var(--border-color);
}

/* ===== 툴바 ===== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.sort-section {
    flex: 1;
    min-width: 120px;
}

#sort-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    background-color: var(--container-bg);
    color: var(--text-color);
    cursor: pointer;
}

#sort-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.data-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--container-bg);
    color: var(--text-color);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.action-btn:hover {
    border-color: var(--primary-color);
    background-color: var(--item-bg);
}

.action-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
}

.import-label {
    cursor: pointer;
}

/* ===== 필터 섹션 ===== */
.filter-section {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    background-color: transparent;
    border: 2px solid var(--primary-color);
    border-radius: 20px;
    color: var(--primary-color);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: #fff;
}

.filter-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
}

/* ===== 할 일 목록 ===== */
#todo-list {
    list-style: none;
    min-height: 100px;
}

.todo-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background-color: var(--item-bg);
    border-radius: 8px;
    margin-bottom: 10px;
    animation: slideIn 0.3s ease;
    transition: all 0.3s ease;
    cursor: grab;
    border: 2px solid transparent;
}

.todo-item:hover {
    background-color: var(--item-hover);
}

.todo-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
    box-shadow: var(--shadow-lg);
}

.todo-item.drag-over {
    border-color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.05);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.todo-item.removing {
    opacity: 0;
    transform: translateX(100px);
}

.todo-item.completed .todo-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.todo-item input[type="checkbox"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--primary-color);
}

.todo-item .drag-handle {
    cursor: grab;
    padding: 0 8px;
    color: var(--text-muted);
    font-size: 14px;
    user-select: none;
}

.todo-item .drag-handle:active {
    cursor: grabbing;
}

.todo-item .todo-title {
    flex: 1;
    font-size: 15px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    word-break: break-word;
    transition: background-color 0.2s;
}

.todo-item .todo-title:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

.todo-item .edit-input {
    flex: 1;
    padding: 6px 10px;
    font-size: 15px;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    background-color: var(--container-bg);
    color: var(--text-color);
}

.todo-item .edit-input:focus {
    outline: none;
}

.todo-item .category-label {
    padding: 4px 10px;
    background-color: var(--border-color);
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-right: 10px;
    flex-shrink: 0;
}

.todo-item .delete-btn {
    padding: 6px 12px;
    background-color: var(--danger-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 10px;
    font-size: 12px;
    transition: all 0.2s;
}

.todo-item .delete-btn:hover {
    background-color: #c82333;
    transform: scale(1.05);
}

.todo-item .delete-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.3);
}

.todo-item input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
}

/* ===== 빈 상태 메시지 ===== */
.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 50px 20px;
}

.empty-message .empty-icon {
    font-size: 56px;
    margin-bottom: 12px;
    display: block;
}

.empty-message .empty-text {
    font-size: 16px;
    color: var(--text-secondary);
}

/* ===== Undo 토스트 ===== */
.undo-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

body.dark .undo-toast {
    background-color: #444;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.undo-toast[hidden] {
    display: none;
}

.undo-message {
    font-size: 14px;
}

.undo-btn {
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s;
}

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

.undo-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary-color);
}

.undo-close {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    line-height: 1;
}

.undo-close:hover {
    color: #fff;
}

/* ===== 중복 경고 ===== */
.duplicate-warning {
    color: var(--warning-color);
    font-size: 12px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== 반응형 ===== */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px 16px;
        border-radius: 10px;
    }

    h1 {
        font-size: 1.25rem;
    }

    .input-section {
        flex-direction: column;
    }

    #todo-input,
    #category-select,
    .input-section button[type="submit"] {
        width: 100%;
        min-width: unset;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .sort-section {
        width: 100%;
    }

    .data-actions {
        justify-content: center;
    }

    .filter-section {
        justify-content: center;
    }

    .filter-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .todo-item {
        padding: 12px;
        flex-wrap: wrap;
    }

    .todo-item .drag-handle {
        display: none;
    }

    .todo-item .category-label {
        order: 10;
        margin-top: 8px;
        margin-right: 0;
        width: 100%;
        text-align: center;
    }

    .undo-toast {
        left: 10px;
        right: 10px;
        transform: none;
        bottom: 20px;
    }
}

/* ===== 포커스 가시성 개선 ===== */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== 애니메이션 감소 설정 존중 ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
