* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
}

:root {
    --bg-gradient-start: #0d9488;
    --bg-gradient-end: #14b8a6;
    --card-bg: white;
    --text-color: #333;
    --text-light: #666;
    --border-color: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
    --logo-bg: white;
    --logo-color: #0d9488;
}

body.dark-mode {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --card-bg: #0f1419;
    --text-color: #e4e4e7;
    --text-light: #a1a1aa;
    --border-color: #27272a;
    --shadow: rgba(0, 0, 0, 0.3);
    --logo-bg: #27272a;
    --logo-color: #14b8a6;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed; /* Keep gradient fixed while scrolling */
    min-height: 100vh;
    height: auto; /* Allow body to grow */
    display: block; /* Changed from flex to allow natural scrolling */
    padding: 20px;
    padding-bottom: 80px; /* Extra space at bottom for scrolling */
    transition: background 0.3s ease;
}

/* Container wrapper to center content */
body > * {
    margin-left: auto;
    margin-right: auto;
}

/* Header Section */
.heading-container.header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 30px auto 40px auto;
    animation: fadeInDown 0.6s ease;
    width: 100%;
    max-width: 700px;
}

.heading-container.header-title h1 {
    color: white;
    font-size: 2.5rem;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.logo-icon {
    width: 60px;
    height: 60px;
    min-width: 60px;
    background: var(--logo-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    color: var(--logo-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: pulse 2s ease-in-out infinite;
}

.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 10px 20px !important;
    font-size: 20px !important;
    background: rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(10px);
    border: 2px solid white !important;
    color: white !important;
    cursor: pointer;
    z-index: 1000;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.logout-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px !important;
    font-size: 14px !important;
    background: rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(10px);
    border: 2px solid white !important;
    color: white !important;
    z-index: 1000;
}

/* Input Container */
.heading-container.task-input-container {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
    max-width: 900px;
    width: 100%;
    margin-bottom: 20px;
    animation: fadeInUp 0.6s ease;
}

/* Task Controls */
.task-controls {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    max-width: 900px;
    width: 100%;
    margin-bottom: 20px;
}

.task-counter {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.toggle-completed-btn {
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-completed-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.toggle-completed-btn.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.toggle-completed-btn.active:hover {
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

#searchInput {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    background: var(--card-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
}

#searchInput:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

select {
    padding: 12px 18px;
    padding-right: 40px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230d9488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

body.dark-mode select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2314b8a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

select:hover {
    border-color: #0d9488;
    background-color: rgba(13, 148, 136, 0.02);
}

select:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

select option {
    padding: 10px;
    background: var(--card-bg);
    color: var(--text-color);
}

input[type="text"] {
    flex: 1;
    min-width: 250px;
    padding: 12px 18px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    background: var(--card-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
}

textarea {
    width: 100%;
    min-width: 250px;
    padding: 12px 18px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    background: var(--card-bg);
    color: var(--text-color);
    resize: vertical;
    font-family: inherit;
    transition: all 0.3s ease;
}

textarea:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

input[type="text"]:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Custom Category Input */
#customCategory {
    min-width: 200px;
    padding: 12px 18px;
    font-size: 15px;
    border: 2px solid #0d9488;
    border-radius: 8px;
    outline: none;
    background: var(--card-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
    animation: slideIn 0.3s ease;
}

#customCategory:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

#customCategory::placeholder {
    color: var(--text-light);
    font-style: italic;
}

/* Date Input Wrapper */
.date-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0 12px;
    transition: all 0.3s ease;
}

.date-input-wrapper:hover {
    border-color: rgba(13, 148, 136, 0.5);
}

.date-input-wrapper:focus-within {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.date-icon {
    font-size: 18px;
    margin-right: 8px;
    user-select: none;
    pointer-events: none;
}

.date-input-wrapper input[type="date"] {
    border: none;
    padding: 12px 6px;
    background: transparent;
    flex: 1;
}

.date-input-wrapper input[type="date"]:focus {
    box-shadow: none;
}

input[type="date"] {
    padding: 12px 18px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    position: relative;
}

input[type="date"]:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Modern Calendar Styling */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    border-radius: 4px;
    margin-left: 8px;
    opacity: 0.7;
    transition: all 0.2s ease;
    padding: 4px;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background: rgba(13, 148, 136, 0.1);
    transform: scale(1.1);
}

input[type="date"]::-webkit-datetime-edit {
    padding: 0;
}

input[type="date"]::-webkit-datetime-edit-fields-wrapper {
    padding: 0;
}

input[type="date"]::-webkit-datetime-edit-text {
    color: var(--text-light);
    padding: 0 2px;
}

input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
    color: var(--text-color);
    font-weight: 500;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

input[type="date"]::-webkit-datetime-edit-month-field:hover,
input[type="date"]::-webkit-datetime-edit-day-field:hover,
input[type="date"]::-webkit-datetime-edit-year-field:hover {
    background: rgba(13, 148, 136, 0.1);
}

input[type="date"]::-webkit-datetime-edit-month-field:focus,
input[type="date"]::-webkit-datetime-edit-day-field:focus,
input[type="date"]::-webkit-datetime-edit-year-field:focus {
    background: rgba(13, 148, 136, 0.2);
    outline: none;
}

/* Style the calendar icon with teal color */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: brightness(0) saturate(100%) invert(48%) sepia(79%) saturate(434%) hue-rotate(126deg) brightness(95%) contrast(92%);
}

body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator {
    filter: brightness(0) saturate(100%) invert(69%) sepia(56%) saturate(449%) hue-rotate(126deg) brightness(96%) contrast(89%);
}

button {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.4);
}

button:active {
    transform: translateY(0);
}

/* Task List */
ul {
    list-style-type: none;
    width: 100%;
    max-width: 900px;
    padding: 0;
}

li {
    background: var(--card-bg);
    font-size: 16px;
    margin: 12px 0;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: slideIn 0.3s ease;
    position: relative;
    border-left: 4px solid transparent;
    cursor: grab;
}

li:active {
    cursor: grabbing;
}

li:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px var(--shadow);
}

li.dragging {
    opacity: 0.5;
    transform: rotate(2deg) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    cursor: grabbing;
}

li.drag-over {
    border-top: 3px solid #14b8a6;
}

/* Completion animations */
li.completing {
    animation: completeTask 0.4s ease forwards;
}

li.completed-task {
    opacity: 0.7;
    transition: all 0.5s ease;
}

li.fade-out {
    animation: fadeOutTask 0.6s ease forwards;
}

@keyframes completeTask {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.98);
        background: rgba(13, 148, 136, 0.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes fadeOutTask {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
        height: auto;
    }
    50% {
        opacity: 0.5;
        transform: translateX(-15px) scale(0.95);
    }
    100% {
        opacity: 0;
        transform: translateX(-30px) scale(0.9);
        height: 0;
        min-height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

li[data-priority="high"] {
    border-left-color: #ef4444;
}

li[data-priority="medium"] {
    border-left-color: #f59e0b;
}

li[data-priority="low"] {
    border-left-color: #10b981;
}

li.overdue {
    background: #fee2e2 !important;
}

body.dark-mode li.overdue {
    background: #7f1d1d !important;
}

li:hover {
    transform: translateX(5px);
    box-shadow: 0 6px 15px var(--shadow);
}

li:hover .task-actions {
    opacity: 1;
}

.task-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: var(--text-color);
}

.task-text {
    font-size: 16px;
    word-break: break-word;
}

.task-notes {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 5px;
    padding: 8px 12px;
    background: var(--border-color);
    border-radius: 6px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.task-notes-toggle {
    color: #0d9488;
    cursor: pointer;
    font-size: 13px;
    margin-top: 5px;
    text-decoration: underline;
    display: inline-block;
}

.task-notes-toggle:hover {
    color: #0a7a6f;
}

.task-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-light);
}

.task-date, .task-category, .task-priority, .task-recurrence {
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--border-color);
}

