:root {
    --primary-color: #7B2CBF;
    --primary-light: #9D4EDD;
    --light-color: #F8F9FA;
    --dark-color: #343A40;
    --text-color: #495057;
    --status-completed-bg: #e9f7ec;
    --status-completed-text: #28a745;
    --status-overdue-bg: #fdecea;
    --status-overdue-text: #dc3545;
    --status-pending-bg: #fdecea;
    --status-pending-text: #dc3545;
    --danger-color: #dc3545;
    --border-radius: 8px;
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: #E0AAFF;
    background-image: linear-gradient(135deg, #E0AAFF 0%, #C77DFF 100%);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
}

.container { max-width: 900px; margin: 20px auto; background-color: var(--light-color); padding: 30px; border-radius: var(--border-radius); box-shadow: var(--box-shadow); }
header { text-align: center; margin-bottom: 30px; color: var(--primary-color); }
header h1 { font-weight: 700; }
header .icon { font-size: 1.5em; vertical-align: middle; }

.form-card { background-color: #fff; padding: 25px; border-radius: var(--border-radius); margin-bottom: 25px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); }
#todo-form h2 { margin-bottom: 20px; font-weight: 600; color: var(--dark-color); }
#todo-form { display: flex; flex-wrap: wrap; gap: 20px; }
.form-group { flex: 1 1 calc(50% - 20px); display: flex; flex-direction: column; }
.form-group.full-width { flex-basis: 100%; }
label { margin-bottom: 5px; font-weight: 500; color: #555; }
input[type="text"], input[type="date"], textarea { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: var(--border-radius); font-family: 'Poppins', sans-serif; font-size: 1rem; transition: border-color 0.3s; }
input[type="text"]:focus, input[type="date"]:focus, textarea:focus { outline: none; border-color: var(--primary-color); }
textarea { resize: vertical; min-height: 80px; }
.btn-add { width: 100%; margin-top: 10px; padding: 15px; background-color: var(--primary-color); color: #fff; border: none; border-radius: var(--border-radius); font-size: 1.1rem; font-weight: 600; cursor: pointer; transition: background-color 0.3s; }
.btn-add:hover { background-color: var(--primary-light); }

.controls-card { display: flex; justify-content: space-between; align-items: center; background-color: #fff; padding: 15px 25px; border-radius: var(--border-radius); margin-bottom: 25px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); flex-wrap: wrap; gap: 15px; }
#search-input {
    width: 320px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
}
.btn-danger { background-color: var(--danger-color); color: white; padding: 10px 20px; border: none; border-radius: var(--border-radius); cursor: pointer; font-weight: 500; transition: background-color 0.3s; }
.btn-danger:hover { background-color: #c82333; }

.table-container { max-height: 450px; overflow-y: auto; display: block; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
thead { position: sticky; top: 0; z-index: 1; }
th, td { padding: 15px; text-align: left; border-bottom: 1px solid #ddd; vertical-align: middle; }
thead th { background-color: #f2f2f2; font-weight: 600; color: var(--dark-color); }
tbody tr:hover { background-color: #f9f9f9; }
.task-details h4 { margin: 0; font-weight: 600; }
.task-details p { margin: 4px 0 0; font-size: 0.9em; color: #777; }

.status-badge { padding: 5px 12px; border-radius: 15px; font-weight: 500; font-size: 0.85em; text-align: center; }
.status-completed { background-color: var(--status-completed-bg); color: var(--status-completed-text); }
.status-overdue { background-color: var(--status-overdue-bg); color: var(--status-overdue-text); }
.status-pending { background-color: var(--status-pending-bg); color: var(--status-pending-text); }

td.actions { display: flex; align-items: center; gap: 8px; }
.actions input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.actions button { border: none; background: none; cursor: pointer; font-size: 1.3rem; transition: transform 0.2s; padding: 5px; }
.actions button:hover { transform: scale(1.2); }
.btn-delete { color: var(--danger-color); }

.notification { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 15px 30px; border-radius: var(--border-radius); color: #fff; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; z-index: 1000; }
.notification.show { opacity: 1; visibility: visible; }
.notification.success { background-color: #28a745; }
.notification.error { background-color: var(--danger-color); }
.notification.info { background-color: #17a2b8; }

#search-input {
    width: 320px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
}

#status-filter {
    padding: 12px 40px 12px 14px;
    border-radius: var(--border-radius);
    border: 1px solid #ddd;
    background: #fff;
    color: var(--dark-color);
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    min-width: 160px;
    cursor: pointer;
    appearance: none;
    position: relative;
}

#status-filter {
    background-image: url("data:image/svg+xml;utf8,<svg fill='gray' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 28px 28px;
}

@media (pointer: coarse) {
    #status-filter {
        min-height: 48px;
    }
}

@media (max-width: 768px) {
    .form-group { flex-basis: 100%; }
    .controls-card { flex-direction: column; align-items: stretch; }
    #search-input { width: 100%; }
}

@media (max-width: 600px) {
    .container {
        padding: 6px;
        max-width: 100vw;
    }
    .form-card, .controls-card, .table-card {
        padding: 8px;
        margin-bottom: 10px;
    }
    #search-input, #status-filter, .btn-add, .btn-danger {
        width: 100%;
        font-size: 0.95rem;
        min-width: 0;
        box-sizing: border-box;
        margin-bottom: 6px;
    }
    .controls-card {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 8px;
    }
    .filter-group, .search-filter {
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }
    table {
        width: 100%;
        font-size: 0.85rem;
        table-layout: fixed;
    }
    th, td {
        padding: 6px 2px;
        word-break: break-word;
        font-size: 0.85em;
    }
    th, td {
        max-width: 70px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    th:nth-child(1), td:nth-child(1) { max-width: 90px; } /* Task */
    th:nth-child(2), td:nth-child(2) { max-width: 70px; } /* Due */
    th:nth-child(3), td:nth-child(3) { max-width: 60px; } /* Status */
    th:nth-child(4), td:nth-child(4) { max-width: 60px; } /* Action */
    .actions button, .actions input[type="checkbox"] {
        font-size: 1rem;
        padding: 2px;
        margin: 0 2px;
    }
    header h1 {
        font-size: 1.1em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .notification {
        left: 6px;
        right: 6px;
        width: auto;
        transform: none;
        font-size: 0.95em;
        padding: 10px 12px;
    }
}