/* ===================================
   TaskMaster - Clean Modern Design
   =================================== */

/* CSS Variables - Light Theme (Default) */
:root {
    --bg-body: #e8eef4;
    --bg-card: #ffffff;
    --bg-input: #f5f7fa;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-muted: #a0aec0;
    --accent-primary: #7c3aed;
    --accent-light: #ede9fe;
    --stat-total: #4a5568;
    --stat-done: #22c55e;
    --stat-pending: #7c3aed;
    --priority-high: #f97316;
    --priority-high-bg: rgba(249, 115, 22, 0.12);
    --priority-medium: #14b8a6;
    --priority-medium-bg: rgba(20, 184, 166, 0.12);
    --priority-low: #6366f1;
    --priority-low-bg: rgba(99, 102, 241, 0.12);
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --transition: 0.2s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-body: #1a1d23;
    --bg-card: #242830;
    --bg-input: #2d323a;
    --text-primary: #f7fafc;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --border-color: #3d4450;
    --stat-total: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* App Layout */
.app-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
}

.app-container {
    width: 100%;
    max-width: 580px;
    background: var(--bg-card);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 28px 32px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: var(--accent-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.brand-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* Statistics Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-input);
    border-radius: 12px;
    padding: 16px 20px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
}

.stat-total .stat-value {
    color: var(--stat-total);
}

.stat-done .stat-value {
    color: var(--stat-done);
}

.stat-pending .stat-value {
    color: var(--stat-pending);
}

/* Add Task Section */
.add-task-section {
    margin-bottom: 20px;
}

.add-task-form {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.add-icon {
    color: var(--text-muted);
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
}

.add-task-input {
    flex: 1;
    padding: 8px 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.add-task-input::placeholder {
    color: var(--text-muted);
}

.priority-select {
    padding: 8px 28px 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23718096' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: var(--transition);
    flex-shrink: 0;
}

.priority-select:focus {
    outline: none;
}

.priority-select:hover {
    background-color: var(--bg-card);
}

.add-task-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.add-task-btn:hover {
    background: #6d28d9;
    transform: scale(1.05);
}

.add-task-btn i {
    font-size: 16px;
    font-weight: bold;
}

/* Filters Section */
.filters-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.filter-tabs {
    display: flex;
    gap: 4px;
}

.filter-tab {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.filter-tab:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

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

.sort-dropdown {
    position: relative;
}

.sort-select {
    padding: 8px 32px 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23718096' viewBox='0 0 16 16'%3E%3Cpath d='M3 5h10M3 8h7M3 11h4'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23718096' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center, right 10px center;
    padding-left: 32px;
}

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

/* App Footer */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
}

.task-progress {
    font-size: 13px;
    color: var(--text-muted);
}

.clear-completed-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: var(--transition);
}

.clear-completed-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.clear-completed-btn:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

.clear-completed-btn:disabled:hover {
    background: transparent;
}

/* Attribution Footer */
.attribution-footer {
    text-align: center;
    padding: 16px 0 0;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

/* Todo List */
.todo-list-section {
    min-height: 200px;
}

.todo-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.todo-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: var(--transition);
    cursor: grab;
}

.todo-item:hover {
    box-shadow: var(--shadow-sm);
}

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

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

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

/* Todo Checkbox */
.todo-checkbox {
    flex-shrink: 0;
    margin-top: 2px;
}

.todo-checkbox input {
    display: none;
}

.todo-checkbox label {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
}

.todo-checkbox label:hover {
    border-color: var(--accent-primary);
}

.todo-checkbox input:checked+label {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.todo-checkbox input:checked+label::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Todo Content */
.todo-content {
    flex: 1;
    min-width: 0;
}

.todo-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
    word-break: break-word;
}

.todo-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Priority Badge */
.priority-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.priority-badge.high {
    background: var(--priority-high-bg);
    color: var(--priority-high);
}

.priority-badge.medium {
    background: var(--priority-medium-bg);
    color: var(--priority-medium);
}

.priority-badge.low {
    background: var(--priority-low-bg);
    color: var(--priority-low);
}


/* Todo Due Date */
.todo-due {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

.todo-due i {
    font-size: 12px;
}

.todo-due.overdue {
    color: var(--priority-high);
}

.todo-due.today {
    color: var(--priority-medium);
}

/* Todo Actions */
.todo-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: var(--transition);
}

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

.todo-actions .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    transition: var(--transition);
}

