:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #6366f1;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --bg-gradient-start: #f8fafc;
    --bg-gradient-end: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --completed-color: #94a3b8;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.main-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    padding: 2.5rem 0;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.header-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

/* Header Top para alinear titulo y botón de tema */
.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.main-header h1 {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.main-header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

.header-decoration {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.circle-1 {
    width: 100px;
    height: 100px;
    top: -30px;
    left: -30px;
}

.circle-2 {
    width: 150px;
    height: 150px;
    bottom: -50px;
    right: -50px;
}

.circle-3 {
    width: 80px;
    height: 80px;
    top: 50%;
    right: 10%;
}

/* Theme Toggle Button */
.theme-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.theme-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(15deg);
}

/* Card Styles */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

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

.section-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Input Section */
.input-group {
    display: flex;
    gap: 0.75rem;
}

#todo-input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--card-bg);
    color: var(--text-color);
}

#todo-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-add {
    padding: 0.875rem 1.75rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-add:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-add:active {
    transform: translateY(0);
}

.error-msg {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.75rem;
    min-height: 1.25rem;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.05);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-msg::before {
    content: "⚠";
    font-size: 1rem;
}

/* Filter Section */
.filter-container {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-btn {
    flex: 1;
    min-width: 120px;
    padding: 0.875rem 1.25rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    color: var(--text-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.filter-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.filter-btn:not(.active) .filter-count {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

/* List Section */
.section-header {
    margin-bottom: 1.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color) 0%, #34d399 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.6s ease;
}

.progress-text {
    text-align: right;
    color: var(--text-light);
    font-size: 0.875rem;
    font-weight: 500;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-light);
}

.empty-state i {
    font-size: 3.5rem;
    color: var(--border-color);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

/* Todo List */
.todo-list {
    list-style: none;
}

.todo-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    animation: slideIn 0.3s ease;
    cursor: grab;
    position: relative;
}

.todo-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.todo-item.completed {
    background: var(--bg-color);
    border-color: var(--border-color);
}

/* Número de tarea */
.task-number {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-light);
    min-width: 30px;
    text-align: center;
    background: var(--bg-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Estilo para Drag & Drop */
.todo-item.dragging {
    opacity: 0.5;
    background: var(--bg-color);
    border: 2px dashed var(--primary-color);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.check-btn {
    background: none;
    border: 2px solid var(--border-color);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.check-btn:hover {
    border-color: var(--secondary-color);
    background: rgba(16, 185, 129, 0.1);
}

.completed .check-btn {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

.todo-content {
    flex: 1;
    cursor: pointer;
    font-size: 1.05rem;
    padding: 0.25rem 0;
    transition: var(--transition);
}

.todo-content:hover {
    color: var(--primary-color);
}

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

/* Input para Edición */
.edit-input {
    flex: 1;
    font-size: 1.05rem;
    padding: 0.5rem;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-color);
    font-family: inherit;
}

.edit-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Botón de Ayuda */
.help-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.help-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.delete-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

/* Stats Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.stat-icon.completed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
}

.stat-icon.total {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-number {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Footer */
.main-footer {
    margin-top: 3rem;
    padding: 2rem 0;
    text-align: center;
    color: var(--text-light);
    border-top: 1px solid var(--border-color);
}

.footer-content p:first-child {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.footer-subtitle {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Modal de Confirmación Personalizado */
.custom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.custom-modal.show {
    display: flex;
}

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

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
    border: 1px solid var(--border-color);
}

/* Estilos para la barra de scroll del modal */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

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

.modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-icon {
    width: 48px;
    height: 48px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.modal-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-text {
    color: var(--text-light);
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.modal-btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
}

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

.modal-btn-cancel:hover {
    background: var(--border-color);
}

.modal-btn-confirm {
    background: var(--danger-color);
    color: white;
}

.modal-btn-confirm:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Estilos para Modal de Ayuda */
.help-modal-content {
    max-width: 600px;
    padding: 1.5rem;
}

.help-section {
    margin-bottom: 1.25rem;
}

.help-section h4 {
    font-family: 'Poppins', sans-serif;
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.help-list {
    list-style: none;
    padding-left: 0;
}

.help-list li {
    padding: 0.375rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-light);
    line-height: 1.5;
    font-size: 0.9rem;
}

.help-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.help-list strong {
    color: var(--text-color);
}

.modal-btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
}

.modal-btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* MODO OSCURO */
body.dark-mode {
    --bg-color: #0f172a;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-light: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
    --completed-color: #64748b;
}

body.dark-mode .main-header {
    background: linear-gradient(135deg, #312e81 0%, #4338ca 100%);
}

body.dark-mode .circle {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .filter-btn:not(.active) .filter-count {
    background: rgba(79, 70, 229, 0.2);
    color: var(--primary-light);
}

body.dark-mode .stat-card {
    background: #0f172a;
}

body.dark-mode .task-number {
    background: #0f172a;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container { padding: 0 15px; }
    .main-header { padding: 2rem 0; margin-bottom: 1.5rem; }
    .main-header h1 { font-size: 2rem; }
    .card { padding: 1.5rem; }
    .input-group { flex-direction: column; }
    .btn-add { width: 100%; justify-content: center; }
    .filter-container { flex-direction: column; }
    .filter-btn { min-width: 100%; }
    .stats-grid { grid-template-columns: 1fr; }
    .todo-item { padding: 1rem; }
}

@media (max-width: 480px) {
    .main-header h1 { font-size: 1.75rem; }
    .section-title { font-size: 1.125rem; }
    .card { padding: 1.25rem; }
    .todo-item { flex-wrap: wrap; }
    .todo-content { width: 100%; order: 3; margin-top: 0.5rem; }
    .modal-content { 
        padding: 1.5rem;
        max-height: 90vh;
    }
    .help-modal-content {
        padding: 1.25rem;
    }
    .help-section {
        margin-bottom: 1rem;
    }
    .help-section h4 {
        font-size: 0.95rem;
    }
    .help-list li {
        font-size: 0.85rem;
        padding: 0.3rem 0;
    }
}