/* ===== Apple Premium Design System ===== */
:root {
    /* Colors - Light Mode (Apple Inspired) */
    --bg-primary: #f5f5f7;
    --bg-surface: rgba(255, 255, 255, 0.72);
    --bg-card: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #d2d2d7;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-glow: rgba(0, 113, 227, 0.3);
    --success: #34c759;
    --danger: #ff3b30;
    --border-color: rgba(0, 0, 0, 0.08);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-float: 0 20px 40px rgba(0, 0, 0, 0.12);
    
    /* Geometry */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-pill: 9999px;
    
    /* Animation */
    --spring: cubic-bezier(0.25, 1, 0.5, 1);
    --transition: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@supports (font-variation-settings: normal) {
    :root {
        font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.47059;
    font-weight: 400;
    letter-spacing: -0.022em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== App Container ===== */
.app-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header (Glassmorphism) ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 20px 0;
    margin-bottom: 40px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 860px;
    margin: 0 auto;
    padding: 0 20px;
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--text-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-sm);
}

.logo h1 {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}

.header-stats {
    display: flex;
    gap: 16px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* ===== Typography Header ===== */
.page-title {
    font-size: 48px;
    line-height: 1.08349;
    font-weight: 700;
    letter-spacing: -0.002em;
    text-align: center;
    margin-bottom: 40px;
}

/* ===== Add Task Form ===== */
.add-task-section {
    margin-bottom: 30px;
}

.add-task-form {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px;
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition), transform var(--transition);
}

.add-task-form:focus-within {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.form-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input-group {
    flex: 1;
}

.input-group-title {
    flex: 2;
}

.input-group input {
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 17px;
    font-weight: 400;
    outline: none;
}

.input-group input::placeholder {
    color: var(--text-secondary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 24px;
    border: none;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-add {
    background: var(--accent);
    color: white;
}

.btn-add:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-add:active {
    transform: scale(0.96);
}

/* ===== Filter Tabs (Segmented Control) ===== */
.filter-section {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.filter-tabs {
    display: inline-flex;
    background: rgba(118, 118, 128, 0.12);
    border-radius: var(--radius-pill);
    padding: 4px;
    gap: 2px;
}

.filter-tab {
    padding: 6px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-tab.active {
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

/* ===== Task List ===== */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 60px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    animation: slideUp 0.4s var(--spring) both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-item:hover {
    box-shadow: var(--shadow-md);
    transform: scale(1.01);
}

.task-item.completed {
    opacity: 0.5;
    background: transparent;
    box-shadow: none;
    border: 1px solid var(--border-color);
}

.task-item.completed:hover {
    opacity: 0.8;
}

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

/* Checkbox (Apple Style) */
.task-checkbox {
    position: relative;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    cursor: pointer;
}

.task-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.task-checkbox .checkmark {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border: 1.5px solid var(--text-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.task-checkbox input:hover ~ .checkmark {
    border-color: var(--text-secondary);
}

.task-checkbox input:checked ~ .checkmark {
    background: var(--success);
    border-color: var(--success);
}

.task-checkbox .checkmark svg {
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: white;
}

.task-checkbox input:checked ~ .checkmark svg {
    opacity: 1;
    transform: scale(1);
}

/* Task Content */
.task-content {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 17px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    word-break: break-word;
    transition: color 0.2s;
}

.task-description {
    font-size: 14px;
    color: var(--text-secondary);
    word-break: break-word;
    line-height: 1.3;
}

.task-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 8px;
}

/* Task Actions */
.task-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(10px);
    transition: all var(--transition);
}

.task-item:hover .task-actions {
    opacity: 1;
    transform: translateX(0);
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.04);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
    transform: scale(1.1);
}

/* ===== Empty & Loading States ===== */
.empty-state, .loading-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.empty-state svg {
    margin-bottom: 20px;
    opacity: 0.4;
    width: 48px;
    height: 48px;
}

.empty-state p {
    font-size: 17px;
    font-weight: 500;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-color);
    border-top-color: var(--text-secondary);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px) scale(0.9);
    padding: 12px 24px;
    background: rgba(29, 29, 31, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-pill);
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-float);
    opacity: 0;
    transition: all 0.4s var(--spring);
    z-index: 1000;
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
}

/* ===== Footer ===== */
.app-footer {
    margin-top: auto;
    padding: 40px 0;
    text-align: center;
}

.app-footer p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .page-title {
        font-size: 32px;
        margin-bottom: 30px;
    }

    .form-row {
        flex-direction: column;
    }

    .input-group input {
        padding: 12px 16px;
    }

    .btn-add {
        width: 100%;
        padding: 14px;
        border-radius: var(--radius-md);
    }

    .task-actions {
        opacity: 1;
        transform: none;
    }
}
