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

/* CSS Variables for Microsoft-inspired colors */
:root {
    --primary-color: #0078d4;
    --primary-hover: #106ebe;
    --primary-active: #005a9e;
    --success-color: #107c10;
    --danger-color: #d13438;
    --danger-hover: #a52424;
    --bg-light: #f3f2f1;
    --bg-white: #ffffff;
    --text-primary: #323130;
    --text-secondary: #605e5c;
    --border-color: #edebe9;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Base Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--bg-white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-active) 100%);
    color: white;
    padding: 32px 24px;
    text-align: center;
}

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

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

/* Todo Input Section */
.todo-input-section {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

#todo-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    transition: border-color 0.2s;
}

#todo-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

#add-btn {
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

#add-btn:hover {
    background-color: var(--primary-hover);
}

#add-btn:active {
    background-color: var(--primary-active);
    transform: scale(0.98);
}

#add-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.character-count {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
}

/* Todo List Section */
.todo-list-section {
    padding: 24px;
}

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

.list-header h2 {
    font-size: 20px;
    font-weight: 600;
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    gap: 4px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.filter-btn {
    padding: 6px 16px;
    background-color: var(--bg-white);
    border: none;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-right: 1px solid var(--border-color);
}

.filter-btn:last-child {
    border-right: none;
}

.filter-btn:hover {
    background-color: var(--bg-light);
}

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

.filter-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

/* Todo List */
#todo-list {
    list-style: none;
    min-height: 100px;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    margin-bottom: 8px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: box-shadow 0.2s, transform 0.1s;
}

.todo-item:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

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

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

.todo-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--success-color);
}

.todo-item input[type="checkbox"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.todo-item label {
    flex: 1;
    font-size: 15px;
    cursor: pointer;
    word-break: break-word;
}

.delete-btn {
    padding: 6px 14px;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.delete-btn:hover {
    background-color: var(--danger-hover);
}

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

.delete-btn:focus {
    outline: 2px solid var(--danger-color);
    outline-offset: 2px;
}

.empty-message {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
    font-style: italic;
}

/* List Footer */
.list-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

#task-count {
    font-size: 14px;
    color: var(--text-secondary);
}

#clear-completed-btn {
    padding: 8px 16px;
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

#clear-completed-btn:hover {
    background-color: var(--bg-light);
    color: var(--text-primary);
}

#clear-completed-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    header {
        padding: 24px 16px;
    }

    header h1 {
        font-size: 22px;
    }

    .todo-input-section,
    .todo-list-section {
        padding: 16px;
    }

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

    #add-btn {
        width: 100%;
    }

    .list-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-buttons {
        width: 100%;
    }

    .filter-btn {
        flex: 1;
        text-align: center;
    }

    .list-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    #clear-completed-btn {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    body {
        background-color: white;
    }

    .container {
        box-shadow: none;
    }

    header {
        background: var(--primary-color);
        print-color-adjust: exact;
    }

    .input-group,
    .filter-buttons,
    .delete-btn,
    #clear-completed-btn {
        display: none;
    }

    .todo-item {
        break-inside: avoid;
    }
}
