:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #EEF2FF;
    --success: #22C55E;
    --success-light: #DCFCE7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --bg-main: #F9FAFB;
    --bg-sidebar: #FFFFFF;
    --text-dark: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --sidebar-width: 280px;
    --header-height: 75px;
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 900;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.logo-icon { font-size: 1.75rem; color: var(--primary); }
.logo-text { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.025em; }

.nav-section { margin-bottom: 2.5rem; }
.nav-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    padding-left: 0.5rem;
}

.nav-list { list-style: none; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    margin-bottom: 0.5rem;
}

.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; }

.sidebar-select, .header-select, .form-group select {
    appearance: none;
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' 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 0.75rem center;
    background-size: 1rem;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-select:hover, .header-select:hover, .form-group select:hover {
    border-color: #D1D5DB;
    background-color: var(--bg-main);
}

.sidebar-select:focus, .header-select:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}


.sidebar-footer { margin-top: auto; }

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 800;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
}


.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--text-dark);
}

.sidebar-toggle:hover { background: var(--bg-main); }

.search-container {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-container i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-container input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-main);
    outline: none;
    transition: var(--transition);
}

.search-container input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.header-right { 
    display: flex; 
    gap: 1rem; 
    align-items: center;
    margin-left: 2rem;
}

.header-select {
    min-width: 180px;
    height: 46px;
}



/* Dashboard */
.dashboard { padding: 3rem; max-width: 1400px; margin: 0 auto; width: 100%; }
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.dashboard-header h2 { font-size: 1.75rem; font-weight: 800; }

/* Grid */
.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
}

/* Card CRUD Animations */
@keyframes cardSlideIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cardSlideOut {
    from { opacity: 1; transform: scale(1); max-height: 300px; margin-bottom: 1.5rem; }
    to   { opacity: 0; transform: scale(0.92); max-height: 0;   margin-bottom: 0; padding: 0; }
}

/* Task Card */
.task-card {

    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.task-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.task-done {
    opacity: 0.72;
    border-left: 4px solid var(--success);
    transition: opacity 0.25s ease, border-left-color 0.25s ease;
}
.task-done .task-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.status-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.status-done    { background: var(--success-light); color: var(--success); }
.status-pending { background: #FEF9EC; color: #B45309; }


.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.priority-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.priority-high { background: var(--danger-light); color: var(--danger); }
.priority-medium { background: #FEF3C7; color: var(--warning); }
.priority-low { background: var(--success-light); color: var(--success); }

.card-actions { display: flex; gap: 0.5rem; }
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-main);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover { background: var(--primary-light); color: var(--primary); }
.btn-check:hover { background: var(--success-light); color: var(--success); }
.btn-del:hover { background: var(--danger-light); color: var(--danger); }

.task-title { font-size: 1.125rem; font-weight: 700; margin-bottom: 0.5rem; }
.task-desc { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1.5rem; flex: 1; }

.card-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-footer i { margin-right: 0.5rem; }

/* Buttons */
.btn {
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius);
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.btn-primary { 
    background: linear-gradient(135deg, var(--primary), #6366F1);
    color: white; 
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -1px rgba(79, 70, 229, 0.1);
}

.btn-primary:hover { 
    background: linear-gradient(135deg, var(--primary-dark), #4F46E5);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3), 0 4px 6px -2px rgba(79, 70, 229, 0.1);
}


.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary { background: white; border: 1px solid var(--border); color: var(--text-dark); }

.btn-secondary:hover { background: var(--bg-main); }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.75rem; }

/* Loader */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 4rem 2rem;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.spinner {
    width: 52px;
    height: 52px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1.5rem;
}

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

.loader-container p {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.01em;
}

/* Empty State */
.empty-state {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    padding: 4rem 2rem;
    text-align: center;
    background: white;
    border-radius: var(--radius);
    border: 2px dashed var(--border);
    animation: fadeIn 0.5s ease;
}

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

.empty-state-content {
    max-width: 420px;
}

.empty-state-icon {
    font-size: 4rem;
    background: linear-gradient(135deg, var(--primary), #6366F1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.5rem;
    display: block;
    opacity: 0.7;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

.empty-state-description {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1rem;
    line-height: 1.7;
}


/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1.5rem;
}

.modal.show { display: flex; }

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 1.5rem;
    padding: 2.5rem;
    animation: modalIn 0.3s ease;
}

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

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.modal-header h2 { font-size: 1.5rem; font-weight: 800; }
.close-modal { background: transparent; border: none; font-size: 1.25rem; color: var(--text-muted); cursor: pointer; }

.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 700; margin-bottom: 0.5rem; }
.form-group input, .form-group textarea {
    width: 100%;
    padding: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    font-family: inherit;
    transition: var(--transition);
}


.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.form-group textarea { height: 120px; resize: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.modal-footer { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; }

/* Popup System */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.popup-overlay.active {
    display: flex;
    opacity: 1;
}

.popup-card {
    background: white;
    width: 100%;
    max-width: 400px;
    border-radius: 1.5rem;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-xl);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.popup-overlay.active .popup-card {
    transform: scale(1);
}

.popup-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    display: block;
}

.popup-success .popup-icon { color: var(--success); }
.popup-error .popup-icon { color: var(--danger); }
.popup-confirm .popup-icon { color: var(--warning); }

.popup-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

.popup-message {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1rem;
    line-height: 1.6;
}

.popup-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.popup-actions .btn {
    min-width: 120px;
}


/* Responsive */
@media (max-width: 1024px) {
    :root { --sidebar-width: 0; }
    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
    }
    .sidebar.open { left: 0; }
    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
    .top-header { padding: 0 1.25rem; }
    .dashboard { padding: 1.5rem; }
    .header-left { gap: 1rem; }
}

@media (max-width: 768px) {
    .header-right span { display: none; }
    .btn-primary#openAddModal { 
        width: 46px; 
        height: 46px; 
        padding: 0; 
        border-radius: 14px;
    }
    .header-right button i { margin: 0; font-size: 1.4rem; }
    .form-row { grid-template-columns: 1fr; }
    .modal-content { padding: 2rem; }
    .search-container { max-width: 180px; }
}


/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background: white;
    box-shadow: 0 20px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.08);
    border-left: 4px solid var(--primary);
    z-index: 9999;
    max-width: 380px;
    min-width: 280px;
    transform: translateY(120%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.toast-show {
    transform: translateY(0);
}

.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }

.toast-msg {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.875rem;
    flex-shrink: 0;
    transition: color 0.2s;
}
.toast-close:hover { color: var(--text-dark); }

/* Danger Button */
.btn-danger {
    background: linear-gradient(135deg, var(--danger), #DC2626);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    transform: translateY(-1px);
}

.hidden { display: none !important; }