.task-recurrence {
    background: #e0e7ff;
    color: #4338ca;
    font-weight: 500;
}

body.dark-mode .task-recurrence {
    background: #3730a3;
    color: #c7d2fe;
}

.task-category.work {
    background: #dbeafe;
    color: #1e40af;
}

.task-category.personal {
    background: #fce7f3;
    color: #9f1239;
}

.task-category.urgent {
    background: #fed7aa;
    color: #9a3412;
}

.task-category.custom {
    background: linear-gradient(135deg, #a78bfa 0%, #c084fc 100%);
    color: white;
    font-weight: 500;
    text-transform: capitalize;
}

body.dark-mode .task-category.work {
    background: #1e3a8a;
    color: #93c5fd;
}

body.dark-mode .task-category.personal {
    background: #831843;
    color: #fbcfe8;
}

body.dark-mode .task-category.urgent {
    background: #7c2d12;
    color: #fed7aa;
}

body.dark-mode .task-category.custom {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: white;
}

.task-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.edit-btn, .delete-btn {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.edit-btn {
    background: #0d9488;
    color: white;
}

.edit-btn:hover {
    background: #0a7a6f;
    transform: scale(1.05);
}

.delete-btn {
    background: #ff4757;
    color: white;
}

.delete-btn:hover {
    background: #ff3838;
    transform: scale(1.05);
}

/* Checkbox Styling */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 24px;
    height: 24px;
    min-width: 24px;
    border: 2.5px solid #d0d0d0;
    border-radius: 6px;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

input[type="checkbox"]:hover {
    border-color: #0d9488;
}

input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    border-color: #0d9488;
}

input[type="checkbox"]:checked::after {
    content: '✓';
    font-size: 16px;
    font-weight: bold;
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Edit Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideInUp 0.3s ease;
    position: relative;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: var(--text-color);
}

.modal-content h2 {
    color: var(--text-color);
    margin-bottom: 20px;
    font-size: 24px;
}

#editTaskForm {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#editTaskForm input,
#editTaskForm textarea,
#editTaskForm select {
    width: 100%;
    padding: 12px 18px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    background: var(--card-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
    font-family: inherit;
}

#editTaskForm input:focus,
#editTaskForm textarea:focus,
#editTaskForm select:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-btn {
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    color: white;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.4);
}