.todo-actions .btn-edit {
    background: var(--accent-light);
    color: var(--accent-primary);
}

.todo-actions .btn-edit:hover {
    background: var(--accent-primary);
    color: white;
}

.todo-actions .btn-delete {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

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

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state.d-none {
    display: none;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state span {
    font-size: 13px;
}

/* Modal Styles */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
}

.modal-title {
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
}

.modal .form-control,
.modal .form-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 10px 14px;
}

.modal .form-control:focus,
.modal .form-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.modal .form-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
}

.modal .btn-primary {
    background: var(--accent-primary);
    border: none;
}

.modal .btn-primary:hover {
    background: #6d28d9;
}

.modal .btn-secondary {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Toast */
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
}

.toast.bg-success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(22, 163, 74, 0.95)) !important;
    color: white;
}

.toast.bg-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(220, 38, 38, 0.95)) !important;
    color: white;
}

.toast.bg-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.95)) !important;
    color: white;
}

/* Sortable States */
.sortable-ghost {
    opacity: 0.5;
    background: #d1d5db;
    border: 2px dashed var(--accent-primary);
}

[data-theme="dark"] .sortable-ghost {
    background: #4b5563;
}

.sortable-chosen {
    box-shadow: var(--shadow-md);
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.todo-item.removing {
    animation: slideOut 0.25s ease forwards;
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Responsive Design */
@media (max-width: 576px) {
    .app-wrapper {
        padding: 16px;
    }

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

    .brand-name {
        font-size: 18px;
    }

    .stat-card {
        padding: 12px 14px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-label {
        font-size: 10px;
    }

    .add-task-form {
        flex-wrap: wrap;
        gap: 8px;
    }

    .add-task-input {
        flex: 1 1 100%;
        order: 1;
        min-width: 0;
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }

    .add-icon {
        display: none;
    }

    .priority-select {
        flex: 1;
        order: 2;
    }

    .add-task-btn {
        order: 3;
    }

    .filter-tabs {
        flex-wrap: wrap;
    }

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

    .todo-actions {
        opacity: 1;
    }

    .todo-actions .btn {
        width: 28px;
        height: 28px;
    }

    .todo-text-input {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Focus States */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: none;
}

/* Inline Editing Styles */
.todo-text-input {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 2px solid var(--accent-primary);
    border-radius: 6px;
    padding: 4px 8px;
    width: 100%;
    max-width: 300px;
    outline: none;
}

.todo-text-input:focus {
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Inline Priority Dropdown */
.priority-dropdown {
    position: relative;
    display: inline-block;
}

.priority-badge {
    cursor: pointer;
    user-select: none;
}

.priority-badge:hover {
    opacity: 0.8;
}

.priority-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 6px 0;
    min-width: 130px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s ease;
}

.priority-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.priority-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 14px;
    color: var(--text-primary);
}

.priority-option:hover,
.priority-option.selected {
    background: var(--bg-input);
}

.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.priority-dot.low {
    background: var(--priority-low);
}

.priority-dot.medium {
    background: var(--priority-medium);
}

.priority-dot.high {
    background: var(--priority-high);
}


/* Inline Date Input */
.todo-due {
    cursor: pointer;
}

.todo-due:hover {
    opacity: 0.8;
}

.inline-date-input {
    font-size: 12px;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 2px solid var(--accent-primary);
    border-radius: 6px;
    padding: 4px 8px;
    outline: none;
}

.inline-date-input:focus {
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Delete button always visible */
.todo-actions .btn-delete {
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

/* Remove edit button since we use inline editing */
.todo-actions .btn-edit {
    display: none;
}