.cancel-btn {
    background: #ef4444;
    color: white;
}

.cancel-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 15px 10px;
        padding-bottom: 100px; /* Extra space for mobile scrolling */
    }

    /* Header */
    .heading-container.header-title {
        flex-direction: column;
        gap: 10px;
        margin: 15px 0 20px 0;
        padding: 0 10px;
    }

    .heading-container.header-title h1 {
        font-size: 1.8rem;
        text-align: center;
    }

    .logo-icon {
        width: 50px;
        height: 50px;
        min-width: 50px;
        font-size: 30px;
    }

    .theme-toggle {
        position: fixed;
        top: 10px;
        left: 10px;
        width: auto;
        padding: 8px 16px !important;
        font-size: 18px !important;
    }

    .logout-btn {
        position: fixed;
        top: 10px;
        right: 10px;
        width: auto;
        padding: 8px 16px !important;
        font-size: 13px !important;
    }

    /* Task Input Form */
    .heading-container.task-input-container {
        padding: 20px 15px;
        margin-bottom: 15px;
    }

    input[type="text"],
    textarea,
    select,
    .date-input-wrapper,
    #customCategory {
        min-width: 100%;
        width: 100%;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    textarea {
        min-height: 80px;
    }

    button {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
    }

    /* Task Controls */
    .task-controls {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
        gap: 10px;
    }

    .task-counter {
        text-align: center;
        font-size: 16px;
    }

    .toggle-completed-btn {
        width: 100%;
        justify-content: center;
    }

    #searchInput {
        width: 100%;
        min-width: 100%;
    }

    #filterCategory {
        width: 100%;
    }

    /* Task List Items */
    li {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
        gap: 10px;
    }

    .task-content {
        width: 100%;
    }

    .task-text {
        font-size: 15px;
    }

    .task-meta {
        flex-wrap: wrap;
        font-size: 11px;
    }

    .task-actions {
        opacity: 1; /* Always show on mobile */
        width: 100%;
        justify-content: flex-end;
    }

    .edit-btn, .delete-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    /* Checkbox */
    input[type="checkbox"] {
        width: 22px;
        height: 22px;
        min-width: 22px;
        align-self: flex-start;
        margin-top: 2px;
    }
}

@media (max-width: 480px) {
    .heading-container.header-title h1 {
        font-size: 1.5rem;
    }

    .logo-icon {
        width: 45px;
        height: 45px;
        min-width: 45px;
        font-size: 26px;
    }

    .task-text {
        font-size: 14px;
    }

    .task-meta {
        font-size: 10px;
    }
}

